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

[dotnet-sdk-9.0.100-preview.7.24379.15] WolvenKit app gets an error "Unable to load one or more of the requested types. Could not load file or assembly 'System.Runtime.Serialization.Formatters, ...'" #9498

Closed
Junjun-zhao opened this issue Aug 1, 2024 · 5 comments

Comments

@Junjun-zhao
Copy link
Member

Junjun-zhao commented Aug 1, 2024

Description

When run the 3rd party application with the latest .NET 9 build "dotnet-sdk-9.0.100-preview.7.24379.15", it throws below exception:

Could not load file or assembly 'System.Runtime.Serialization.Formatters, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

Reproduction Steps

Minimal Repro Steps:
1.Create a WPF project.
2. Add below code in MainWindow.xaml.cs file:

public MainWindow()
{
    InitializeComponent();
    var test = new ObservableCollection<string>(AppDomain.CurrentDomain.GetAssemblies().SelectMany(s => s.GetTypes()).Select(x => x.Name));
}
  1. Build the project.
  2. Update the runtime.config file to let the project run against with 9.0.100-preview.7.24379.15:
 "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "9.0.0-preview.7.24376.15"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "9.0.0-preview.7.24379.3"
      }
    ],
  1. Launch the app.

Expected behavior

App launch successfully.

Actual behavior

App launch failed with following error:

Unable to load one or more of the requested types.
Could not load file or assembly 'System.Runtime.Serialization.Formatters, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

Stack Trace:
 at System.Reflection.RuntimeModule.GetDefinedTypes()
   at System.Reflection.RuntimeModule.GetTypes()
   at LoadTypeExceptionDemo.MainWindow.<>c.<.ctor>b__0_0(Assembly s) in E:\Demos\LoadTypeExceptionDemo\LoadTypeExceptionDemo\MainWindow.xaml.cs:line 23
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.IteratorSelectIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Collections.ObjectModel.ObservableCollection`1..ctor(IEnumerable`1 collection)
   at LoadTypeExceptionDemo.MainWindow..ctor() in E:\Demos\LoadTypeExceptionDemo\LoadTypeExceptionDemo\MainWindow.xaml.cs:line 23
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)

Regression?

Yes
Verify Scenarios:
1). Windows 10 21H2 AMD64 + dotnet-sdk-6.0.425:Pass
2). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.303:Pass
3). Windows 10 21H2 AMD64 +dotnet-sdk-9.0.100-preview.6.24317.13: Pass
4). Windows 10 21H2 AMD64 +dotnet-sdk-9.0.100-preview.7.24379.15: Fail

Known Workarounds

Steps with workaround:

  1. Download and Extract System.Runtime.Serialization.Formatters nuget package.
  2. Copy the System.Runtime.Serialization.Formatters.dll to application folder.
  3. Update WolvenKit.runtimeconfig.json file:
 "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "9.0.0-preview.7.24376.15"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "9.0.0-preview.7.24379.3"
      }
    ],

  1. Add following content in WolvenKit.deps.json file:
