在 ASP.NET 和 Silverlight 之间共享程序集
我创建了一个程序集来在我的主应用程序和 silverlight 应用程序之间共享它。一开始它看起来好像可以工作,但现在我得到了这个异常:“System.IO.FileNotFoundException 被捕获,Message =”无法加载文件或程序集“System.Xml.Linq”。我正在使用 .NET 3.5 Sp1 和 Silverlight 3。
该共享程序集使用 System.Xml.Linq,并且找不到它...我想是因为它试图在 .NET 框架中查找该版本,而不是在 silverlight 中查找,我该如何修复。 :这
PS
是完整的异常输出:
System.IO.FileNotFoundException 被捕获 Message="无法加载文件或程序集“System.Xml.Linq,Version=2.0.5.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。系统找不到指定的文件。" 来源=“MyApp.元数据” FileName =“System.Xml.Linq,版本= 2.0.5.0,文化=中性,PublicKeyToken = 31bf3856ad364e35” FusionLog===预绑定状态信息===\r\nLOG: User = IIS APPPOOL\DefaultAppPool\r\nLOG: DisplayName = System.Xml.Linq, Version=2.0.5.0, Culture=neutral, PublicKeyToken= 31bf3856ad364e35\n(完全指定)\r\n日志:Appbase = file:///C:/Users/vtortola.MyApp/Documents/MyApp/MyAppSAS/WebApplication1/WebApplication1/\r\n日志:初始 PrivatePath = C:\ Users\vtortola.MyApp\Documents\MyApp\MyAppSAS\WebApplication1\WebApplication1\bin\r\n调用程序集: MyApp.Metadata,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null。\r\n===\r \n日志: 此绑定在默认加载上下文中启动。\r\n日志: 使用应用程序配置文件: C:\Users\vtortola.MyApp\Documents\MyApp\MyAppSAS\WebApplication1\WebApplication1\web.config\r\n日志: 使用主机配置文件:C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet.config\r\nLOG:使用 C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine 中的计算机配置文件。配置。\r\n日志:策略后引用:System.Xml.Linq,版本=2.0.5.0,文化=中性,PublicKeyToken=31bf3856ad364e35\r\n日志:之前看到过相同的绑定,但失败,hr = 0x80070002 .\r\n" 堆栈跟踪: 在 MyApp.Metadata.MyAppEntity.Deserialize(字符串消息)
I've created an assembly to share it between my main app and the silverlight app. At the beginning it looked like it was going to work but now I get this exception: "System.IO.FileNotFoundException was caught, Message="Could not load file or assembly 'System.Xml.Linq". I'm using .NET 3.5 Sp1 and Silverlight 3.
That shared assembly uses System.Xml.Linq, and it cannot find it... I think because it is trying to find that version in the .NET framework instead looking in the silverlight one. How can I fix this?
Cheers.
PS: this is the full exception output:
System.IO.FileNotFoundException was caught
Message="Could not load file or assembly 'System.Xml.Linq, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."
Source="MyApp.Metadata"
FileName="System.Xml.Linq, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
FusionLog="=== Pre-bind state information ===\r\nLOG: User = IIS APPPOOL\DefaultAppPool\r\nLOG: DisplayName = System.Xml.Linq, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\n (Fully-specified)\r\nLOG: Appbase = file:///C:/Users/vtortola.MyApp/Documents/MyApp/MyAppSAS/WebApplication1/WebApplication1/\r\nLOG: Initial PrivatePath = C:\Users\vtortola.MyApp\Documents\MyApp\MyAppSAS\WebApplication1\WebApplication1\bin\r\nCalling assembly : MyApp.Metadata, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.\r\n===\r\nLOG: This bind starts in default load context.\r\nLOG: Using application configuration file: C:\Users\vtortola.MyApp\Documents\MyApp\MyAppSAS\WebApplication1\WebApplication1\web.config\r\nLOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet.config\r\nLOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.\r\nLOG: Post-policy reference: System.Xml.Linq, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\r\nLOG: The same bind was seen before, and was failed with hr = 0x80070002.\r\n"
StackTrace:
at MyApp.Metadata.MyAppEntity.Deserialize(String message)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须维护两个独立的项目 - 一个用于桌面,一个用于 Silverlight。请参阅此处了解更多信息:
如何在 Silverlight 应用程序中使用非 Silverlight 程序集?
您可以共享大部分代码项目之间(如从一个项目到另一个项目的链接文件)。以下是描述如何执行此操作的 Microsoft 页面:
http://msdn .microsoft.com/en-us/library/ff648215.aspx
You must maintain two separate projects - one for desktop and for Silverlight. Have a look here for more information:
How can I use non-Silverlight assemblies in a Silverlight app?
You can share most of the code between projects (as in link files from one to another). Here is the Microsoft page that describes how to do exactly this:
http://msdn.microsoft.com/en-us/library/ff648215.aspx