我的项目可以为x64、x86和ARM (WinRT)构建,引用特定于平台的库(还构建在x64、x86和ARM上)。为了有条件地构建平台特定的DLL,我手动编辑了.csproj文件,使这些平台特定DLL的元素如下所示:
<ItemGroup Condition="'$(Platform)' == 'x86'">
<Reference Include="PortablePlatform">
<HintPath>..\..\packages\LibraryName\x86\PortablePlatform.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(Platform)' == 'x64'">
<Reference Include="PortablePlatform">
<HintPath>..\..\packages\LibraryName\x64\PortablePlatform.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(Platform)' == 'ARM'">
<Reference Include="PortablePlatform">
<HintPath>..\..\packages\LibraryName\ARM\PortablePlatform.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>现在,我能够编译我的解决方案。但是,在运行时,它在加载平台特定的DLL (PortablePlatform.dll)时会出现错误,并且在GetXamlType在xamlTypeInfo.g.cs中的返回语句中引发错误:
public global::Windows.UI.Xaml.Markup.IXamlType GetXamlType(global::System.Type type)
{
if(_provider == null)
{
_provider = new global::<ABC>_App_XamlTypeInfo.XamlTypeInfoProvider();
}
return _provider.GetXamlTypeByType(type);
}下面是错误堆栈:类型'System.IO.FileNotFoundException‘的异常发生在.WinRT.App.exe中,但未在用户代码中处理:无法加载文件或程序集'PortablePlatform、Version=0.1.0.0、Culture=neutral、PublicKeyToken=null’或其依赖项之一。系统找不到指定的文件。
发布于 2015-01-20 05:51:23
我解决了这个问题。我不得不从csproj文件中的<Private>True/False</Private>元素中删除<Reference>。不太确定,但我认为这是导致在运行时加载以前构建的dll的原因。
https://stackoverflow.com/questions/28020867
复制相似问题