?
Solved

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

Posted on 2003-11-06
4
Medium Priority
?
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

777 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