'System.InvalidProgramException' 在 PC 上发生在 RestSharp.dll,在笔记本电脑上工作正常
'System.InvalidProgramException' occurred in RestSharp.dll on PC, on Laptop works fine
所以我有 2 个项目的解决方案。我将整个解决方案从我的笔记本电脑转移到我的电脑上,但我的电脑出现了这个错误:
System.InvalidProgramException was unhandled HResult=-2146233030
Message=JIT Compiler encountered an internal limitation.
Source=RestSharp StackTrace:
at RestSharp.Deserializers.XmlDeserializer.GetElementByName(XElement
root, XName name)
at RestSharp.Deserializers.XmlDeserializer.GetValueFromXml(XElement root,
XName name, PropertyInfo prop)
at RestSharp.Deserializers.XmlAttributeDeserializer.GetValueFromXml(XElement
root, XName name, PropertyInfo prop)
at RestSharp.Deserializers.XmlDeserializer.Map(Object x, XElement root)
at RestSharp.Deserializers.XmlDeserializer.Deserialize[T](IRestResponse
response)
at WolframAlphaNET.WolframAlpha.GetResponse[T](RestRequest request) in
i:\VS_Projects_Shared\CCProject\WolframAlpha.NET\WolframAlpha.cs:line
390
at WolframAlphaNET.WolframAlpha.Query(String query) in i:\VS_Projects_Shared\CCProject\WolframAlpha.NET\WolframAlpha.cs:line
374
at CCProject.Search.button1_Click(Object sender, EventArgs e) in
i:\VS_Projects_Shared\CCProject\CCProject\Search.cs:line 54
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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at CCProject.Form1.button2_Click(Object sender, EventArgs e) in
i:\VS_Projects_Shared\CCProject\CCProject\Form1.cs:line 97
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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at CCProject.Program.Main() in i:\VS_Projects_Shared\CCProject\CCProject\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart() InnerException:
在这行代码是 WolframAlpha.NET 的一部分
https://github.com/Genbox/WolframAlpha.NET :
private T GetResponse<T>(RestRequest request)
{
RestResponse response = (RestResponse)_client.Execute(request);
XmlAttributeDeserializer deserializer = new XmlAttributeDeserializer();
T results = deserializer.Deserialize<T>(response); //this line
return results;
}
这里是 PEVerify.exe 结果:
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1
Tools>PEVerify.exe I:\
VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\CalorieCounter.exe
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.33440
Copyright (c) Microsoft Corporation. All rights reserved.
All Classes and Methods in
I:\VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\C
alorieCounter.exe Verified.
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1
Tools>PEVerify.exe I:\
VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\CalorieCounter.exe
/md /il
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.33440
Copyright (c) Microsoft Corporation. All rights reserved.
All Classes and Methods in
I:\VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\C
alorieCounter.exe Verified.
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1
Tools>PEVerify.exe I:\
VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\WolframAlpha.NET.dll
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.33440
Copyright (c) Microsoft Corporation. All rights reserved.
All Classes and Methods in
I:\VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\W
olframAlpha.NET.dll Verified.
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1
Tools>PEVerify.exe I:\
VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\RestSharp.dll
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.33440
Copyright (c) Microsoft Corporation. All rights reserved.
All Classes and Methods in
I:\VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\R
estSharp.dll Verified.
当翻译的 Microsoft 中间语言 (MSIL) 指令包含无效命令时,将引发错误 InvalidProgramException。由于无效或损坏的 MSIL 指令,即时 (JIT) 编译器无法再继续编译 MSIL 指令,并且 JIT 编译器抛出 InvalidProgramException。 For more information look here. This may mean that the translated file (EXE or DLL) containing the GetResponse() function has become corrupt, and needs to be re-translated. The two other possibility are that your MSIL translator on your PC has a bug, or the .NET Framework JIT compiler bundled into the EXE or DLL has a bug. You can find out the exact problem by running the PEverify tool 验证 EXE 或 DLL 中的 MSIL 代码。在上面链接的信息页面上,按照 "How to troubleshoot the InvalidProgramException exception" 中的说明进行操作。 运行 PEverify 后,请将结果添加到问题的末尾。
[编辑]
我一直在寻找解决您问题的其他方法。 One solution I found 是将您的 Intellisense 设置更改为 "Show Events Only" 或完全关闭。我不知道为什么会这样,但据报道这是一种解决方案。
所以我有 2 个项目的解决方案。我将整个解决方案从我的笔记本电脑转移到我的电脑上,但我的电脑出现了这个错误:
System.InvalidProgramException was unhandled HResult=-2146233030
Message=JIT Compiler encountered an internal limitation.
Source=RestSharp StackTrace: at RestSharp.Deserializers.XmlDeserializer.GetElementByName(XElement root, XName name) at RestSharp.Deserializers.XmlDeserializer.GetValueFromXml(XElement root, XName name, PropertyInfo prop) at RestSharp.Deserializers.XmlAttributeDeserializer.GetValueFromXml(XElement root, XName name, PropertyInfo prop) at RestSharp.Deserializers.XmlDeserializer.Map(Object x, XElement root) at RestSharp.Deserializers.XmlDeserializer.Deserialize[T](IRestResponse response) at WolframAlphaNET.WolframAlpha.GetResponse[T](RestRequest request) in i:\VS_Projects_Shared\CCProject\WolframAlpha.NET\WolframAlpha.cs:line 390 at WolframAlphaNET.WolframAlpha.Query(String query) in i:\VS_Projects_Shared\CCProject\WolframAlpha.NET\WolframAlpha.cs:line 374 at CCProject.Search.button1_Click(Object sender, EventArgs e) in i:\VS_Projects_Shared\CCProject\CCProject\Search.cs:line 54 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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.RunDialog(Form form) at System.Windows.Forms.Form.ShowDialog(IWin32Window owner) at System.Windows.Forms.Form.ShowDialog() at CCProject.Form1.button2_Click(Object sender, EventArgs e) in i:\VS_Projects_Shared\CCProject\CCProject\Form1.cs:line 97 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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at CCProject.Program.Main() in i:\VS_Projects_Shared\CCProject\CCProject\Program.cs:line 19 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:
在这行代码是 WolframAlpha.NET 的一部分 https://github.com/Genbox/WolframAlpha.NET :
private T GetResponse<T>(RestRequest request)
{
RestResponse response = (RestResponse)_client.Execute(request);
XmlAttributeDeserializer deserializer = new XmlAttributeDeserializer();
T results = deserializer.Deserialize<T>(response); //this line
return results;
}
这里是 PEVerify.exe 结果:
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools>PEVerify.exe I:\ VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\CalorieCounter.exe
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.33440 Copyright (c) Microsoft Corporation. All rights reserved.
All Classes and Methods in I:\VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\C alorieCounter.exe Verified.
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools>PEVerify.exe I:\ VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\CalorieCounter.exe /md /il
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.33440 Copyright (c) Microsoft Corporation. All rights reserved.
All Classes and Methods in I:\VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\C alorieCounter.exe Verified.
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools>PEVerify.exe I:\ VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\WolframAlpha.NET.dll
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.33440 Copyright (c) Microsoft Corporation. All rights reserved.
All Classes and Methods in I:\VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\W olframAlpha.NET.dll Verified.
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools>PEVerify.exe I:\ VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\RestSharp.dll
Microsoft (R) .NET Framework PE Verifier. Version 4.0.30319.33440 Copyright (c) Microsoft Corporation. All rights reserved.
All Classes and Methods in I:\VS_Projects_Shared\CalorieCounter\CalorieCounter\bin\Debug\R estSharp.dll Verified.
当翻译的 Microsoft 中间语言 (MSIL) 指令包含无效命令时,将引发错误 InvalidProgramException。由于无效或损坏的 MSIL 指令,即时 (JIT) 编译器无法再继续编译 MSIL 指令,并且 JIT 编译器抛出 InvalidProgramException。 For more information look here. This may mean that the translated file (EXE or DLL) containing the GetResponse() function has become corrupt, and needs to be re-translated. The two other possibility are that your MSIL translator on your PC has a bug, or the .NET Framework JIT compiler bundled into the EXE or DLL has a bug. You can find out the exact problem by running the PEverify tool 验证 EXE 或 DLL 中的 MSIL 代码。在上面链接的信息页面上,按照 "How to troubleshoot the InvalidProgramException exception" 中的说明进行操作。 运行 PEverify 后,请将结果添加到问题的末尾。
[编辑]
我一直在寻找解决您问题的其他方法。 One solution I found 是将您的 Intellisense 设置更改为 "Show Events Only" 或完全关闭。我不知道为什么会这样,但据报道这是一种解决方案。