繁体   English   中英

根据平台类型构建项目

[英]Building projects based on platform type

我有一个可以针对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)时出现错误,并且在xamlTypeInfo.g.cs中的GetXamlType的return语句中引发该错误:

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);
        }

下面是错误堆栈: .WinRT.App.exe中发生类型'System.IO.FileNotFoundException'的异常,但未在用户代码中处理。其他信息:无法加载文件或程序集'PortablePlatform,Version = 0.1.0.0,文化=中性,PublicKeyToken =空”或其依赖项之一。 该系统找不到指定的文件。

我能够找出问题所在。 我必须从csproj文件中的<Reference>元素中删除<Private>True/False</Private> 不太确定,但是我认为这导致先前构建的dll在运行时加载。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM