Please Help - Importing and using a DLL?
Hi,
I have no idea on where to even get started here.
Basically I have a DLL written in C#, I want to be able to use that in my VC++ 2005 project.
How can I do this?
I'm guessing #import "<name>/dll", which compiles, but then how can I use the class contained within?
Thanks
Re: Please Help - Importing and using a DLL?
What kind of DLL is it? COM?
Re: Please Help - Importing and using a DLL?
Well, I have the c# source project. I have set it up to build a COM dll.
It seemed to work fine. Now I am trying to use it in my project.
It compiles fine (using functionality from the DLL no problem). Then when I run I get the following error:
Code:
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in AutoInspectorX+.exe
Additional information: Could not load file or assembly '<dllname>, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
So I read around a bit and it seems I have to do some registration of the dll (it's my first time doing this ! :) ).
So I tried : regsrv32 <dllname>.dll
I then get the following error :
Code:
<dllname>.dll was loaded but the DllRegisterServer entry point was not found.
The file can not be registered.
And now I'm stuck!
Please help :(
Re: Please Help - Importing and using a DLL?
It sounds like it's not really a COM DLL. Does your DLL have the 'DllRegisterServer' exported?
Viggy
Re: Please Help - Importing and using a DLL?
Not sure. How do I find that out? :)
Re: Please Help - Importing and using a DLL?
The function should be in the source code for the DLL. Along with a function called 'DllUnregisterServer' (or something like that).
All COM DLL's have these funcitons. They're used to register (and unregister) the COM object. THey also allow you to do some customization during initializing.
Viggy
Re: Please Help - Importing and using a DLL?
A find in all files of the source showed nothing like you say.
What can I do to use this?
Can I convert to a COM dll or use it as a "normal" dll?
Re: Please Help - Importing and using a DLL?
I just re-read your initial post, and the DLL is written in C#? I'm not sure how to work with that, as I've never used C#. Perhaps someone else will have a suggestion...
Sorry!
Viggy
Re: Please Help - Importing and using a DLL?
At first,check your c# dll can work on COM.
Next,You must output tlb file from your c# dll by excuting regasm.exe command(you can find it in .NET Framework's SDK).
Finally,import the yourdll.tlb in your c++ project .