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 / Component Services / January 2004

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jos? Ram?n Rodr?guez - 30 Dec 2003 19:59 GMT
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
enrico sabbadin @ infinito - 05 Jan 2004 01:11 GMT
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.

> Hello there,
>
[quoted text clipped - 16 lines]
>
> Jose R. Rodr?guez
Jos? Ram?n Rodr?guez - 05 Jan 2004 13:17 GMT
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.

> looks like tehre are some issues with type library registration / interop
> assembly ..
[quoted text clipped - 23 lines]
> >
> > Jose R. Rodr?guez
enrico sabbadin @ infinito - 06 Jan 2004 00:49 GMT
inline
> 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?

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)

> 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
[quoted text clipped - 3 lines]
>
> Thanks again for answering,

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

> Jose R.
>
[quoted text clipped - 26 lines]
> > >
> > > Jose R. Rodr?guez

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.