How to call unmanaged Dll in C#
-
Hi I written a C++ unmanaged Dll. I tried to call the dll in C# Application. But I am unable to call the dll. Kindly note the following points 1) I have used the namespace using System.Runtime.InteropServices; 2) I have used the [DllImport("dll1.dll")] to import the the dll in C#. 3) I tried add the dll in C++ using the Add Reference method.Using this method I was unable to add the dll to the project. The dll is a Win32 Dynamic Dll. Can any one tell how to write a dll in C++ that used imported to C# application ? It is very urgent. Thanks Phijo Philip :)
-
Hi I written a C++ unmanaged Dll. I tried to call the dll in C# Application. But I am unable to call the dll. Kindly note the following points 1) I have used the namespace using System.Runtime.InteropServices; 2) I have used the [DllImport("dll1.dll")] to import the the dll in C#. 3) I tried add the dll in C++ using the Add Reference method.Using this method I was unable to add the dll to the project. The dll is a Win32 Dynamic Dll. Can any one tell how to write a dll in C++ that used imported to C# application ? It is very urgent. Thanks Phijo Philip :)
You need to pinvoke it, that is, you need to import the methods you want to call, not just the dll. www.pinvoke.net has examples of how to do this with Win32 API calls, the approach for your own calls would be identical.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Hi I written a C++ unmanaged Dll. I tried to call the dll in C# Application. But I am unable to call the dll. Kindly note the following points 1) I have used the namespace using System.Runtime.InteropServices; 2) I have used the [DllImport("dll1.dll")] to import the the dll in C#. 3) I tried add the dll in C++ using the Add Reference method.Using this method I was unable to add the dll to the project. The dll is a Win32 Dynamic Dll. Can any one tell how to write a dll in C++ that used imported to C# application ? It is very urgent. Thanks Phijo Philip :)