By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

C# Interop with Remote COM Object

P: n/a
I'm having trouble connecting to a remote COM object using Reflection. I've
got a Web Form using C# that needs to connect to a COM object on a remote
server. The snippet of code that follows is what I've got (and found through
all of my research as the necessary code):

Type remoteType = Type.GetTypeFromProgID(r2wprogid, r2wserver) ;
object remoteObject = Activator.CreateInstance(remoteType, true) ;

The call to the Activator.CreateInstance continually causes an exception
stating that the remote server is unavailable. However, if I run the
associated code in my old 'standard ASP' page, there is no problem connecting
and performing my function calls.

Can anyone see something specific that I'm missing that would cause my Web
Form to be unable to connect to the remote server? Any ideas and suggestions
would be appreciated.
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Bryan,

By default, ASP.NET runs under the ASPNET local account, which doesn't
have access to the network. Since you are trying to access an object over
the network, it is most likely that it is failing here.

What you need to do is run the page under a user account which can
access the object on the network. You can do this through impersonation
(using the WindowsImpersonationContext class), or by setting the identity
tag in the web.config file appropriately.

To verify this is the issue, create a windows forms application, and try
making the same call. If it succeeds, then the solution above should work.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bryan Tubbs" <Br********@discussions.microsoft.com> wrote in message
news:99**********************************@microsof t.com...
I'm having trouble connecting to a remote COM object using Reflection.
I've
got a Web Form using C# that needs to connect to a COM object on a remote
server. The snippet of code that follows is what I've got (and found
through
all of my research as the necessary code):

Type remoteType = Type.GetTypeFromProgID(r2wprogid, r2wserver) ;
object remoteObject = Activator.CreateInstance(remoteType, true) ;

The call to the Activator.CreateInstance continually causes an exception
stating that the remote server is unavailable. However, if I run the
associated code in my old 'standard ASP' page, there is no problem
connecting
and performing my function calls.

Can anyone see something specific that I'm missing that would cause my Web
Form to be unable to connect to the remote server? Any ideas and
suggestions
would be appreciated.

Nov 17 '05 #2

P: n/a
Nicholas,

Thanks for your post and suggestion. Unfortunately, I have the identity tag
in the web.config file set to impersonate. I did, however, try your
suggestion of creating a Windows app to see if I could get the COM object to
instantiate successfully and was unable to get that to work either.

Any other suggestions?

Thanks,
Bryan Tubbs
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.