CB
Clay Burch
Syncfusion Team
May 28, 2002 06:17 AM UTC
Here is a Microsoft link explaining how to use P/Invoke with DLLImport to access functions in unmanaged DLLs.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconconsumingunmanageddllfunctions.asp
If you have a active X library (an OCX or ATL DLL)you are trying to use, then you can create the .NET wrapper class using the tool aximp.exe.
MM
Mukesh Motwani
June 4, 2002 06:36 AM UTC
I created an unmanaged DLL which has a C++ class.
PInvoke is able to access global exported DLL functions but it CANNOT import class methods from an unmanged DLL. Thus, I get an error "Object reference not set to an instance of an object" because I am not able to create an object of my class. In VC++ 6 I could use the header file and create an instance. But C# doesnt allow that. In fact,
[DllImport("mywin32.dll")]
public static extern Cwin32class();
is not compiled because the compiler thinks that method has no return type! But constructors are not supposed to have return types. Thus I cant find any way of using my unmanaged object oriented classes with the C# UI. Can anyone help me please?
Thanks
Mukesh
MI
Michael
May 17, 2003 12:10 AM UTC
Mukesh,
I have the same problem when I try to use a C++ DLL. Have you found out what the problem could be and how to instantiate the wrapper class or the object?
Regards.
Michael.
> I created an unmanaged DLL which has a C++ class.
> PInvoke is able to access global exported DLL functions but it CANNOT import class methods from an unmanged DLL. Thus, I get an error "Object reference not set to an instance of an object" because I am not able to create an object of my class. In VC++ 6 I could use the header file and create an instance. But C# doesnt allow that. In fact,
>
> [DllImport("mywin32.dll")]
> public static extern Cwin32class();
>
> is not compiled because the compiler thinks that method has no return type! But constructors are not supposed to have return types. Thus I cant find any way of using my unmanaged object oriented classes with the C# UI. Can anyone help me please?
>
> Thanks
> Mukesh