question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[5.0.100-rc.1.20454.5] Build/Launch NuGetPackageExplorer failed due to exception "Could not find type 'System.Runtime.Versioning.MinimumOSPlatformAttribute'"

See original GitHub issue

Application Name: NuGetPackageExplorer OS: Windows 10 RS5 CPU: X64 .NET Build Number: 5.0.100-rc.1.20454.5 App Source on GitHub link: https://github.com/NuGetPackageExplorer/NuGetPackageExplorer (this source is new, we test old version ) (We found this bug when we are trying to upgrade the NuGetPackageExplorer app, and build with latest RC1 SDK.)

Verify Scenarios: 1). Windows 10 RS5 X64 + .NET Core SDK build 5.0.100-rc.1.20454.5: Fail 2). Windows 10 RS5 X64 + .NET Core SDK build 5.0.100-preview.8.20417.9-win-x64: Pass

Repro Machine: See in bug: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1198579/

Repro steps: open command prompt window. Run “cd C:\Users\Appcompat\Documents\NuGetPackageExplorer” command, navigate to the app path. Run “dotnet NuGetPackageExplorer.dll” to lanuch the app. Expected Result: Open NuGetPackageExplorer successful. Actual Result: Unable to lanuch NuGetPackageExplorer

Exception Log:

Unhandled exception. System.TypeLoadException: Could not load type 'System.Runtime.Versioning.MinimumOSPlatformAttribute' from assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctorWithParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
   at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
   at System.Reflection.CustomAttributeExtensions.GetCustomAttributes[T](Assembly element)
   at NuGetPe.Utility.AppVersionTelemetryInitializer..ctor() in C:\Users\Appcompat\Downloads\NuGetPackageExplorer-5.8.2\NuGetPackageExplorer-5.8.2\Core\Utility\AppVersionTelemetryInitializer.cs:line 19
   at NuGetPe.DiagnosticsClient.Initialize() in C:\Users\Appcompat\Downloads\NuGetPackageExplorer-5.8.2\NuGetPackageExplorer-5.8.2\Core\Utility\DiagnosticsClient.cs:line 17
   at PackageExplorer.App..ctor() in C:\Users\Appcompat\Downloads\NuGetPackageExplorer-5.8.2\NuGetPackageExplorer-5.8.2\PackageExplorer\App.xaml.cs:line 30
   at PackageExplorer.App.Main()

Findings : We search the this change on Github and found this class name is changed from MinimumOSPlatformAttribute to SupportedOSPlatformAttribute: https://github.com/dotnet/sdk/pull/12775

We also created a simple reproduce project: https://github.com/jiangzeng01/MinimumOSPlatformAttributeExceptionSample.git

MinimumOSPlatformAttribute OSPlatform = new MinimumOSPlatformAttribute("win-x64");
Console.WriteLine(OSPlatform.PlatformName);
Console.WriteLine("Hello World!");

When we set sdk version as “5.0.100-preview.8.20417.9” in global.json file, the project can be built and run successful:

{
  "sdk": {
    "version": "5.0.100-preview.8.20417.9"
  }
}

If we change the sdk version to “5.0.100-rc.1.20454.5”, we will get exception when building the app.

{
  "sdk": {
    "version": "5.0.100-rc.1.20454.5"
  }
}

Exception from the sample code above :

C:\Users\Appcompat\source\repos\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample\Program.cs(10,13): error CS0246: The type or namespace name 'MinimumOSPlatformAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Appcompat\source\repos\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample.csproj]
C:\Users\Appcompat\source\repos\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample\Program.cs(10,57): error CS0246: The type or namespace name 'MinimumOSPlatformAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Appcompat\source\repos\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample.csproj]

cc @dotnet-actwx-bot

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jeffhandleycommented, Sep 10, 2020

@jiangzeng01 We did not yet write it, since we don’t typically produce breaking change documents between preview releases. But due to the impact this has caused, I’ve labeled https://github.com/dotnet/runtime/issues/40360 with needs-breaking-change-doc-created to capture that task and we will get it written very soon.

0reactions
jiangzeng01commented, Sep 15, 2020

Update breaking change document: https://github.com/dotnet/docs/issues/20635

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue #40360 · dotnet/runtime · GitHub
[5.0.100-rc.1.20454.5] Build/Launch NuGetPackageExplorer failed due to exception "Could not find type 'System.Runtime.Versioning.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found