【问题标题】:TFS build adding an unwanted code block to xap file Microsoft.Practices.ServiceLocatorTFS 构建将不需要的代码块添加到 xap 文件 Microsoft.Practices.ServiceLocator
【发布时间】:2011-09-23 11:13:36
【问题描述】:

这是我在 silverlight 项目中的参考列表。

Microsoft.Practices.Unity.Silverlight<br/>
mscorelib<br/>
Prospector.ProviderMatching.LinkedDataObjects<br/>
Prospector.ProviderMatching.SLDataObjects<br/>
System<br/>
System.ComponentModel.DataAnnotations<br/>
System.Core<br/>
System.Net<br/>
System.ServiceModel<br/>
System.Windows<br/>
System.Windows.Browser<br/>
System.Windows.Controls<br/>
System.Windows.Controls.Data.Input<br/>
System.Windows.Controls.Toolkit<br/>
System.Windows.Data<br/>
System.Xml<br/>

当我在本地构建项目时,我的 xap 文件的内容如下所示。

AppManifest.xaml
Microsoft.Practices.Unity.Silverlight.dll
Prospector.ProviderMatching.DataObjects.SL.dll
Prospector.ProviderMatching.Silverlight.dll
Prospector.ProviderMatching.SLDataObjects.dll
ServiceReferences.ClientConfig
System.ComponentModel.DataAnnotations.dll
System.Windows.Controls.Data.dll
System.Windows.Controls.Data.Input.dll
System.Windows.Controls.dll
System.Windows.Controls.Toolkit.dll
System.Windows.Controls.Toolkit.Internals.dll
System.Windows.Data.dll

当这被签入并且构建服务器启动时,它会创建一个包含以下内容的 xap 文件。

AppManifest.xaml
Microsoft.Practices.ServiceLocation.dll
Microsoft.Practices.Unity.Silverlight.dll
Prospector.ProviderMatching.DataObjects.SL.dll
Prospector.ProviderMatching.Silverlight.dll
Prospector.ProviderMatching.SLDataObjects.dll
ServiceReferences.ClientConfig
System.ComponentModel.DataAnnotations.dll
System.Windows.Controls.Data.dll
System.Windows.Controls.Data.Input.dll
System.Windows.Controls.dll
System.Windows.Controls.Toolkit.dll
System.Windows.Controls.Toolkit.Internals.dll
System.Windows.Data.dll

如您所见,我在 xap 文件中获得了应用程序不使用的代码块。然而,这不仅浪费带宽,而且实际上阻止了 silverlight 应用程序做任何事情,它被下载但没有运行。

如果我从 xap 文件和 manifest.xml 中删除有问题的 Microsoft.Practices.ServiceLocator.dll,silvlight 应用程序就会按预期运行。

有没有人知道为什么构建服务器包含这个库以及如何防止它这样做......?

【问题讨论】:

  • 只是一个想法...您在使用 Prism 吗?您是否检查过您没有使用错误的程序集(可能是 WPF 程序集?)
  • 我认为 Microsoft.Practices.ServiceLocation.dll 不断被添加,因为您引用了 Microsoft.Practices.Unity.Silverlight.dll 我感觉它们相互依赖。你在使用 Unity 吗?

标签: visual-studio-2010 silverlight-4.0 msbuild unity-container


【解决方案1】:

我认为 Microsoft.Practices.ServiceLocation.dll 不断添加,因为您引用了 Microsoft.Practices.Unity.Silverlight.dll 我感觉它们相互依赖。您需要使用 Unity 吗?至于为什么当 Microsoft.Practices.ServiceLocation.dll 包含在 XAP 中时您的应用程序会失败;我怀疑您可能使用了错误版本的 Microsoft.Practices.Servicelocation.dll(WPF 版本?)

【讨论】:

  • 感谢您的反馈。我的解决方案中根本没有对 Microsoft.Practices.ServiceLocation.dll 的引用,所以我不知道如何让它使用正确的。我只有对 Mirosoft.Practices.Unity.Silverlight.dll 的引用。如果 ServiceLocation 是 Unity.Silverlight 的依赖项,那么为什么它不包含在 Visual Studio 本地构建的 xap 中?
  • 我在这里的 Silverlight 项目中使用 Unity。我刚刚在我的一个 SL 项目中添加了对 Microsoft.Practices.Unity.Silverlight.dll 的引用。在进行本地构建后,我打开了 XAP 文件并找到了.....Microsoft.Practices.Servicelocation.dll。我更感兴趣的是为什么当 XAP 包含 Microsoft.Practices.Servicelocation.dll 文件时您的 SL 应用程序会失败。当 XAP 包含两个 DLL 时,我的 SL 应用程序运行良好。您在 XAP 中找到的 Microsoft.Practices.Servicelocation.dll 的版本号是什么。您的应用程序如何失败...是否有错误消息?
  • 刚刚在我的本地构建输出中找到了这个:Dependency "Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"。 (TaskId:956)“Microsoft.Practices.Unity.Silverlight”要求。 (任务 ID:956)
  • 好的,我已经反汇编了 Microsoft.Practices.unity.silverlight,它很明显像你说的那样依赖于 ServiceLocation。assembly extern Microsoft.Practices.ServiceLocation { .publickeytoken = (31 BF 38 56 AD 36 4E 35 ) // 1.8V.6N5 .ver 1:0:0:0 }
【解决方案2】:

Myles 真的抓住了问题的关键,我只是添加了这个以了解我的特定问题的更多细节。

问题在于 .net 版本的 ServiceLocator 正在构建到构建服务器上的 xap 中。

我认为它没有在本地构建的原因是因为它正在由 GAC 解决。

我复制了 Microsoft.Practices.Unity.silverlight.dll 和 Microsoft.Practices.ServiceLocator.dll 并将它们添加到共享二进制文件夹中,该文件夹已签入到构建服务器可以引用的源代码管理中。然后,我从已安装的程序中卸载了 Unity for Silverlight 2.0(我假设这已消除它)。我添加了对现在位于我的二进制文件夹中的上述 dll 的引用,并在本地构建了我的解决方案。 Hay presto 现在我的 xap 文件中包含了 Microsoft.Practices.ServiceLocator.dll。

一旦将所有这些检查到 TFS 中,构建现在会从共享二进制文件夹中选择正确版本的 Microsoft.Practices.ServiceLocator.dll 并将其包含在 xap 中。任务完成。我认为这个问题的原因在于全局程序集缓存。

希望这可以帮助同样沮丧的人。

【讨论】:

  • 统一安装程序不 GAC 任何东西。不知道它是怎么进来的,一定是其他程序做到了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-11
  • 2011-06-07
相关资源
最近更新 更多