"targets": {
    ".NETCoreApp,Version=v6.0": {},
    ".NETCoreApp,Version=v6.0/win-x64": {
      "WolvenKit/8.8.1": {
        "dependencies": {
          ......
          "System.Runtime.Serialization.Formatters": "9.0.0-preview.6.24327.7"
        },
        "runtime": {
          "WolvenKit.dll": {}
        }
      },
    "System.Runtime.Serialization.Formatters/9.0.0-preview.6.24327.7": {
        "runtime": {
          "lib/net8.0/System.Runtime.Serialization.Formatters.dll": {
            "assemblyVersion": "9.0.0.0",
            "fileVersion": "9.0.24.32707"
          }
        }
      },
  ......
"libraries": {
      "System.Runtime.Serialization.Formatters/9.0.0-preview.6.24327.7": {
         "type": "package",
         "serviceable": true,
         "sha512": "sha512-5S1E7KF/RzcZoRQ27BW3f6HX6zihRVz2utacaUWw4ilos2L4435PPn4rn8c+6Ltp4isTukBnw9K+FZCQHwCVPA==",
         "path": "system.runtime.serialization.formatters/9.0.0-preview.6.24327.7",
         "hashPath": "system.runtime.serialization.formatters.9.0.0-preview.6.24327.7.nupkg.sha512"
    },
    ......

​5. Run the app with the App Repro steps above, it will work.

Impact

No response

Configuration

Application Name: WolvenKit
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-9.0.100-preview.7.24379.15
App Source or App checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2176393
Github Link:
https://github.com/WolvenKit/WolvenKit

Other information

App Repro steps:
The machine has dotnet-sdk-9.0.100-preview.7.24379.15 installed.

  1. Copy SourceShare\WolvenKit\App\WolvenKit and SourceShare/WolvenKit/AppRequiredFiles/test1) to local machine.
  2. Update the WolvenKit.runtimeconfig.json file to let the app run against with 9.0.100-preview.7.24379.15:
 "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "9.0.0-preview.7.24376.15"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "9.0.0-preview.7.24379.3"
      }
    ],
  1. Launch WolvenKit.exe under WolvenKit folder.
  2. Click Cancel button for WolvenKit.Installer pop up window.
  3. Click Cancel button for WolvenKit update window if it pops up.
  4. Click Close button for First Setup pop up window.
  5. Maximize app.
  6. Click Open a project.
  7. Select test1.cpmodproj file from test1 folder and Open it.
  8. Double-click 1.aiarch item from left panel.
  9. Click Create Handle button on right panel.

Expected Result:
Create Class window will pop up.
image

Actual Result:
Create Class window not show and below error is displayed in Log window.
image

Error in Log window:

[8/1/2024 1:32:51 PM] Unhandled exception in WolvenKit v8.7.0.0
[8/1/2024 1:32:51 PM] Message: Unable to load one or more of the requested types.
Could not load file or assembly 'System.Runtime.Serialization.Formatters, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Source: System.Private.CoreLib
StackTrace:    at System.Reflection.RuntimeModule.GetDefinedTypes()
   at System.Reflection.RuntimeModule.GetTypes()
   at WolvenKit.ViewModels.Shell.ChunkViewModel.<>c.<ExecuteAddHandle>b__161_0(Assembly s) in E:\AppsSourceCode\WolvenKit\WolvenKit.App\ViewModels\Shell\ChunkViewModel.cs:line 1310
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.IEnumerableWhereSelectIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Collections.ObjectModel.ObservableCollection`1..ctor(IEnumerable`1 collection)
   at WolvenKit.ViewModels.Shell.ChunkViewModel.ExecuteAddHandle() in E:\AppsSourceCode\WolvenKit\WolvenKit.App\ViewModels\Shell\ChunkViewModel.cs:line 1310
   at Prism.Commands.DelegateCommand.Execute()
   at Prism.Commands.DelegateCommand.Execute(Object parameter)
   at Prism.Commands.DelegateCommandBase.System.Windows.Input.ICommand.Execute(Object parameter)
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Findings:

@dotnet-actwx-bot @dotnet/compat

@Junjun-zhao
Copy link
Member Author

Junjun-zhao commented Aug 1, 2024

@rchauhan18 This is a new BinaryFormatter issue for WolvenKit app. Could you please help look into it? There was a runtime bug which blocked the test and fixed on the latest build. Then this issue is found during the test execution.

@rchauhan18
Copy link
Contributor

rchauhan18 commented Aug 1, 2024

@Junjun-zhao Can you please try to repro the issue in new release [9.0.0-rc.1.24381.1]?
There are few changes added to it, and it might work after it.

@Junjun-zhao
Copy link
Member Author

@rchauhan18 We verified this on build 9.0.100-rc.1.24381.10, this issue has been fixed. Thanks.

@Junjun-zhao
Copy link
Member Author

Verified this issue on build dotnet-sdk-9.0.100-preview.7.24402.8, it has been fixed.

@pchaurasia14
Copy link
Member

Closing as fixed

@github-actions github-actions bot locked and limited conversation to collaborators Sep 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants