Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 试图读取或写入受保护的内存。-将应用程序从VS 2005转换为VS 2008后_C#_Visual Studio 2008_Dll - Fatal编程技术网

C# 试图读取或写入受保护的内存。-将应用程序从VS 2005转换为VS 2008后

C# 试图读取或写入受保护的内存。-将应用程序从VS 2005转换为VS 2008后,c#,visual-studio-2008,dll,C#,Visual Studio 2008,Dll,我有一个用VS2005(C#)编写的应用程序。工作正常,它调用第三方dll。现在我已经将其转换为VS2008(使用向导),在尝试实例化第三方dll时出现以下错误 Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 不知道从哪里开始调试这个。谁能给我指出正确的方向吗 编辑:作为旁注,它在VS2010下做了完全相同的事情 编辑:VS2005和VS

我有一个用VS2005(C#)编写的应用程序。工作正常,它调用第三方dll。现在我已经将其转换为VS2008(使用向导),在尝试实例化第三方dll时出现以下错误

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
不知道从哪里开始调试这个。谁能给我指出正确的方向吗

编辑:作为旁注,它在VS2010下做了完全相同的事情


编辑:VS2005和VS2008项目都使用相同的代码目标.NET2.0框架


编辑:它是一个名为LPDFCTRLIB的ActiveX库。我只是在引用下添加了它,并创建了一个新的实例:

public LPDFCTRLLib.LPDFWndClass olpdf = null;
//and later in my code
//...
//this is where it fails
olpdf = new LPDFCTRLLib.LPDFWndClass();
编辑:堆栈跟踪

at pcl2pdf.Form1.convertPCL(String inputFile, String outputFile) in C:\junk\pcl2pdf\pcl2pdf\pcl2pdf\Form1.cs:line 29
   at pcl2pdf.Form1.Form1_Load(Object sender, EventArgs e) in C:\junk\pcl2pdf\pcl2pdf\pcl2pdf\Form1.cs:line 24
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.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.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
   at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
   at System.Windows.Forms.Control.set_Visible(Boolean value)
   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 pcl2pdf.Program.Main() in C:\junk\pcl2pdf\pcl2pdf\pcl2pdf\Program.cs:line 17
   at System.AppDomain._nExecuteAssembly(Assembly 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.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

这里描述了相同的问题:

“无论如何,解决方案是启用 JIT优化。换句话说,在 VisualStudio2008选择“工具”并 然后选择“选项”。选择“调试”并 “将军”并找到写着 “抑制模块上的JIT优化 “加载”,这种方式确保 调试器和JIT编译的代码 由于 JIT编译器就是这样一个超级复制器 你的代码的优化器。这做了 把戏。”


这里描述了相同的问题:

“无论如何,解决方案是启用 JIT优化。换句话说,在 VisualStudio2008选择“工具”并 然后选择“选项”。选择“调试”并 “将军”并找到写着 “抑制模块上的JIT优化 “加载”,这种方式确保 调试器和JIT编译的代码 由于 JIT编译器就是这样一个超级复制器 你的代码的优化器。这做了 把戏。”


您应该删除DLL,然后重新添加它。特别是对于非托管DLL。并与供应商检查是否兼容


请注意:您不会将项目转换为VS版本,配置文件除外。您使其成为框架版本的目标。您的问题缺少有关Fx版本的所有信息。

您应该删除DLL,然后重新添加它。特别是对于非托管DLL。并与供应商检查是否兼容


请注意:您不会将项目转换为VS版本,配置文件除外。您使其成为框架版本的目标。您的问题缺少有关Fx版本的所有信息。

您可以发布堆栈跟踪吗?并且ConvertPCl在DLL中?是否有任何导入/互操作标记?是否可以发布堆栈跟踪?ConvertPCl是否在DLL中?任何导入/互操作标记?这没有做到…发布堆栈跟踪这没有做到…发布堆栈跟踪VS 2005和VS 2008项目使用相同的代码目标.NET 2.0 FrameworkIt是一个名为LPDFCTRLIB的ActiveX库。我只是在引用下添加了它,并使用相同的代码target.NET2.0Frameworkit的名为LPDFCTRLIB的ActiveX库创建了一个ITVS2005和VS2008项目的新实例。我只是在引用下添加了它,并创建了一个新的实例