' System.InvalidProgramException'发生在PC上的RestSharp.dll中,在笔记本电脑上正常工作

时间:2016-08-12 14:31:05

标签: c# visual-studio restsharp

所以我有2个项目的解决方案。我将整个解决方案从我的笔记本电脑转移到我的电脑,在那里我得到了这个错误:

  

System.InvalidProgramException未处理HResult = -2146233030
  Message = JIT编译器遇到内部限制   Source = RestSharp StackTrace:          在RestSharp.Deserializers.XmlDeserializer.GetElementByName(XElement   root,XName名称)          在RestSharp.Deserializers.XmlDeserializer.GetValueFromXml(XElement root,   XName名称,PropertyInfo prop)          at RestSharp.Deserializers.XmlAttributeDeserializer.GetValueFromXml(XElement)   root,XName名称,PropertyInfo prop)          at RestSharp.Deserializers.XmlDeserializer.Map(Object x,XElement root)          在RestSharp.Deserializers.XmlDeserializer.Deserialize [T](IRestResponse   响应)          在WolframAlphaNET.WolframAlpha.GetResponse [T](RestRequest请求)中   I:\ VS_Projects_Shared \ CCProject \ WolframAlpha.NET \ WolframAlpha.cs:行   390          在WolframAlphaNET.WolframAlpha.Query(字符串查询)i:\ VS_Projects_Shared \ CCProject \ WolframAlpha.NET \ WolframAlpha.cs:line   374          在CCProject.Search.button1_Click(Object sender,EventArgs e)中   i:\ VS_Projects_Shared \ CCProject \ CCProject \ Search.cs:第54行          在System.Windows.Forms.Control.OnClick(EventArgs e)          在System.Windows.Forms.Button.OnClick(EventArgs e)          在System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)          在System.Windows.Forms.Control.WmMouseUp(消息& m,MouseButtons按钮,Int32点击)          在System.Windows.Forms.Control.WndProc(消息& m)          在System.Windows.Forms.ButtonBase.WndProc(消息& m)          在System.Windows.Forms.Button.WndProc(消息& m)          在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)          在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)          在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)          在System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)          在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr)   dwComponentID,Int32原因,Int32 pvLoopData)          在System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32)   原因,ApplicationContext上下文)          在System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32)   原因,ApplicationContext上下文)          在System.Windows.Forms.Application.RunDialog(表单表单)          在System.Windows.Forms.Form.ShowDialog(IWin32Window所有者)          在System.Windows.Forms.Form.ShowDialog()          在CCProject.Form1.button2_Click(Object sender,EventArgs e)中   i:\ VS_Projects_Shared \ CCProject \ CCProject \ Form1.cs:第97行          在System.Windows.Forms.Control.OnClick(EventArgs e)          在System.Windows.Forms.Button.OnClick(EventArgs e)          在System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)          在System.Windows.Forms.Control.WmMouseUp(消息& m,MouseButtons按钮,Int32点击)          在System.Windows.Forms.Control.WndProc(消息& m)          在System.Windows.Forms.ButtonBase.WndProc(消息& m)          在System.Windows.Forms.Button.WndProc(消息& m)          在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)          在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)          在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)          在System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)          在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr)   dwComponentID,Int32原因,Int32 pvLoopData)          在System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32)   原因,ApplicationContext上下文)          在System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32)   原因,ApplicationContext上下文)          在System.Windows.Forms.Application.Run(Form mainForm)          at CCProject.Program.Main()in i:\ VS_Projects_Shared \ CCProject \ CCProject \ Program.cs:第19行          在System.AppDomain._nExecuteAssembly(RuntimeAssembly程序集,String [] args)          在System.AppDomain.nExecuteAssembly(RuntimeAssembly程序集,String [] args)          在System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)          在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()          在System.Threading.ThreadHelper.ThreadStart_Context(对象状态)          在System.Threading.ExecutionContext.RunInternal(ExecutionContext   executionContext,ContextCallback回调,对象状态,布尔值   preserveSyncCtx)          at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean   preserveSyncCtx)          在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态)          在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   工具&gt; PEVerify.exe I:\   VS_Projects_Shared \ CalorieCounter \ CalorieCounter \ BIN \调试\ CalorieCounter.exe

     

Microsoft(R).NET Framework PE Verifier。版本4.0.30319.33440   版权所有(c)Microsoft Corporation。保留所有权利。

     

中的所有类和方法   I:\ VS_Projects_Shared \ CalorieCounter \ CalorieCounter \ BIN \调试\ C   alorieCounter.exe已验证。

     

C:\ Program Files(x86)\ Microsoft SDKs \ Windows \ v8.1A \ bin \ NETFX 4.5.1   工具&gt; PEVerify.exe I:\   VS_Projects_Shared \ CalorieCounter \ CalorieCounter \ BIN \调试\ CalorieCounter.exe   / md / il

     

Microsoft(R).NET Framework PE Verifier。版本4.0.30319.33440   版权所有(c)Microsoft Corporation。保留所有权利。

     

中的所有类和方法   I:\ VS_Projects_Shared \ CalorieCounter \ CalorieCounter \ BIN \调试\ C   alorieCounter.exe已验证。

     

C:\ Program Files(x86)\ Microsoft SDKs \ Windows \ v8.1A \ bin \ NETFX 4.5.1   工具&gt; PEVerify.exe I:\   VS_Projects_Shared \ CalorieCounter \ CalorieCounter \ BIN \调试\ WolframAlpha.NET.dll

     

Microsoft(R).NET Framework PE Verifier。版本4.0.30319.33440   版权所有(c)Microsoft Corporation。保留所有权利。

     

中的所有类和方法   I:\ VS_Projects_Shared \ CalorieCounter \ CalorieCounter \ BIN \调试\ W   olframAlpha.NET.dll已通过验证。

     

C:\ Program Files(x86)\ Microsoft SDKs \ Windows \ v8.1A \ bin \ NETFX 4.5.1   工具&gt; PEVerify.exe I:\   VS_Projects_Shared \ CalorieCounter \ CalorieCounter \ BIN \调试\ RestSharp.dll

     

Microsoft(R).NET Framework PE Verifier。版本4.0.30319.33440   版权所有(c)Microsoft Corporation。保留所有权利。

     

中的所有类和方法   I:\ VS_Projects_Shared \ CalorieCounter \ CalorieCounter \ BIN \调试\ r   estSharp.dll已通过验证。

1 个答案:

答案 0 :(得分:0)

当翻译的Microsoft中间语言(MSIL)指令包含无效命令时,将引发错误InvalidProgramException。由于MSIL指令无效或损坏,实时(JIT)编译器无法再继续编译MSIL指令,并且JIT编译器抛出InvalidProgramException。 For more information look here。这可能意味着包含GetResponse()函数的已翻译文件(EXE或DLL)已损坏,需要重新翻译。另外两种可能性是您PC上的MSIL转换程序有错误,或捆绑到EXE或DLL中的.NET Framework JIT编译器有错误。您可以通过运行PEverify tool来验证确切的问题,以验证EXE或DLL中的MSIL代码。在上面链接的信息页面上,按照“如何解决InvalidProgramException异常”中的说明进行操作。运行PEverify后,请将结果添加到问题的最后。

[编辑]

我一直在寻找其他解决方案来解决您的问题。 One solution I found是将您的智能感知设置更改为“仅显示事件”或完全关闭。我不知道为什么会这样,但据报道它已成为一种解决方案。