Link to home
Start Free TrialLog in
Avatar of emily_hall
emily_hall

asked on

Trying to make a C# DLL that can be accessed from C++

My problem is that when I call it from C++, the CoInitialize() call gives me the error "Class not recognized"

I did some looking around and found some stuff that said i needed to make a strong name?  So I did that using "sn -k myDLL.dll" and it said it was successful.   Where do I go from here?  If I look in WINNT\assembly I can see my library in a subfolder called Download.  It is marked as private...  Is that any help?  

Avatar of emily_hall
emily_hall

ASKER

Ok, I got it so that it is registered in the GAC and now I am not getting that Class not recognized error.  The problem now is that when I try to access a function in my DLL, I get a box in C++ that says:

---------------------------
Microsoft Visual C++
---------------------------
Unhandled exception in TestProgram2.exe: 0xC0000005: Access Violation.
---------------------------
OK  
---------------------------

Any ideas?
To generate a keypair using sn:
sn -k StrongNamedDll.snk

A file with name StrongNamedDll.snk will be created in the current folder.
In the source code file assemblyinfo.cs add the following line:

[assembly: AssemblyKeyFile("StrongNamedDll.snk")]

then compile the project and deploy it to GAC.

like I said in my comment - I got it registered so that I am not getting that class not recognized error but now I am getting:

---------------------------
Microsoft Visual C++
---------------------------
Unhandled exception in TestProgram2.exe: 0xC0000005: Access Violation.
---------------------------
OK  
---------------------------

When I try to call the funtion from C++.
ASKER CERTIFIED SOLUTION
Avatar of bluedaisydawg
bluedaisydawg

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial