What does version 255.255.255.255 for winmd files indicate?

核能气质少年 提交于 2019-12-07 04:38:23

问题


I noticed that most (all?) .winmd files have a version of 255.255.255.255 like:

Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null

Metro apps have a reference to such assemblies with this version number.


Further the Windows.winmd itself references:

mscorlib, Version=255.255.255.255, Culture=neutral, PublicKeyToken=b77a5c561934e089

However, an assembly with this version number does not exist, as far as I know.

Does this version number have a special meaning? Is there any documentation for this?


回答1:


ECMA 335 assemblies need to have a version number. But the windows runtime type resolution algorithm doesn't use the version number, so the team creating the winmd format chose an arbitrary version number of 255.255.255.255 for the assembly version number.

That helps to ensure that nobody attempts to use the .Net type resolution algorithm when doing type resolution (it's not perfect, unfortunately some tools still use the .Net type resolution algorithm).

Oh and the mscorlib reference is a pro-forma reference - ECMA 335 requires that all typeref's have a corresponding assemblyref and the WINMD file format chose to use typerefs to certain ECMA 335 types as indicators of a specific type. For example, the winrt "enum" construct is represented as a type which extends "System.Enum" - for a winmd file the "System.Enum" part is just a string (it could have been anything), and cannot be resolved to a real type. That string is represented in metadata as a typeref and typerefs have to have an assemblyref - we chose to use the mscorlib version of System.Enum as the assemblyref for the enum because it was convenient.




回答2:


Keep in mind that the .winmd files contain metadata for the WinRT interfaces. Windows can't assume that any particular version of .NET will be used. Windows 8 will be around a lot longer than .NET 4.5

Nor can a .NET project assume it will run on any particular version of Windows. It should work just as well on Windows 8 as on Windows 10.

So interpret 255.255.255.255 as "any version".



来源:https://stackoverflow.com/questions/10411168/what-does-version-255-255-255-255-for-winmd-files-indicate

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