简体   繁体   中英

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). 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:

  <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:

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. 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. Not very sure, but I think it was causing the previously built dll to be loaded in runtime.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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