简体   繁体   中英

How to use ATl COM from a windows service

Using the VS2008 wizard, I have created a Service (That does nothing currently other than Start and Stop)

I wish to use an (out of process) COM object

If I add a #import "object.tlb", then recompilation gives

error C2812: #import is not supported with /clr:pure and /clr:safë

Changing properties to use /clr (not pure or safe), allows compilation, but install of the service fails with "Ättempt to load an unverifiable executable with fixups"

Any advice appreciated

Peter

It is explicitly mentioned in the MSDN article for InstallUtil.exe:

Note that you cannot deploy a Windows service created using C++ with Installutil.exe. Installutil.exe cannot recognize the embedded native code that is produced by the C++ compiler. If you attempt to deploy a C++ Windows service with Installutil.exe, an exception such as BadImageFormatException will be thrown. To work with this scenario, move the service code to a C++ module. Then, write the installer object in C# or Visual Basic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM