Reputation: 777
I was trying to give vb.net dll reference to C++ Project. I was able to add the reference successfully but I am unable to use it in my code.
I have following reference:
I am trying to use it like:
Configuration::MyClass::MyFunction()
I got the following error:
error C2653: 'Configuration' : is not a class or namespace name
What am I doing wrong? Do I need to add a header file?
Upvotes: 4
Views: 744
Reputation: 2128
On the one hand, according to this answer, it might be just a Visual Studio failure.
On the other hand, the other answer suggests that it could be a dependency issue. Also, you may have the class with the same name defined twice in different libraries.
Anyway, consider re-checking all the dependencies and the Visual Studio setup.
Here is another answer regarding the topic.
UPD: Check if you are not trying to define a compound namespace, which is illegal in C++.
Upvotes: 0
Reputation: 50717
Make sure you have exposed assembly to the COM subsystem by it's 'ComVisible'
property. Then, you should register the assembly to expose it to COM 'subscribers'
.
Only then you can use the assembly namespace from your C++ code.
Check out How to call a managed DLL from native Visual C++ code for step-by-step guidelines.
Upvotes: 0
Reputation: 6849
Place this code at the top of the class
<ComVisible(True)> _
<Guid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")> _
<ClassInterface(ClassInterfaceType.None)> _
read this thread. I think this will help you. http://social.msdn.microsoft.com/Forums/en-US/3f30b414-2ea3-4a54-b4cb-24e48fdfda3e/calling-vbnet-dll-from-c?forum=vbgeneral
Upvotes: 2