Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / January 2005

Tip: Looking for answers? Try searching our database.

QueryInterface does not work for services, works for other applications.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Konrad Banys - 30 Jan 2005 13:01 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.