Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application fails to start using System.Runtime.Experimental 6.0.1 with .NET 6.0.2 #65018

Closed
martincostello opened this issue Feb 8, 2022 · 17 comments
Assignees
Milestone

Comments

@martincostello
Copy link
Member

Description

Attempting to run a self-contained deployment of a ASP.NET Core application using the .NET 6.0.102 SDK with System.Runtime.Experimental 6.0.1 fails with the following error when run.

Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=6.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'System.Runtime, Version=6.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

This appears to be related to the fix for #62840 in #63525.

This can be worked around by using version 6.0.2-mauipre.1.22054.8 of the package so that the version numbers align.

Reproduction Steps

Clone martincostello/adventofcode@60fbfa4 and then run the following commands:

.\build.ps1 -SkipTests -Runtime win10-x64
cd .\artifacts\publish
.\AdventOfCode.Site.exe

Expected behavior

The ASP.NET Core application starts using the NuGet package that shipped today as part of the .NET 6.0.2 release, rather than requiring the use of a prerelease package for MAUI.

Actual behavior

The ASP.NET Core application fails to start.

> .\AdventOfCode.Site.exe
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=6.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'System.Runtime, Version=6.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Regression?

Compared to .NET 6.0.0, yes.

.NET 6.0.1 was broken without a workaround being applied.

Known Workarounds

Use the 6.0.2-mauipre.1.22054.8 version of the System.Runtime.Experimental package.

Configuration

> dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.102
 Commit:    02d5242ed7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.102\

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Feb 8, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost
Copy link

ghost commented Feb 8, 2022

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Attempting to run a self-contained deployment of a ASP.NET Core application using the .NET 6.0.102 SDK with System.Runtime.Experimental 6.0.1 fails with the following error when run.

Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=6.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'System.Runtime, Version=6.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

This appears to be related to the fix for #62840 in #63525.

This can be worked around by using version 6.0.2-mauipre.1.22054.8 of the package so that the version numbers align.

Reproduction Steps

Clone martincostello/adventofcode@60fbfa4 and then run the following commands:

.\build.ps1 -SkipTests -Runtime win10-x64
cd .\artifacts\publish
.\AdventOfCode.Site.exe

Expected behavior

The ASP.NET Core application starts using the NuGet package that shipped today as part of the .NET 6.0.2 release, rather than requiring the use of a prerelease package for MAUI.

Actual behavior

The ASP.NET Core application fails to start.

> .\AdventOfCode.Site.exe
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=6.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'System.Runtime, Version=6.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Regression?

Compared to .NET 6.0.0, yes.

.NET 6.0.1 was broken without a workaround being applied.

Known Workarounds

Use the 6.0.2-mauipre.1.22054.8 version of the System.Runtime.Experimental package.

Configuration

> dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.102
 Commit:    02d5242ed7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.102\

Other information

No response

Author: martincostello
Assignees: -
Labels:

area-System.Runtime, untriaged

Milestone: -

@absid89
Copy link

absid89 commented Feb 9, 2022

same error on winforms:
after Visual Studio 17.0.6 update .net SDK updated to 6.0.2

client with 6.0.1 runtime installed, launched the app and got a crash
runtime601

client without runtime, got friendly error with link to download .net 6 runtime
without_runtime

@EatonZ
Copy link
Contributor

EatonZ commented Feb 9, 2022

Related

@tannergooding
Copy link
Member

CC. @safern, @ericstj

@ericstj
Copy link
Member

ericstj commented Feb 9, 2022

System.Runtime, Version=6.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

The problem here is that the AssemblyVersion should not change. Can we double check if the package has this change? If it does we need to fix that -- only FileVersion can change for the reference assembly in servicing. In the meantime, you can workaround this by using the 6.0.0 version of System.Runtime.Experimental and the workaround from here #62840 (comment)

@absid89 -- looks like you might be hitting something different. Care to open a seperate issue and include a full set of repro steps?

@ericstj ericstj added this to the 6.0.x milestone Feb 9, 2022
@martincostello
Copy link
Member Author

Looking at NuGet package explorer, the version in the assembly is indeed 6.0.0.1.

image

@ericstj
Copy link
Member

ericstj commented Feb 9, 2022

Yes, that agrees with what you're observing. I was able to see what's happening. This is what's changing it:

<AssemblyVersion Condition="'$(_AssemblyInTargetingPack)' != 'true'">$(MajorVersion).$(MinorVersion).0.$(ServicingVersion)</AssemblyVersion>

We aren't hitting this for the non-experimental System.Runtime (or other refpack assemblies) because we never set ServicingVersion for them, but we did set it for this reference project.

@safern
Copy link
Member

safern commented Feb 9, 2022

