My development tool is VS2010, development language is C#, and operating system is WINDOWS7 64-bit. I need to call interface functions of COM service (OPC DA Automation Wrapper 2.02) in my windows service application, while the COM service and windows service are on the same computer. It turns out that calling some of the COM interface functions successes, but some have errors(System.Runtime.InteropServices.COMException was caught).
errors is:
System.Runtime.InteropServices.COMException was caught
Message=Exception from HRESULT: 0xC0040007
Source=GWOPC.NET
ErrorCode=-1073479673
I created a normal application(not a windows service program) to call the COM service, there was no problem. So I think the problem is due to using of windows service, and I suspect are some permission setting problem of windows service. Then I tried these steps:
1. I log in my computer using an administrator account.
2. In the windows service properties -> Log On tab, select "Local System account" by default.
3. Run my windows service application to call COM interface functions, error exists.
4. In the windows service properties -> Log On tab, select "This Account" and enter a user name and password (the user is an administrator).
5. Run my windows service application to call COM interface functions, the error still exists.
Same code, the general application(e.g. EXE) call, there will be no errors. Only in the service call, will have errors.