Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
suppose, if i have a DLL file that i created in C++ WITHOUT using COM

Can i load it directly in .NET??

or COM is required???

if i can load it directly, then how??
Posted
Comments
TinyDevices 15-May-12 9:49am    
All those Win32 API that you (might) use in managed apps are NOT COM dlls. When there is way to use Win32 Dll, there is certainly a way for your DLL as well. The rest as explained in the other reply here.

1 solution

No, COM is not required. Yes, you can load exported native DLL functions in your .NET application and use them using Platform Invocation Services, P/Invoke.

Please see:
http://en.wikipedia.org/wiki/P/Invoke[^],
http://msdn.microsoft.com/en-us/library/Aa712982[^].

This CodeProject article can also be useful:
Essential P/Invoke[^].

An alternative approach is using C++/CLI. You can create a mixed-mode (managed+unmanaged) C++/CLI DLL. You can mix C++ with C++/CLI and wrap all native calls to your native DLL into .NET C++/CLI "ref" classes. The obtained executable can be used like a regular .NET assembly and referenced by your C# assembly.

About C++/CLI, please see:
http://en.wikipedia.org/wiki/C%2B%2B/CLI[^],
http://www.ecma-international.org/publications/standards/Ecma-372.htm[^],
http://msdn.microsoft.com/en-us/library/xey702bw.aspx[^].

—SA
 
Share this answer
 
v3
Comments
VJ Reddy 15-May-12 4:53am    
My 5!
Sergey Alexandrovich Kryukov 15-May-12 11:48am    
Thank you, VJ.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900