?
Solved

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

Posted on 2003-11-06
4
Medium Priority
?
284 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 570 total points
ID: 9819291
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

831 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