主表单加载有问题吗? [英] Problem with main form load?

查看:69
本文介绍了主表单加载有问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些试图开始工作的开源软件.我已经按照说明导入并注册了正确的dll文件,但令我惊讶的是,直到需要调试它时,项目中才没有其他错误.

其中有异常的代码部分是:

I have a bit of open source that im trying to get working. I have imported and registred the proper dll files as instructed and now to my surprise there is no more errors in the project untill it comes time to debug it.

the part of code that has the exception in it is:

Global.System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Protected Overrides Sub OnCreateMainForm()
            Me.MainForm = Global.Shield.Form1
        End Sub


Me.mainform = Global.shield.form1给出错误信息..

创建表单时发生错误.有关详细信息,请参见Exception.InnerException.错误是:无法加载文件或程序集``Interop.MyLibrary,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null''或其依赖项之一.试图加载格式不正确的程序.

我需要该程序非常糟糕地运行才能为我的程序提供帮助,并开始在我没有太多经验的一些非常复杂的领域中起步.任何人都可以解决我的问题或告诉我怎么回事吗?


Me.mainform = Global.shield.form1 gives the error.......

An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assembly ''Interop.MyLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I need this program to run very badly to help with my program and to get a start in some very complex areas that I have not much expierence with. Can anyone solve my problem or tell me whats going on?

推荐答案

我建​​议您的第一个调用端口应该是您从那里获得开源代码的地方.他们将比这里的任何人都有更多的经验.

否则,我们将不得不检查源代码(我们没有)并亲自经历学习过程!
I would suggest that your first port of call should be where you got the open source code from. They will have a lot more experience with it than anyone here.

Otherwise, we would have to examine the source code (which we don''t have) and go through a learning curve ourselves!


尝试AssemblyResolve.可能会有所帮助.

Try AssemblyResolve. May be it would help.

  Function CurrentDomain_AssemblyResolve(ByVal sender As Object, ByVal args As ResolveEventArgs) As Reflection.Assembly
  Try
    Return Reflection.Assembly.LoadFrom(directoryToLookForDependencies & "\" & args.Name.Substring(0, args.Name.IndexOf(",")) & ".dll")
  Catch ex As Exception
    Return Nothing
  End Try
End Function



directoryToLookForDependencies
中具有目录路径
并在您的表单的加载事件中
AddHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf CurrentDomain_AssemblyResolve



Have a directory path in directoryToLookForDependencies

and in your form''s load event
AddHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf CurrentDomain_AssemblyResolve


这篇关于主表单加载有问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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