Reputation: 51
How can I add a C++ DLL file in my .NET application?
Upvotes: 5
Views: 2777
Reputation: 22148
If it's registered in COM, you can simply add a COM reference in Visual Studio and Visual Studio will do all the Interop creation for you.
Upvotes: 0
Reputation: 1755
Assuming you use Visual Studio, in your Solution right click "references" and choose "Add Reference". Select your dll file.
In the classes that will use the dll, add : using MyLibrarysName;
then you can call the functions in that DLL using Mylibraryname.myfunction
Upvotes: 0
Reputation: 217233
Depending on the nature of the DLL, you can
Write a wrapper in C++/CLI.
Upvotes: 6
Reputation: 49534
You would use an "extern" function, marked with the DllImport attribute.
[DllImport(@“C:\mylib.dll”)]
public static extern int myFunc(int param);
Upvotes: 6