all groups > dotnet interop > september 2006 >
You're in the

dotnet interop

group:

underlying connection was closed: unable to connect to the remote server: COM --> .Net --> WebService --> Error


underlying connection was closed: unable to connect to the remote server: COM --> .Net --> WebService --> Error Monty
9/27/2006 9:28:57 AM
dotnet interop:
OK, I had an issue with this and found lots of advice that did not apply, so
I'm posting what I found hoping it might help someone else. Here's the
sitch: you have a COM app that calls to a .Net assembly which in turn calls
a web service. You know the web service is reachable and that the COM app is
able to instantiate your .Net assembly (because you RegAsm'ed it and it's
good to go). However, when you attempt to make a call to the web service you
get the error message "underlying connection was closed: unable to connect
to the remote server". Chances are, you've had people telling you this is a
proxy issue even though you're pretty sure it's not. OK, here's what saved
me: simply add your assembly to the GAC. That's it. Even if you've RegAsm'ed
the heck outta your assembly and the COM object has no problems
instantiating it, I got this error every time it made a call to the
webservice until I added it to the GAC, then it worked like magic.

If anyone knows why this is, please chime in. Thanks.

Keywords: COM, ASMX, Web Service, Web Services, interop, REGASM, GACUTIL,
CCW, Register for COM, proxy, proxies, "underlying connection was closed:
unable to connect to the remote server"

Re: underlying connection was closed: unable to connect to the remote server: COM --> .Net --> WebService --> Error John Saunders
9/27/2006 5:10:11 PM
[quoted text, click to view]

I wonder if this is a trust issue.

John

Re: underlying connection was closed: unable to connect to the remote server: COM --> .Net --> WebService --> Error David Betz
9/27/2006 8:59:37 PM
I'm surprised you aren't getting threading errors... COM's not supposed
to do stuff like that.

Try switching everything to COM+ (Enterprise Services)... that ALWAYS
works for me. I just many applications via Enterprise Services.

[quoted text, click to view]
Re: underlying connection was closed: unable to connect to the remote server: COM --> .Net --> WebService --> Error stcheng NO[at]SPAM online.microsoft.com
9/28/2006 2:51:32 AM
Hello Monty,

Regarding on the problem you mentioned, based on my experience, it is
possibly caused by the following things:

** assembly loading, since when the .net assembly is not put in GAC, the
application CLR will try loading it from private assembly directory. For
your scenario, you call the .net through COM interop, then you need to make
sure the .net assembly is at your COM client app's private assembly folder.
You can use the "AppDomain.CurrentDomain.BaseDirectory" in your .net
component's code to get the current CLR appdomain's base directory(where
the runtime will try locating private dependency assemblies).

The following tool is useful for troubleshooting assembly loading and
binding issue:

#Assembly Binding Log Viewer (Fuslogvw.exe)
http://msdn2.microsoft.com/en-us/library/e74a18c4.aspx


**As John mentioned, since the problem differs when the assembly is
installed in GAC or not, it does be possible that there is some CAS
security related issue since the component in GAC is always evaluaetd as
FullTrust. For CAS test, you can use the "caspol.exe" tool to temporarily
turn off CAS and test with both scenarios(wrapper assembly in GAC or not )
to see whether it works.


#Code Access Security Policy Tool (Caspol.exe)
http://msdn2.microsoft.com/en-us/library/cb6t8dtz.aspx


In addition, all the above suggestion just based on some common scenarios.
We still can not make sure the exact problem in your wrapper component and
application. If possible, I would suggest you use some debugger to manually
attach to your application's process and locate the exact point the
exception get thrown. Visual Studio will be the preferred one if you've it
installed on the box.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
Re: underlying connection was closed: unable to connect to the remote server: COM --> .Net --> WebService --> Error Monty
9/28/2006 7:00:57 PM
Thanks Steve and John. I'm leaning towards John's explanation (Steven's
second explanation), since I don't think it's a matter of assembly loading
because I am able to load the assembly. It's only when I make a web service
call that I get the issue. If I get some time, I will try the caspol.exe.

Thanks fellas.

Re: underlying connection was closed: unable to connect to the remote server: COM --> .Net --> WebService --> Error stcheng NO[at]SPAM online.microsoft.com
9/30/2006 12:00:00 AM
Thanks for the followup Monty,

Hope you'll soon figure out the problem. If there is anything we can help
,please don't hesitate to post here.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button