July 9th, 2002, 02:51 PM
C++ COM to call .NET assembly
Hi all... A description of my problem follows and any help whatsoever would be greatly appreciated...
I have created a COM DLL in C++ which is registered and interfaces with Winlogon to receive events. This has been tested and works fine...
My next step was to try and create a .NET assembly in C#, which would have a single function in it, which would be called by the COM object mentioned before, each time an event occured. And this is where problems start...
I very quickly put this C# class together... nothing difficult there...
Following a few guides on the web about COM/.NET interop, I followed this procedure:
1)Compile the assembly with a strong name
2)gacutil -i Mydll.dll (Register it in assembly cache)
3)regasm /tlb:Mydll.tlb Mydll.dll (Register the assembly)
Which seemed to work just fine...
After I did this, I had to create a reference to this .NET assembly (which by now should be accessible by COM).
My first question is HOW DO I DO THIS?? in C++.... All the websites I have visited mention how you can do it from a VB or C# COM object and it is simple enough... BUT C++?? I have no clue...
What has been achieved is my .NET assembly DLL has appeared in the list of available COM objects in the add reference menu, which I tried by creating a VB test module (since this is as I mentioned the only envrnmnt where I know how to reference my assembly)... But when I try and do that, I get an error when I try to reference it which says:
*A reference to "Mydll" could not be added. Converting the type library to a .NET assembly failed. Type library Mydll was exported from a CLR assembly and cannot be reimported as a CLR assembly.*
This as I understand it means that the test module I have created in vb is not a COM module, so it cannot access my assembly through the COM access points I am trying to...
ANY help will be greatly appreciated since I am a bit of a newbie with a difficult task at hand... Thank you in advance,
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!