Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / March 2005

Tip: Looking for answers? Try searching our database.

How I use VC++ dll by C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
modx - 23 Mar 2005 19:12 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.