0
是否可以將Assembly版本加載到純XAML代碼中? 我發現這個在這裏:在Pure XAML中獲取組件版本GetExecutingAssembly
但它總是返回4.0.0
<TextBlock xmlns:ref="clr-namespace:System.Reflection;assembly=mscorlib">
<TextBlock.Text>
<Binding Path="Version">
<Binding.Source>
<ObjectDataProvider MethodName="GetName">
<ObjectDataProvider.ObjectInstance>
<ObjectDataProvider MethodName="GetExecutingAssembly"
ObjectType="{x:Type ref:Assembly}" />
</ObjectDataProvider.ObjectInstance>
</ObjectDataProvider>
</Binding.Source>
</Binding>
</TextBlock.Text>
</TextBlock>
然後我想這在這裏:(如果應用程序運行它完美的作品)
<TextBlock Grid.Row ="0" Grid.Column="0" xmlns:ref="clr-namespace:System.Reflection;assembly=mscorlib" xmlns:sys="clr-namespace:System;assembly=mscorlib">
<TextBlock.Text>
<Binding Path="Version">
<Binding.Source>
<ObjectDataProvider MethodName="GetName">
<ObjectDataProvider.ObjectInstance>
<ObjectDataProvider MethodName="ReflectionOnlyLoadFrom"
ObjectType="{x:Type ref:Assembly}">
<ObjectDataProvider.MethodParameters>
<sys:String>.\Modules\Myassembly.dll</sys:String>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</ObjectDataProvider.ObjectInstance>
</ObjectDataProvider>
</Binding.Source>
</Binding>
</TextBlock.Text>
</TextBlock>
但是現在設計者說(想要在System32中找到Assembly)
Could not load file or assembly 'file:///C:\Windows\system32\Modules\MyAssembly.dll' or one of its dependencies. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
感謝LightBulb審查佈局 – Seppl