[英]C# Mono: TypeLoadException when trying to use a DLL reference
I'm new to Mono/.NET so I'm not quite sure if I'm adding my reference right or not. 我是Mono / .NET的新手,所以我不确定我是否正在添加我的引用。 I'm trying to implement Fleck WebSockets.
我正在尝试实现Fleck WebSockets。 I downloaded the source, opened the solution in MonoDevelop, and built it.
我下载了源代码,在MonoDevelop中打开了解决方案并构建了它。 I took the resulting "Fleck.dll" and "Fleck.dll.mdb" and placed them in my project's folder.
我将生成的“Fleck.dll”和“Fleck.dll.mdb”放在我项目的文件夹中。 Then, in MonoDevelop, I went to the reference editor in my solution and selected that Fleck.dll as a .NET Assembly reference.
然后,在MonoDevelop中,我转到解决方案中的引用编辑器,然后选择Fleck.dll作为.NET Assembly引用。
It seems to work correctly, MonoDevelop finds everything in that assembly. 它似乎工作正常,MonoDevelop找到该程序集中的所有内容。 If I type "Fleck."
如果我输入“Fleck”。 then the autocomplete pops up with all the members of that DLL, but if I write a bit of code trying to use it, I get a TypeLoadException.
然后会自动弹出该DLL的所有成员,但是如果我编写一些尝试使用它的代码,则会收到TypeLoadException。 It compiles and runs but throws that exception immediately.
它编译并运行但立即抛出异常。
I'm using the code from an example I found so I don't think that's an issue. 我使用的是我发现的示例中的代码,因此我认为这不是问题。 Here's my full exception output:
这是我的完整异常输出:
Could not load signature of Fleck.SocketWrapper:Accept due to:
Could not load signature of Fleck.ISocket:Accept due to:
Unhandled Exception: System.TypeLoadException: Could not load type 'Fleck.SocketWrapper' from assembly 'Fleck, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
at Fleck.WebSocketServer..ctor (System.String location) [0x00000] in <filename unknown>:0
at TestServer.MainClass.Main (System.String[] args) [0x00000] in /home/danny/Projects/TestServer/Main.cs:10
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'Fleck.SocketWrapper' from assembly 'Fleck, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
at Fleck.WebSocketServer..ctor (System.String location) [0x00000] in <filename unknown>:0
at TestServer.MainClass.Main (System.String[] args) [0x00000] in /home/danny/Projects/TestServer/Main.cs:10
What am I doing wrong? 我究竟做错了什么?
It works fine for me. 这对我来说可以。 I am using Mono 2.10.8 on Ubuntu.
我在Ubuntu上使用Mono 2.10.8。 What I did was:
我做的是:
So I bet it should work fine. 所以我打赌它应该工作正常。 What is your version of Mono?
你的Mono版本是什么?
Oh, I also explicitly set the framework version for all mentioned projects to 4.0 (which was essential for proper compilation). 哦,我还明确地将所有提到的项目的框架版本设置为4.0(这对于正确的编译是必不可少的)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.