运行时错误加载类 [英] Runtime Error loading Class

查看:87
本文介绍了运行时错误加载类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行VB2008 Express,其中已加载2个项目.
1.具有公共New方法的类-clsAcad.
2.用于测试课程的Windows窗体

表单具有以下代码:

I am running VB2008 Express with 2 projects loaded.
1. A class - clsAcad which has a public New method.
2. A windows form to test class

Form has this code:

Private Sub Form1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Click
   Dim ac As New Acad2008.clsAcad
   Button1.Enabled = ac.Loaded
End Sub


运行时错误会导致此:-


Runtime error produces this:-

System.IO.FileNotFoundException was unhandled
  Message="The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
  Source="Acad2008"
  StackTrace:
       at Acad2008.clsAcad..ctor()
       at WindowsApplication1.Form1.Form1_Click(Object sender, EventArgs e) in C:\Users\Stuart\Documents\Visual Studio 2008\Projects\WindowsApplication1\Form1.vb:line 9
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(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(Int32 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 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

推荐答案

在Internet上快速浏览一下,发现它可能是由于尝试使用两种不同版本的.NET Framework引起的. />
检查包含clsAcad的DLL和测试实用程序是否都针对同一版本.


了解了.再次,AutoCad soes不支持网络框架4,建议使用我下载的VB2008,因此我使用3.5重写了VB2008 Express中的所有内容.
但是,似乎Express不允许使用外部程序进行调试<"/b>

从此评论中,我假设您下载了VS2008 Express来对其进行编译:如果您已经具有VS2010的适当"版本,则可以将框架设置为V3.5,然后对其进行编译.这将包括完整的调试.

我不相信VS2008 Express会受到如此有限的限制:您要做的就是在V3.5项目中包含对ACAD程序集的引用,它应该可以工作.我没有在这里进行测试,因此无法检查.为此,您做了什么?
A quick look on the internet suggest that it can be caused by trying to use two different version of the .NET framework.

Check that both the DLL containing clsAcad and the test utility are targeting the same version.


"Understood. Again AutoCad soes not support net framework 4 and suggest using VB2008, which I downloaded, and so I rewrote everything in VB2008 Express using 3.5
However it seems that Express does not allow debugging using an external program<"/b>

I assume from this comment that you downloaded VS2008 Express to compile it: If you already have the "proper" version of VS2010, you can just set the framework to V3.5 and compile it then. That would include full debugging.

I do not believe that VS2008 Express would be so limited: all you should have to do is include a reference to the ACAD assembly in your V3.5 project and it should work. I don''t have it here to test, so can''t check however. What did you do to get to this point?


这篇关于运行时错误加载类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