从.NET加载WinRT程序集

6
如何按名称加载WinRT程序集? 当我执行以下操作时:
```csharp Assembly.Load("MyWinRtComponent, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null") ```
它会抛出异常:未能找到程序集 'MyWinRtComponent'。
(new TextBlock()).GetType().GetTypeInfo().Assembly

然后我获取了 Windows.UI.Xaml.Controls 的程序集。但是如果我尝试通过名称加载它:

var name = new AssemblyName { 
   Name = "Windows.UI.Xaml.Controls", 
   Version = new Version(255, 255, 255, 255), 
   ContentType = AssemblyContentType.WindowsRuntime 
};

然后它显示“操作不支持”。即使我这样做,也会出现这种情况:
var name = (new TextBlock()).GetType().GetTypeInfo().Assembly.GetName();
Assembly.Load(name);

我如何通过名称获取WinRT程序集?


我明白了,谢谢。即使像第三个例子一样包含了所有信息,问题仍然没有解决... - Jules
AssemblyName实际上不支持Culture和PublicKeyToken吗?也许在Visual Studio的开发者预览版中有所不同? - Jules
1个回答

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接