简体   繁体   English

根据平台类型构建项目

[英]Building projects based on platform type

I have my project that can build for x64, x86 and ARM (WinRT) referencing to a platform specific library (Also builds on x64, x86 and ARM). 我有一个可以针对x64,x86和ARM(WinRT)构建的项目,引用了平台特定的库(也基于x64,x86和ARM构建)。 In order to conditionally build the platform specific DLL, I edited the .csproj file manually to have the elements for those platform specific DLL as below: 为了有条件地构建特定于平台的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>

Now, I am able to compile my solution. 现在,我可以编译我的解决方案了。 But, in runtime it gives error while loading the platform specific DLLs (PortablePlatform.dll) and the error is thrown in return statement of GetXamlType in xamlTypeInfo.g.cs: 但是,在运行时,它会在加载平台特定的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);
        }

Below is the error stack: An exception of type 'System.IO.FileNotFoundException' occurred in .WinRT.App.exe but was not handled in user code Additional information: Could not load file or assembly 'PortablePlatform, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 下面是错误堆栈: .WinRT.App.exe中发生类型'System.IO.FileNotFoundException'的异常,但未在用户代码中处理。其他信息:无法加载文件或程序集'PortablePlatform,Version = 0.1.0.0,文化=中性,PublicKeyToken =空”或其依赖项之一。 The system cannot find the file specified. 该系统找不到指定的文件。

I was able to figure out the issue. 我能够找出问题所在。 I had to remove <Private>True/False</Private> from <Reference> element in csproj file. 我必须从csproj文件中的<Reference>元素中删除<Private>True/False</Private> Not very sure, but I think it was causing the previously built dll to be loaded in runtime. 不太确定,但是我认为这导致先前构建的dll在运行时加载。

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

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