all groups > dotnet component services > december 2003 >
You're in the

dotnet component services

group:

Connection to remote COM object works in Windows Forms application but not in ASP.NET application


Connection to remote COM object works in Windows Forms application but not in ASP.NET application José Ramón Rodríguez
12/30/2003 2:59:33 PM
dotnet component services: Hello there,

The following code causes "Specified cast is not valid" exception when line
3
executes inside an ASP.NET application. I have tried this with several
components. Exactly the same code works if
connecting locally (i.e with localhost) and it always works from a Windows
Forms application even if connecting to another computer.

Here is the code:

Type type = Type.GetTypeFromProgID("CorporaServer.CorporaAppServer",
"RemoteServer");
Object objTest = Activator.CreateInstance(type);
CorporaAppServer CorporaServerObj = (CorporaAppServer)objTest; // exception
"Specified cast is not valid" raised here

Anybody knows why this could happen? Thanks in advance,

Jose R. Rodríguez



Re: Connection to remote COM object works in Windows Forms application but not in ASP.NET application enrico sabbadin NO[at]SPAM infinito
1/5/2004 2:11:16 AM
looks like tehre are some issues with type library registration / interop
assembly ..
In windows forms it works likely because there is no marshaling taking
place.


[quoted text, click to view]

Re: Connection to remote COM object works in Windows Forms application but not in ASP.NET application José Ramón Rodríguez
1/5/2004 8:17:29 AM
Hello Enrico, thanks for answering. My Windows forms application is a .NET
application also so I figure it would be doing the same marshalling that is
done when using COM objects from an ASP.NET application, it's all .NET
right?

I later tested with a Web application in my little network at home and it
worked well, I figure it must be just some configuration problem either in
the COM+ application or in the ASP.NET application. My network at home has
no domain controller and the settings of the COM+ application were
different, I'll try this this morning at work.

Thanks again for answering,

Jose R.

[quoted text, click to view]

Re: Connection to remote COM object works in Windows Forms application but not in ASP.NET application enrico sabbadin NO[at]SPAM infinito
1/6/2004 1:49:49 AM
inline
[quoted text, click to view]

nope .. the windows form .NET thread is an STA thread so there is no
marshaling when calling the STA com component (i guesses it's an sta)

[quoted text, click to view]

I suggest you to test the caller and callee thread id to know when
marshaling is taking place or not


[quoted text, click to view]

AddThis Social Bookmark Button