1
votes

I created a vb.net dll called "WSdll.dll". I compiled it, created a type library (tlb), and registered it globally(gacutil).. It includes a file called wsutils.vb, which includes a namespace called "wsutils". In the namespace, there's an interface (with attribute) called "IWSconnection", and a class called "WSconnection". The interface and class are public, as are all methods and properties.

I then tried to implement it in an unmanaged c++ project.

I imported it: #import "..\WSdll\WSdll\bin\Debug\WSdll.tlb" \ raw_interfaces_only, \ named_guids, \ no_namespace

Then tried to create an instance: CComPtr< IWSconnection > pIWSconnection; pIWSconnection.CoCreateInstance( __uuidof( wsutils::WSconnection ) );

I am getting 2 errors a)wsutils is not a class or namespace name b)wsconnection undeclared identifier

What other steps do i have to do to get the dll working here?

TIA

2

2 Answers

1
votes

You put no_namespace in the #import line - so your object is not in the wsutils namespace, it's in the global namespace. Remove either the no_namespace from the #import line, or the wsutils:: from the object creation line.

1
votes

Namespace names used in your VB.NET code are not visible to a COM client. Just omit the wsutils:: prefix. Whenever you are in doubt what the #imported names look like, open the automatically generated .tlh and .tli files with your editor.