我正在尝试使用Visual Studio for .NET 4.5创建的程序集在MonoDevelop 4.2.3中创建一个应用程序,但是我收到了这个警告:
/usr/lib/mono/4.5/Microsoft.Common.targets:警告:参考 ' System.Diagnostics.Tracing,Version = 4.0.0.0,Culture = neutral, 公钥= b03f5f7f11d50a3a'未解决(ListenerBinTest)
当然,当我尝试运行应用程序时,它会因此错误而失败:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Diagnostics.Tracing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
at System.Threading.Tasks.Dataflow.TransformBlock`2[System.Net.Sockets.Socket,vtortola.WebSockets.WebSocketListener+WebSocketNegotiationResult]..ctor (System.Func`2 transform, System.Threading.Tasks.Dataflow.ExecutionDataflowBlockOptions dataflowBlockOptions) [0x00000] in <filename unknown>:0
at vtortola.WebSockets.WebSocketListener..ctor (System.Net.IPEndPoint endpoint, vtortola.WebSockets.WebSocketListenerOptions options) [0x00000] in <filename unknown>:0
at vtortola.WebSockets.WebSocketListener..ctor (System.Net.IPEndPoint endpoint) [0x00000] in <filename unknown>:0
at ListenerBinTest.MainClass.Main (System.String[] args) [0x00010] in /home/vtortola/ListenerBinTest/ListenerBinTest/Program.cs:12
说实话,我不会使用与System.Diagnostics.Tracing
相关的任何内容,但显然System.Threading.Tasks.Dataflow
会这样做。
这是我的设置:
=== MonoDevelop ===
Version 4.2.3
Installation UUID: 2798c094-3f0b-42d7-afe4-2984107bea4e
Runtime:
Mono 3.2.8 (tarball Mon Mar 10 19:20:49 UTC 2014) (64-bit)
GTK+ 2.24.22 theme: oxygen-gtk
GTK# (2.12.0.0)
=== Build Information ===
Git revision:
Build date: 2014-03-10 20:43:25+0000
=== Operating System ===
Linux
Linux linux-nt8h.site 3.11.10-7-desktop #1 SMP PREEMPT Mon Feb 3 09:41:24 UTC 2014 (750023e) x86_64 x86_64 x86_64 GNU/Linux
我该如何解决这个问题?
感谢。
答案 0 :(得分:4)
不幸的是,Mono 3.2.8没有将System.Diagnostics.Tracing.dll作为其完整.NET框架实现的一部分。
但是,应该可以通过将System.Diagnostics.Tracing.dll的PCL版本复制到项目中并引用它来解决此问题。这假设您实际上没有在项目中使用任何System.Diagnostics.Tracing.dll,因为PCL库可能没有任何实现。
安装Mono 3.4.0后,您可以复制System.Diagnostics.Tracing.dll文件之一。为了测试一切正常,我将以下文件复制到我的项目中:
/Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/xbuild-frameworks/.NETPortable/v4.5/System.Diagnostics.Tracing.dll
这是在Mac上。您将需要找到该文件,因为Linux上的位置不同,它可能位于Mono 3.2.8中的不同位置。它似乎在Profile7中应该包含在Mono 3.2.8中。在Portable Library Reference Assemblies下载中也可以从Microsoft获得.dll。不幸的是,下载要求Windows能够使用可移植的库dll安装.zip文件。
该文件已复制到项目中,因为在添加引用时无法使用Xamarin Studio浏览该文件。这是因为它位于一个隐藏的目录中,因为该目录以点开头。
在我的项目中直接引用System.Diagnostics.Tracing.dll,我可以让Microsoft的example DataFlow code正常工作。