corert icon indicating copy to clipboard operation
corert copied to clipboard

EXEC : error : [TEMPORARY EXCEPTION MESSAGE] FileLoadErrorGeneric: System.Windows.Forms

Open szhaomsft opened this issue 6 years ago • 6 comments

seems like a regression

i am compiling a dotnet core 2.1 console app. why it looks for system windows forms now?

using official build <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-27414-02" /> <PackageReference Include="runtime.linux-x64.Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-27414-02" /> <PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-27414-02" />

while an older build has no such error

<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-27322-02" />
<PackageReference Include="runtime.linux-x64.Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-27322-02" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-27322-02" />

szhaomsft avatar Feb 17 '19 06:02 szhaomsft

the new build I used that has the issue

<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-27414-02" />
<PackageReference Include="runtime.linux-x64.Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-27414-02" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-27414-02" />

szhaomsft avatar Feb 17 '19 06:02 szhaomsft

any fix?

szhaomsft avatar Feb 20 '19 09:02 szhaomsft

My only guess would be that after #6820 we're compiling code that we didn't compile before that references Windows.Forms. The compiler or the build targets definitely don't inject references to Windows.Forms.

Try adding <RootAllApplicationAssemblies>false</RootAllApplicationAssemblies> to one of the PropertyGroups in your CSPROJ to see if it makes the message disappear.

MichalStrehovsky avatar Feb 20 '19 10:02 MichalStrehovsky

Still happens in 1.0.0-alpha-29228-02 RootAllApplicationAssemblies didn't help

Compiling as dotnet publish /p:NativeLib=Shared -r win-x64 -c release

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-29228-02" />
  </ItemGroup>
  
  <PropertyGroup>
    <RootAllApplicationAssemblies>false</RootAllApplicationAssemblies>
  </PropertyGroup>
</Project>

kamyker avatar Sep 03 '20 05:09 kamyker

Hmm... Interesting, my vs crashed, restarted and finally it started building. I guess new Microsoft.DotNet.ILCompiler package got pulled.

kamyker avatar Sep 03 '20 05:09 kamyker

Oh even more interesting, when I have 2 instances of Visual Studio running - one with Unity project, other one with this library then the problem error occurs.

kamyker avatar Sep 03 '20 05:09 kamyker