从共享驱动器运行C#的网络连接 [英] C# network connection running from shared drive

查看:81
本文介绍了从共享驱动器运行C#的网络连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在C#代码中弗朗阅读Web资源。不幸的是,代码是有效的,从本地驱动器运行,并抛出异常,只有当从网络共享运行(而这正是我需要的)时候。

I'm trying to read web resource fron within the C# code. Unfortunately the code is valid only when running from local drive and throws exception when running from network share (and that's what I need).

The underlying connection was closed: Unable to connect to the remote server.
   in System.Net.HttpWebRequest.GetResponse()
   .........
Caused by: 
An invalid argument was supplied
   in System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
   in System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
   in System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
   in System.Net.Connection.CompleteStartConnection(Boolean async, HttpWebRequest httpWebRequest)

我试过类似(这将引发除外)代码:

I've tried code similar to (this throws the exception):

request = (HttpWebRequest)WebRequest.Create(url);



以及根据的 http://msdn.microsoft.com/en-us/library/2b86d684

我怀疑有某种在Windows中避免网络连接的安全设置。是否有可能解决这个问题?通过Ad政策?什么在我的代码?

I have a suspicion there is some sort of security setting in Windows that prevents network connections. Is it possible to solve this? Via AD policy? Or something in my code?

推荐答案

您可以在这里开始的项目的位置不被信任对话框。报价:

You could start here The Project Location is Not Trusted Dialog Box. Quote:

默认情况下,UNC路径不是一个项目一个受信任的位置。您可以修改文件共享的安全策略,以防止此对话框出现。欲了解更多信息,请参见配置安全策略

By default, a UNC path is not a trusted location for a project. You can modify the security policy of the file share to prevent this dialog box from appearing. For more information, see Configuring Security Policy.

这篇关于从共享驱动器运行C#的网络连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