我已经为所工作的公司制作了Windows Forms应用程序。 在我自己的笔记本电脑和PC上,该程序可以正常运行,但是当我尝试在公司的计算机上安装该程序时,出现了很大的错误。
我使用.NET Framework 4.6.1创建了程序,而我工作的公司PC上的当前Framework是4.0版。由于版本的差异,我遇到了一些错误。我已经解决了所有错误,除了一个...
我想从Web服务器(000webhost服务器)上的本地存储数据进行备份。同样,所有这些在我自己的笔记本电脑上都可以正常工作,即使我在公司的WIFI上连接,在我自己的计算机上也可以正常工作。但是在公司的PC上,一切都变了。.当尝试进行备份时,我总是遇到异常。
我已经在Google上搜索了任何解决方案,但不幸的是没有运气。只有一个结果告诉我有关此异常的任何信息,该家伙写道HttpClient对象应该是静态的,我不应该使用using()子句。
我当前的代码:
private static HttpClient client;
public Parser(Form1 form)
{
client = new HttpClient();
}
private async Task<int> backup()
{
try
{
var data = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("license", license),
new KeyValuePair<string, string>("json", text),
new KeyValuePair<string, string>("date", DateTime.Today.ToString("dd/MM/yyyy"))
});
var response = await client.PostAsync(URL + "makebackup.php", data);
string content = await response.Content.ReadAsStringAsync();
Response result = JsonConvert.DeserializeObject<Response>(content);
return result.result;
}
catch (HttpRequestException)
{
form.showMessageBox("Kon geen backup maken door het ontbreken van een internet verbinding");
}
return -1;
}
public async Task<CheckVersionResult> checkVersion()
{
try
{
var data = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("version", form.mrtVersion)
});
var response = await client.PostAsync(URL + "checkversion.php", data);
string content = await response.Content.ReadAsStringAsync();
CheckVersionResult result = JsonConvert.DeserializeObject<CheckVersionResult>(content);
return result;
}
catch (HttpRequestException)
{
form.showMessageBox("Je hebt een internetverbinding nodig om dit programma te kunnen gebruiken");
return null;
}
}
不幸的是,错误消息是用荷兰语编写的,所以你们大多数人都无法阅读完整的错误消息。 最重要的一行可能是stacktrace的第一行,它的英文翻译是:“ SocketException(0x80004005):提供了无效的参数”。
错误消息
Zie het einde van dit bericht voor meer informatie over het aanroepen
van JIT-foutopsporing (Just In Time) in plaats van dit dialoogvenster.
************** Tekst van uitzondering **************
System.Net.Sockets.SocketException (0x80004005): Er is een ongeldig argument opgegeven
bij System.Net.SafeCloseSocketAndEvent.CreateWSASocketWithEvent(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, Boolean autoReset, Boolean signaled)
bij System.Net.NetworkAddressChangePolled..ctor()
bij System.Net.AutoWebProxyScriptEngine.AutoDetector.Initialize()
bij System.Net.AutoWebProxyScriptEngine.AutoDetector.get_CurrentAutoDetector()
bij System.Net.AutoWebProxyScriptEngine..ctor(WebProxy proxy, Boolean useRegistry)
bij System.Net.WebProxy.UnsafeUpdateFromRegistry()
bij System.Net.Configuration.DefaultProxySectionInternal..ctor(DefaultProxySection section)
bij System.Net.Configuration.DefaultProxySectionInternal.GetSection()
************** Geladen assembly's **************
mscorlib
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2117.0 built by: NET47REL1LAST
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
MRT
Assembly-versie: 1.0.0.0
Win32-versie: 1.0.0.0
CodeBase: file:///O:/DKW/MRT%20(Medewerkers%20Resultaten%20Tool)/release%202/MRT.exe
----------------------------------------
System.Windows.Forms
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2114.0 built by: NET47REL1LAST
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2114.0 built by: NET47REL1LAST
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2053.0 built by: NET47REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2053.0 built by: NET47REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2117.0 built by: NET47REL1LAST
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2102.0 built by: NET47REL1LAST
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Windows.Forms.DataVisualization
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2053.0
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.DataVisualization/v4.0_4.0.0.0__31bf3856ad364e35/System.Windows.Forms.DataVisualization.dll
----------------------------------------
CircularProgressBar
Assembly-versie: 2.5.6403.13419
Win32-versie: 2.5
CodeBase: file:///O:/DKW/MRT%20(Medewerkers%20Resultaten%20Tool)/release%202/CircularProgressBar.DLL
----------------------------------------
WinFormAnimation
Assembly-versie: 1.5.6298.3372
Win32-versie: 1.5
CodeBase: file:///O:/DKW/MRT%20(Medewerkers%20Resultaten%20Tool)/release%202/WinFormAnimation.DLL
----------------------------------------
System.Windows.Forms.DataVisualization.resources
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2053.0
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.DataVisualization.resources/v4.0_4.0.0.0_nl_31bf3856ad364e35/System.Windows.Forms.DataVisualization.resources.dll
----------------------------------------
System.Net.Http
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2053.0 built by: NET47REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Net.Http/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Net.Http.dll
----------------------------------------
Newtonsoft.Json
Assembly-versie: 11.0.0.0
Win32-versie: 11.0.2.21924
CodeBase: file:///O:/DKW/MRT%20(Medewerkers%20Resultaten%20Tool)/release%202/Newtonsoft.Json.DLL
----------------------------------------
System.Numerics
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2053.0 built by: NET47REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
System.Runtime.Serialization
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2106.0 built by: NET47REL1LAST
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Serialization/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll
----------------------------------------
System.Data
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2102.0 built by: NET47REL1LAST
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.resources
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2053.0 built by: NET47REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.resources/v4.0_4.0.0.0_nl_b77a5c561934e089/System.resources.dll
----------------------------------------
mscorlib.resources
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2053.0 built by: NET47REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_nl_b77a5c561934e089/mscorlib.resources.dll
----------------------------------------
System.Windows.Forms.resources
Assembly-versie: 4.0.0.0
Win32-versie: 4.7.2053.0 built by: NET47REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_nl_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------
************** JIT-foutopsporing **************
Als u JIT-foutopsporing wilt inschakelen, moet in het configuratiebestand voor deze
toepassing of computer (machine.config) de waarde
jitDebugging in het gedeelte system.windows.forms zijn ingesteld.
De toepassing moet ook zijn gecompileerd terwijl foutopsporing
was ingeschakeld.
Bijvoorbeeld:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
Wanneer JIT-foutopsporing is ingeschakeld, worden onverwerkte uitzonderingen
naar het JIT-foutopsporingsprogramma gestuurd dat op de computer is geregistreerd
en worden niet door dit dialoogvenster verwerkt.
该公司的PC正在运行由NET47REL1LAST构建的Windows 32位版本4.7.2117.0。所有功能都被管理员阻止,因此我无法检查有关系统信息的任何内容,而且很遗憾,我也无法在此计算机上安装任何内容...我的猜测是,问题与该问题有关.NET Framework版本,但我可能错了...
任何帮助将不胜感激! 提前致谢! Joeri。
答案 0 :(得分:1)
.Net 4.0不支持异步等待升级到4.5或更高版本,并且可以正常工作。我相信您的本地PC在更高版本的.net上运行,这就是为什么该应用程序在您的个人PC上运行没有任何问题的原因