Solved

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

Posted on 2003-11-06
4
274 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now