2

Possible Duplicate:
How to use c# Dll in vc++?

I have created a class in the c sharp and made the DLL of the class now i want to use the methods in the DLL file in my VC++ project.

I know how to add the .lib file in VC++ project but how to add a DLL file in VC++ project I don't know.

I want to create the object of the class that i defined in the DLL in my VC++ project and through the object i want to access its methods.

When I tried this and I got following error:

support.microsoft.com/kb/828736 error "referenced assembly entlibcontrib.data.mysql does not have strong name"

Please guide me through this.

Community
  • 1
  • 1
Ajinkya
  • 1,701
  • 4
  • 25
  • 42
  • 1
    Possible duplicate of http://stackoverflow.com/q/980808/796036 – Christian Ivicevic Oct 05 '12 at 11:31
  • 4
    _"Please guide me through this."_ - done any research? What have you found? – CodeCaster Oct 05 '12 at 11:34
  • 1
    @CodeCaster i tryed this and i got this http://support.microsoft.com/kb/828736 error "referenced assembly entlibcontrib.data.mysql does not have strong name" – Ajinkya Oct 05 '12 at 13:56
  • @Ajinkya then mention that in your question. Or even better, download the enterprise library that has strong-named assemblies or [do so yourself](http://stackoverflow.com/questions/659408/enterprise-library-strong-naming-guidance-package). – CodeCaster Oct 05 '12 at 13:59
  • @CodeCaster i went to http://support.microsoft.com/kb/828736 i did this C:\Documents and Settings\Administrator\Desktop\NiproDAAB\IISWebFrameworkDAAB\bi n\Release>RegAsm.exe IISWebFrameworkDAAB.dll Microsoft (R) .NET Framework Assembly Registration Utility 4.0.30319.1 Copyright (C) Microsoft Corporation 1998-2004. All rights reserved. Types registered successfully but there is no .tlb file as said under the heading "Call the Managed DLL from Native C++ Code" under "7"point – Ajinkya Oct 05 '12 at 15:22

2 Answers2

2

Keep in mind to make the DLL visible to COM and follow this guide. For the visibility you can either change the AssemblyInfo.cs and add [assembly: ComVisible(true)] or via the integrated property editor of Visual Studio.

Christian Ivicevic
  • 10,071
  • 7
  • 39
  • 74
  • @Christianlvicevic Sir i did what is given in above link but when i did RegAsm.exe My.dll under the heading "Register the Managed DLL for Use with COM or with Native C++" i get "RegAsm : warning RA0000 : No types were registered" – Ajinkya Oct 05 '12 at 14:55
  • 1
    Sir i got the "Types registered successfully" but there is no .tlb file as said under the heading "Call the Managed DLL from Native C++ Code" under "7"point – Ajinkya Oct 05 '12 at 15:07
  • C:\Documents and Settings\Administrator\Desktop\NiproDAAB\IISWebFrameworkDAAB\bi n\Release>RegAsm.exe IISWebFrameworkDAAB.dll Microsoft (R) .NET Framework Assembly Registration Utility 4.0.30319.1 Copyright (C) Microsoft Corporation 1998-2004. All rights reserved. Types registered successfully – Ajinkya Oct 05 '12 at 15:12
0

your c# dll need to be ComVisible attribute

[assembly: ComVisible(true)]

For more info see here

If you are non-managed, C++ project then you must use COM interop to access the assembly. After which you can access it like any other COM component

jiten
  • 5,128
  • 4
  • 44
  • 73
  • Sir i did what is given in above link but when i did RegAsm.exe My.dll under the heading "Register the Managed DLL for Use with COM or with Native C++" i get "RegAsm : warning RA0000 : No types were registered" – Ajinkya Oct 05 '12 at 14:56
  • Sir i got the "Types registered successfully" but there is no .tlb file as said under the heading "Call the Managed DLL from Native C++ Code" under "7"point – Ajinkya Oct 05 '12 at 15:07
  • 1
    i did this C:\Documents and Settings\Administrator\Desktop\NiproDAAB\IISWebFrameworkDAAB\bi n\Release>RegAsm.exe IISWebFrameworkDAAB.dll Microsoft (R) .NET Framework Assembly Registration Utility 4.0.30319.1 Copyright (C) Microsoft Corporation 1998-2004. All rights reserved. Types registered successfully – Ajinkya Oct 05 '12 at 15:13