简体   繁体   English

C#项目中引用的VB.Net dll

[英]VB.Net dll referenced in C# project

I have a previously created project written in VB.Net. 我有一个以前用VB.Net编写的项目。 I have a website that is written in C# referencing the VB project. 我有一个用C#编写的网站,引用了VB项目。 The VB project is a class that accesses the database. VB项目是访问数据库的类。 It compiles and runs fine on my local machine. 它可以在我的本地计算机上编译并正常运行。 When I put it on the server, I get the following error 将其放在服务器上时,出现以下错误

Cannot load type 'DLLOM.clsDB, DLLOM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. 无法加载类型'DLLOM.clsDB,DLLOM,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'。

This is the code it is failing on 这是它失败的代码

DLLOM.clsDB objDB = (DLLOM.clsDB)Activator.GetObject(typeof(DLLOM.clsDB), ConfigurationManager.AppSettings["RemotingPathDB." + System.Environment.MachineName.ToUpper()]);
DataSet ds = objDB.MembershipsGet();

Any idea on why it is correctly referenced on my machine, but not on the server? 关于为什么在我的计算机上正确引用了它但在服务器上没有正确引用的想法? The website is compiled on 3.5 framework, while the VB class is 2.0. 该网站是在3.5框架上编译的,而VB类是2.0。 I tried switching them to no avail. 我试图将它们切换为无济于事。

Cannot load type 'DLLOM.clsDB, DLLOM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. 无法加载类型'DLLOM.clsDB,DLLOM,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'。

It is a TypeLoadException. 它是TypeLoadException。 That's the boring part, it doesn't get interesting until you start looking at the InnerException. 那是无聊的部分,直到您开始查看InnerException时,它才变得有趣。 Which tells you what really happened to stop the type from getting loaded. 告诉您真正发生了什么事情阻止了该类型的加载。

If this is all you got out of your program then you need to improve your exception reporting. 如果这是您从程序中得到的全部,那么您需要改进异常报告。 Be sure to use the exception's ToString() method instead of the Message property. 确保使用异常的ToString()方法而不是Message属性。 You'll get everything , including the inner exceptions. 您将获得所有信息 ,包括内部异常。 If you get it in the debugger then be sure to use the Exception Assistant. 如果您在调试器中找到它,请确保使用“异常助手”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM