I have a .NET Windows service which self hosts a WCF service. This WCF service then goes on to call an old COM component written in ATL on Visual Studio 6. This COM component then creates a Excel.Application COM component. It calls various methods on this Excel COM component and then calls SaveAs on it to finish saving the document. This SaveAs method call fails. The Windows service is running as Local System so I thought it must be some permission problem. So I changed the windows service so that it ran under my user account (just go into servic开发者_开发技巧es.msc, stop the service, properties, change log on, and restart the service). However, the same problem persists.
I create a quick .NET Win Forms test app and then run the COM component from there. This works fine. The app is running under my user account so I would have thought running the windows service under my account would have the same effect.
What is the problem with the windows service (even when it is running under my user account)? And how do I solve this?
Since Vista Windows Service are not allowed to do "Desktop things" (security etc.)... additionally Office automation is NOT supported by MS in this scenario...
You could find some way to circumvent all this BUT I would strongly recommend to take another route - for Office files there is a free SDK from MS you can use called OpenXML SDK 2.0 - you can download it here.
IF the features are not enough there are other free and commercial SDKs out there - to recommend something it would help to know more about your requirements.
精彩评论