TFS 构建将不需要的代码块添加到 xap 文件 Microsoft.Practices.ServiceLocator
这是我在 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 应用程序就会按预期运行。
有谁知道为什么构建服务器包含这个库以及如何防止它这样做......?
Here is a list of my references in my silverlight project.
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/>
When I build the project localy the contence of my xap file looks like the following.
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
When this is checked in and the build server kicks off it creates a xap file with the following contence.
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
As you can see I have gained a code block in the xap file that the application does not use. However not only is this a waste of bandwidth, it actually prevents the silverlight app from doing anything, it is downloaded but does not run.
If I remove the offending Microsoft.Practices.ServiceLocator.dll from the xap file and the manifest.xml the silvlight app then functions as intended.
Has anyone got any ideas why the build server is including this library and how to prevent it from doing so...?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为 Microsoft.Practices.ServiceLocation.dll 不断添加,因为您引用了 Microsoft.Practices.Unity.Silverlight.dll 我有一种感觉,它们是相互依赖的。需要使用Unity吗?至于为什么当 Microsoft.Practices.ServiceLocation.dll 包含在 XAP 中时您的应用程序会失败;我怀疑您可能使用了错误版本的 Microsoft.Practices.Servicelocation.dll(WPF 版本?)
I think Microsoft.Practices.ServiceLocation.dll keeps getting added as you have a reference to Microsoft.Practices.Unity.Silverlight.dll I have a feeling that they are dependent on each other. Do you need to use Unity? As to why your app fails when Microsoft.Practices.ServiceLocation.dll is included in the XAP; I have a suspicion that you may be using the wrong version of the Microsoft.Practices.Servicelocation.dll (WPF version?)
迈尔斯确实了解了问题的关键,我只是添加此内容以获取有关我的特定问题的更多详细信息。
问题是 ServiceLocator 的 .net 版本被构建到构建服务器上的 xap 中。
我认为它没有在本地构建的原因是因为它正在由 GAC 解决。
我复制了 Microsoft.Practices.Unity.silverlight.dll 和 Microsoft.Practices.ServiceLocator.dll 并将它们添加到共享二进制文件夹中,该文件夹已签入源代码管理,构建服务器可以引用该文件夹。然后,我从已安装的程序中卸载了 Unity for Silverlight 2.0(我认为这已将其取消)。我添加了对上述 dll 的引用,这些 dll 现在位于我的二进制文件夹中,并在本地构建了我的解决方案。很快我的 xap 文件中就包含了 Microsoft.Practices.ServiceLocator.dll。
将所有这些内容签入 TFS 后,构建现在会从共享二进制文件夹中获取正确版本的 Microsoft.Practices.ServiceLocator.dll 并将其包含在 xap 中。工作完成了。我认为这个问题的原因在于全局程序集缓存。
希望这可以帮助同样沮丧的人。
Myles really got to the crucks of the matter and I just add this for more detail of my particular problem.
The problem was that the .net version of ServiceLocator was being built into the xap on the build server.
I think the reason it was not being built in locally was because it was being resolved by the GAC.
I took copies of the Microsoft.Practices.Unity.silverlight.dll and Microsoft.Practices.ServiceLocator.dll and added them to a shared binary folder which is checked into source control to which the build server can reference. I then uninstalled Unity for Silverlight 2.0 from my installed programs (I assume this de-Gaced it). I added references to the above dlls that were now in my binary folder and built my solution locally. Hay presto I now have Microsoft.Practices.ServiceLocator.dll included in my xap file.
Once all this was checked into TFS the build now picked up the right version of Microsoft.Practices.ServiceLocator.dll from the shared binarys folder and included it in the xap. Job done. I think the cause of this problem lies in the Global Assembly Cache.
Hope this helps someone equally frustrated.