I'm creating a windows service on a windows 2003 machine, using dsofile to modify custom properties on a bunch of documents. This works fine until I install the service on a win2k8 machine where it gives me the following error:
ERROR [2010-09-06 13:17:12,317] An
unknown error occured:
System.InvalidCastException: Unable to
cast COM object of type
'DSOFile.OleDocumentPropertiesClass'
to interface type
'DSOFile._OleDocumentProperties'. This
operation failed because the
QueryInterface call on the COM
component for the interface with IID
'{58968145-CF01-4341-995F-2EE093F6ABA3}'
failed due to the following error:
Error loading type library/DLL.
(Exception from HRESULT: 0x80029C4A
(TYPE_E_CANTLOADLIBRARY)).
All my projects are set to run as x86, and Ive used procmon to monitor the files requested without any clues.. Anyone have any ideas on how to solve this?
Since you have mentioned that you are running a service under Win2008,
- The first clue is, is the DSO File dll component part of Office, what version? is that installed?
- I am not sure if a service can access such a office component running as a system account user which could be open to malicious exploits whilst running under said account as a service...
- TYPE_E_CANTLOADLIBRARY should be as a result of the first option given...
I had a similar problem and I solved it due to the explanation by Geoff Darst - MSFT.
I adjusted his original answer to fit your interface IID:
Sounds like you have a problem with your typelib registration.
Presumably, the Com interop layer is hitting the registry to try to
locate the typelib. It would start by looking under
HKCR\Interface{58968145-CF01-4341-995F-2EE093F6ABA3}\Typelib. The
default value should refer to the guid for the typelib that defines
the interface in question: which should be located under the following
key: HKCR\Typelib{what found in the aforementioned Interface key}.
There should be a version subkey and then a 0 subkey, and a win32
subkey under that. The default value of the win32 key should point to
the right typelib.