最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】C#编译出来的程序运行出错:System.Configuration.ConfigurationErrorsException: Error creating the Web Proxy specified in the ‘system.new/defaultProxy’ configuration section.

C# crifan 5555浏览 0评论

【问题】

一个C#编译出来的exe程序,该exe是单独的exe,无额外的配置文件等东西。

exe放到一个Win7下的共享盘里面,然后在另外一台电脑上,访问该exe,直接运行,出错:

Error creating the Web Proxy specified in the ‘system.new/defaultProxy’ configuration section

错误截图:

Error creating the Web Proxy specified in the xxx configuration section

错误log:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Configuration.ConfigurationErrorsException: Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section. ---> System.Net.Sockets.SocketException: An invalid argument was supplied
   at System.Net.SafeCloseSocketAndEvent.CreateWSASocketWithEvent(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, Boolean autoReset, Boolean signaled)
   at System.Net.NetworkAddressChangePolled..ctor()
   at System.Net.AutoWebProxyScriptEngine.AutoDetector.Initialize()
   at System.Net.AutoWebProxyScriptEngine.AutoDetector.get_CurrentAutoDetector()
   at System.Net.AutoWebProxyScriptEngine..ctor(WebProxy proxy, Boolean useRegistry)
   at System.Net.WebProxy.UnsafeUpdateFromRegistry()
   at System.Net.WebProxy..ctor(Boolean enableAutoproxy)
   at System.Net.Configuration.DefaultProxySectionInternal..ctor(DefaultProxySection section)
   at System.Net.Configuration.DefaultProxySectionInternal.GetSection()
   --- End of inner exception stack trace ---
   at System.Net.Configuration.DefaultProxySectionInternal.GetSection()
   at System.Net.WebRequest.get_InternalDefaultWebProxy()
   at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint)
   at System.Net.HttpRequestCreator.Create(Uri Uri)
   at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
   at System.Net.WebRequest.Create(String requestUriString)
   at crifanLib.getUrlResponse(String url, Dictionary`2 headerDict, Dictionary`2 postDict, Int32 timeout, String postDataStr)
   at crifanLib.getUrlRespHtml(String url, Dictionary`2 headerDict, String charset, Dictionary`2 postDict, Int32 timeout, String postDataStr)
   at crifanLib.getUrlRespHtml(String url, String charset, Int32 timeout)
   at crifanLib.getUrlRespHtml(String url, String charset)
   at downloadSongtasteMusic.songtaste.getSongInfo(String idOrUrl, songInfo& songInfo, String& errStr)
   at downloadSongtasteMusic.frmDownloadSongtasteMusic.downloadSingleStMusic(String idOrUrl, String dirToSave)
   at downloadSongtasteMusic.frmDownloadSongtasteMusic.downloadStMusicFromUrl()
   at downloadSongtasteMusic.frmDownloadSongtasteMusic.doDownload()
   at downloadSongtasteMusic.frmDownloadSongtasteMusic.btnDownload_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
downloadSongtasteMusic
    Assembly Version: 1.0.0.0
    Win32 Version: 1.4.0.0
    CodeBase: file:///T:/CLi/st/downloadSongtasteMusic.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5460 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5462 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

 

现在想要找到出错的根本原因。

 

【解决过程】

1.后来经过验证,当把此exe,从(网上邻居中的)共享盘,拷贝到当前硬盘中,再运行就正常了,就没了错误了。

2.后来又经过测试,直接通过我本机的win7下,访问该网盘上的该exe,直接运行该exe,则是正常的,也不会出现这个错误。

3.但是还是想要去多了解此错误,想要搞懂为何会出现此错误。

4. 网上这人:

error creating the web proxy specified in the ‘system.net/defaultproxy’ configuration section

遇到和我类似的情况,也是网络上运行程序出错,本地运行是正常的。

5.这里:

Error creating the web proxy specified in the ‘system.net/defaultproxy’ configuration section

是通过“netsh winsock reset”然后重启解决问题的。

 

【总结】

懒得继续找根据原因了。总之是:

将exe从网络共享中,拷贝到本地,就是可以正常运行的了。

转载请注明:在路上 » 【已解决】C#编译出来的程序运行出错:System.Configuration.ConfigurationErrorsException: Error creating the Web Proxy specified in the ‘system.new/defaultProxy’ configuration section.

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.154 seconds, using 22.21MB memory