Hi All,
I have a library(.dll). It's develop by VC++ 6.0. I would like to know
how C# can used my library? When I add reference at C# project it will show
my dll is not a valid assembly or COM component. How I fix this problem. I
don't want rewrite my dll because it's very big project.
Inside my dll everything is class. I think I can't use DllImport.
I try to used tlbimp by type this command
tlbimp MyDll.dll \out:MyDllImport.dll
I got this error.
TlbImp error : The input file "MyDll.dll" is not a valid type
library.
But I can use this dll by VC++ 6.0.
Best Regards,
Siripong W.
gyurisc - 23 Mar 2005 20:49 GMT
Hello,
one option is to use pinvoke this can be used to call native functions from
managed dlls
check out this article to learn about it more
http://msdn.microsoft.com/msdnmag/issues/03/07/NET/
http://msdn.microsoft.com/msdnmag/issues/04/10/net/default.aspx
the problem with p/invoke that you can call only functions but cannot use
classes from the dll. The other option would be to recompile your code under
.NET.
Cris
> Hi All,
> I have a library(.dll). It's develop by VC++ 6.0. I would like to
[quoted text clipped - 19 lines]
> Best Regards,
> Siripong W.
jesbeer - 28 Mar 2005 07:20 GMT
Hi,
There are two options for this.
1. This is a kind of extending the C++ dll. Identify the
functionalities you want to get done by the C++ dll. Wrap them
into additional exported functions in the C++ dll. Keep in mind
that the new functions should only recieve arguments which are of
primitive types or structures which has only premitive members.
This applies to the return types as well. These new functions are
the ones which you might use in your C# code. Redefine these
functions in C# using DllImport attribute and use them.
2. Convert the C++ dll into a COM project. Reference the output
COM dll in your C# project. This way you can directly use the
types (classes) defined within your COM dll.
Jesbeer
== Quote from modx (modxchat@hotmail.com)'s article
> Hi All,
> I have a library(.dll). It's develop by VC++ 6.0. I would like to know
[quoted text clipped - 10 lines]
> Best Regards,
> Siripong W.