all groups > dotnet clr > june 2007 >
You're in the

dotnet clr

group:

Call .NET windows service methods from C++


Call .NET windows service methods from C++ Gert Unterhofer
6/20/2007 3:50:00 AM
dotnet clr: The windows service is ComVisible and has the ClassInterfaceType.AutoDual set.

Code:
<Assembly: ComVisible(True)>

<ComVisible(True)> _
<ClassInterface(ClassInterfaceType.AutoDual)> _
Public Class SEngine


The C++ Code that will call the service looks like:

#import "SEngine.tlb" no_namespace named_guids
....
_SEnginePtr pEngine( CLSID_SWFEngine );
pEngine->AddRef();


I reveived following errors:

ISitePtr Site;
__declspec(property(get=GetContainer))
IContainerPtr Container;
__declspec(property(get=GetEventLog))

error C2146: syntax error : missing ';' before identifier 'Site'
error C2146: syntax error : missing ';' before identifier 'Container'


When the C++ COM object call methods from an old C++ windows service in the
same way it works fine.
How must I define the vb.NET windows service to make the methods callable?

Re: Call .NET windows service methods from C++ Ben Voigt [C++ MVP]
6/20/2007 9:48:27 AM

"Gert Unterhofer" <GertUnterhofer@discussions.microsoft.com> wrote in
message news:0AC843C8-A756-440A-BCBD-71E057C0A178@microsoft.com...
[quoted text, click to view]

It doesn't know about ISitePtr and IContainerPtr. Open SEngine.tlb with
OleView and see what names .NET generated.

[quoted text, click to view]

Re: Call .NET windows service methods from C++ Gert Unterhofer
6/25/2007 4:51:01 AM
I found the solution.

#import "SEngine.tlb" auto_search no_namespace implementation_only
The auto_search Attribute imports the neccessary data.

Now I can compile the project, but in can't create the service object for
calling the method.

I received the error:
Unknown error 0x80131509
when I create an object from the service.

Is there an example or an 'How To' how the communication between windows
services in .Net and C++ or .Net works.

Thanks
AddThis Social Bookmark Button