I think we can add a condition to disable automatically bumping the AssemblyVersion when a package is not in the targeting pack and set that flag to true on System.Runtime.Experimental.

@ericstj
Copy link
Member

ericstj commented Feb 9, 2022

Do you know why we use IsNetCoreAppSrc here

<_AssemblyInTargetingPack Condition="('$(IsNETCoreAppSrc)' == 'true' or '$(_IsAspNetCoreApp)' == 'true' or '$(_IsWindowsDesktopApp)' == 'true') and '$(TargetFrameworkIdentifier)' != '.NETFramework'">true</_AssemblyInTargetingPack>

That's only defined for a src project and not ref

Maybe we could use '$(IsNETCoreAppSrc)' == 'true' or '$(IsNETCoreAppRef)' == 'true' or create a property that corresponds to the assembly lookup (eg: IsNETCoreApp)

<IsNETCoreAppSrc Condition="'$(IsNETCoreAppSrc)' == '' and
'$(IsSourceProject)' == 'true' and
$(NetCoreAppLibrary.Contains('$(AssemblyName);'))">true</IsNETCoreAppSrc>
<IsNETCoreAppRef Condition="'$(IsNETCoreAppRef)' == '' and
'$(IsReferenceAssembly)' == 'true' and
$(NetCoreAppLibrary.Contains('$(AssemblyName);'))">true</IsNETCoreAppRef>

That would have been true for this assembly, since it's named System.Runtime

@tannergooding
Copy link
Member

Is there something we can do to help test/validate/catch these issues before shipping?

@safern
Copy link
Member

safern commented Feb 9, 2022

Do you know why we use IsNetCoreAppSrc here

I believe the wrong assumption was made? https://github.com/dotnet/runtime/pull/57158/files#r687259631

I think this is because we never had cases like the System.Runtime.Experimental scenario where we ship a ref only package and the implementation is inbox.

I think that would be a better solution than what I proposed above.

Is there something we can do to help test/validate/catch these issues before shipping?

That'd be hard as all these lists are "static" and we could've made the wrong assumption when testing (that we only need to check for IsNetCoreAppSrc.

@ericstj
Copy link
Member

ericstj commented Feb 9, 2022

Related #63467

Is there something we can do to help test/validate/catch these issues before shipping?

API Compat could have caught it.

<!-- Pull type forwards from the experimental ref assembly so we only need to maintain a single src project -->
<ContractProject>$(LibrariesProjectRoot)System.Runtime.Experimental\ref\System.Runtime.Experimental.csproj</ContractProject>

That would have caught this since inbox S.R wouldn't have satisfied the ref. Perhaps APICompat is not honoring assembly version? I know we made changes in the new API compat to do that. https://github.com/dotnet/sdk/blob/aecf5b5cc13e93dd8c377c502490bcf714565a5a/src/Compatibility/Microsoft.DotNet.ApiCompatibility/Rules/AssemblyIdentityMustMatch.cs#L57-L59

Another thing we often ask folks to do is verify the end-to-end scenario in the final builds. We usually ask folks contributing servicing changes to adhoc validate the end-to-end scenario in final bits to ensure that its fixed. We should definitely have @tannergooding help with this when we fix it again.

Since the current package 6.0.1 doesn't fix the issue, I recommend we just unlist and reactivate the original bug.

@absid89
Copy link

absid89 commented Feb 10, 2022

@absid89 -- looks like you might be hitting something different. Care to open a seperate issue and include a full set of repro steps?

sorry i had to write in the winforms thread

martincostello added a commit to martincostello/adventofcode that referenced this issue Feb 10, 2022
Revert to the 6.0.0 release of System.Runtime.Experimental and re-apply the workaround until dotnet/runtime#65018 is resolved.
@tannergooding tannergooding removed the untriaged New issue has not been triaged by the area owner label Feb 14, 2022
@teo-tsirpanis
Copy link
Contributor

Fixed in #65166.

@safern
Copy link
Member

safern commented Feb 15, 2022

We still need to make sure the new package is created for 6.0.4 release, so we need to add ServicingVersion=2 and GeneratePackageOnBuild=true to the System.Runtime.Experimental.csproj in the release/6.0 branch, so we should keep this open until that PR is created and merged.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 22, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 8, 2022
@teo-tsirpanis
Copy link
Contributor

System.Runtime.Experimental 6.0.2 has been released, I ran a small repro that failed with (the now-unlisted) 6.0.1 and works with 6.0.2, and #65733 should have closed this issue but for some reason didn't. So I'm going to close it myself. Feel free to provide feedback if anything went wrong.

@ghost ghost locked as resolved and limited conversation to collaborators Jul 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants