Groups | Blog | Home
all groups > dotnet interop > january 2005 >

dotnet interop : No such interface supported


Sachin
1/30/2005 10:31:03 PM
Hi,
I am using a COM component from ASP.NET and am getting "No such interface
supported" along with "InvalidCastException".

Can someone please give some pointers?

Jared Parsons [MSFT]
1/31/2005 10:58:55 AM
Chris Brumme has a great article that includes an explanation about why this
can happen when it seems like it shouldn't

http://blogs.msdn.com/cbrumme/archive/2004/02/02/66219.aspx

Look under the "No typelib Registered" section. The first 5 paragraphs deal
with an issue that may be causing the problem you're seeing.

--
Jared Parsons [MSFT]
jaredpar@online.microsoft.com
"This posting is provided "AS IS" with no warranties, and confers no rights"
[quoted text, click to view]

Ender699
2/8/2005 3:15:08 AM
Hello,

I had the same problems, and for me at least the problem was indeed related
to STA and MTA threading (I'm hosting the IE control inside a smart client to
update the page from which the smart client link was clicked). The problem
with using IEexec is that it always seems to use MTA, regardless of the
<STAThread()> attribute (try to read ApartmentState of the current thread,
you'll see its MTA). Setting the appartment state explicitly on the current
threa does NOT work either. Any COM I've used on an MTA thread seems to gives
the errors you describe: invalid cast and/or no such interface. Note that
some of the managed common dialogs suffer from the same problem
(fileOpenDialog hangs on navigating to 'My documents' when in an MTA thread,
see Chris Sells Wahoo game). The solution that seems to work for me is to
create a new thread and set it to STA BEFORE it is started ...

sub Main()
Dim oThread As New Threading.Thread(AddressOf STAMain)
oThread.ApartmentState = Threading.ApartmentState.STA
oThread.Start()
end sub

sub STAMain()
'Do something
end sub

Note that when you start a message pump for a form with
Application.Run(theForm)
it is again MTA, and you will need to restart seperate STA threads to
interop with COM objects ....

Not very practical, but it solved all my problems, except for one security
related one:

My assemblies are strong named, and given fulltrust by the .NET CLR. On some
machines this works fine, on others the smartclient seems to get fulltrust,
but fails to launch the thread or access the file system. Asserting works for
file IO, but for the permissions related to launching new threads. Basically
there seems to be a problem with some threads not getting the correct
security context from the parent thread. Any ideas?

Ender

AddThis Social Bookmark Button