Detect Silverlight version required by an assembly

心不动则不痛 提交于 2019-12-08 02:43:37

问题


How can I tell whether Silverlight 2 is sufficient for an assembly or Silverlight 3 is required?
I have all information that is available through reflection (Mono.Cecil).

Same question for SL 3 versus 4.

Thanks in advance.


回答1:


You cannot tell from just the class library and its metadata - this can only be reliably determined from a Silverlight application's embedded manifest file in the .Xap.




回答2:


This might be exactly what you are looking for:

Assembly asm = Assembly.GetExecutingAssembly(); 
string[] parts = asm.FullName.Split(',');
string version = parts[1];

http://forums.silverlight.net/forums/p/23321/82774.aspx#82774

4 is backward compatible with 3, 3 is backward compatiable with 2.

You should know which version of silverlight the app is built in.

Installation and detection:

This one has a Javascript file that will detect if SL is installed and What version: http://blog.mdk-photo.com/post/Detecting-Silverlight-version-installed.aspx

http://www.apijunkie.com/APIJunkie/blog/post/2009/04/How-to-programmatically-detect-Silverlight-version.aspx

Version detection with Silverlight

http://www.scribd.com/doc/14938624/Creating-a-Custom-Silverlight-Installation-Experience

http://blogs.msdn.com/tims/archive/2007/10/29/optimizing-the-silverlight-install-experience.aspx

Thge GAC will also notify you durring compile if you are running the wrong version of SL. Typically when you have Silverlight tools installed and try to compile an app. For instance your assembly is created in version 3 and you use a control that is only available in 3, you will have to have SL 3 tools installed or the build will error letting you know.

More on the Silverlight assemblies:

http://www.netfxharmonics.com/2008/12/Reusing-NET-Assemblies-in-Silverlight

http://nerddawg.members.winisp.net/AssemblySniffer/



来源:https://stackoverflow.com/questions/1862801/detect-silverlight-version-required-by-an-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!