The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I have a class library written in C++ which I intend to use in a program whose interface is designed in C#. I understand that I need to create an unmanaged DLL and use the DLL in the program. Are there any resources which show how to create a unmanaged C++ DLL in .NET environment without using MFC and how I could use the DLL with C#? MSDN site suggests wrapping the unmanaged DLL function in a managed class but doesnt give any much useful information.
Thanks
Mukesh
CBClay 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.
MMMukesh MotwaniJune 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
MIMichael 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