I have C# COM dll and want to use it in a C++ MFC program. My operating system is Windows 7 (64 bits) and Visual Studio 2008.
I did the below steps:
1. create a strong name: sn -k TestKeyPair.snk and added it into the AssemblyInfo.cs file for this C# dll.
2. regasm this dll /tlb a.tlb
3. gacutil /i this dll
Then I asked this C++ MFC program to use this a.tlb. But I got the error at the line of CreateInstance, which called CoCreateInstance: 0x80040154 Class not registered.
But I created a Win32 Console Project in VS 2008, and then copied the corresponding code into this Console program and used this same a.tlb file, and CreateInstance got the "S_OK".
I also unregistered this dll. I verified the "unregistered" by this console project. Then I re-registered it, and the console project worked, but the above C++ MFC program still got this error.
I tried to build this C# dll by x86, x64, win32 and Any CPU, and the result is the same.
Any ideas about what I can further do on this MFC program or anything else?
Thanks a lot.
viernes, 18 de marzo de 2011 16:58
Todas las respuestas
What is the target platform of your C# dll?
Is the MFC app 32bit or 64bit?
Is regasm the 32bit or 64bit version?
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVPviernes, 25 de marzo de 2011 0:52
Thanks for reply. I got the answer to it. The reason is the main component. Sorry for so late reply here.
But it is strange. I check the "Alert me when someone responds to this post", however, I did not get the email to notify me when your guys replied. Anything is wrong? Thanks.miércoles, 30 de marzo de 2011 0:55