hello,
I've got a problem that can be more or less reliably reproduced.
I've got a com object described in a c++ written com library. There's
also an interop for this library. the object has two interfaces. as
long as use the default interface, everything works fine, but when I
cast to the other interface and try to execute methods on it, it
throws the error "QueryInterface failed for interface..."
example:
1 Strong.Name.InterfaceName i_variable = new
Strong.Name.InterfaceNameClass();
2 Strong.Name.AnotherInterfaceName i_anotherVariable =
(Strong.Name.AnotherInterfaceName)i_variable;
3 i_anotherVariable.someFunction();
The error happens either in line 2 or 3. On the same machine it works
just fine for a normal (windows forms desktop) application in C# but
fails in a windows service written also in C#. Declaring the function
where the code is or the portion of the code as STA does not help.
Does anybody know a cure?
Thank You
Konrad
Daniel Petersson, Cefalo - 31 Jan 2005 06:11 GMT
hi,
The STAThread attribute only applies to the main entry point
of the application, to set the apartmentmodel later use
set the Thread.ApartmentState property in your code.
// Daniel
> hello,
> I've got a problem that can be more or less reliably reproduced.
[quoted text clipped - 19 lines]
> Thank You
> Konrad