Solved

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

Posted on 2003-11-06
4
276 Views
Last Modified: 2010-04-16
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?  

0
Comment
Question by:emily_hall
  • 2
4 Comments
 
LVL 1

Author Comment

by:emily_hall
ID: 9695888
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?
0
 

Expert Comment

by:paulgao
ID: 9696587
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.

0
 
LVL 1

Author Comment

by:emily_hall
ID: 9696940
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++.
0
 
LVL 1

Accepted Solution

by:
bluedaisydawg earned 190 total points
ID: 9819291
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question