CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.89k stars 1.37k forks source link

Microsoft.Toolkit.Uwp.Services : System.TypeLoadException / on Exception thrown: 'System.IO.FileLoadException' in mscorlib.ni.dll #540

Closed mfe- closed 7 years ago

mfe- commented 8 years ago

Greetings,

when creating a blank uwp app with the dependencies Prism, Unitry it will throw at starting or closing the app a 'System.IO.FileLoadException' in mscorlib.ni.dll or a System.TypeLoadException.

Steps to reproduce:

  1. Create new blank uwp project.
  2. Install dependencies

{ "dependencies": { "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0", "Microsoft.Toolkit.Uwp.Services": "1.1.0", "Prism.Unity": "6.2.0", "Prism.Windows": "6.0.2" }, "frameworks": { "uap10.0": {} }, "runtimes": { "win10-arm": {}, "win10-arm-aot": {}, "win10-x86": {}, "win10-x86-aot": {}, "win10-x64": {}, "win10-x64-aot": {} } }

  1. My App.xaml.cs

sealed partial class App : PrismUnityApplication { protected override UIElement CreateShell(Frame rootFrame) { return new MainPage(); } protected override Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args) { return Task.FromResult<object>(null); } }

Any ideas what causes this?

hermitdave commented 8 years ago

@mfe- fancy attaching a repro ?

mfe- commented 7 years ago

I created the repo https://github.com/mfe-/App4 .

  1. Start the app
  2. Close the app
  3. When closing it will throw: Exception thrown: 'System.IO.FileLoadException' in mscorlib.ni.dll Exception thrown: 'System.IO.FileLoadException' in mscorlib.ni.dll The program '[12464] App4.exe: Program Trace' has exited with code 0 (0x0). The program '[12464] App4.exe' has exited with code -1073741189 (0xc000027b).
hermitdave commented 7 years ago

@mfe- I downloaded your solution and first thing I did was removed toolkit services and then ran the debug version of the app. on closing the app still crashes.. so not something to do with toolkit services

hermitdave commented 7 years ago

Having done that I upgraded the WindowsUniversalPlatform to 5.2.2 and that stopped the crashes.

Adding uwp toolkit services now and running it does not generate new crashes either on close

mfe- commented 7 years ago

Thanks for the upgrade hint @hermitdave

At the moment I'm note able to reproduce the TypeLoadException with a new created uwp app project. Anyway in my current app I still get the TypeLoadException .

I added System.Diagnostics.Debug.WriteLine(fullName); (only for debugging) to the XamlTypeInfo.g.cs

     public global::Windows.UI.Xaml.Markup.IXamlType GetXamlType(string fullName)
        {
            System.Diagnostics.Debug.WriteLine(fullName);
            if (_provider == null)
            {
                _provider = new global::Tetromino.Tetromino_XamlTypeInfo.XamlTypeInfoProvider();
            }

            return _provider.GetXamlTypeByName(fullName);
        }

I could trace the following:

'Tetromino.exe' (CoreCLR: DefaultDomain): Loaded 'C:\Program Files\WindowsApps\Microsoft.NET.CoreRuntime.1.0_1.0.23819.0_x86__8wekyb3d8bbwe\mscorlib.ni.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\entrypoint\Tetromino.exe'. Symbols loaded. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\System.Runtime.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\WinMetadata\Windows.winmd'. Module was built without symbols. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\System.Runtime.InteropServices.WindowsRuntime.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\Prism.Unity.Windows.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\Prism.Windows.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\Prism.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\System.Threading.Tasks.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\System.Globalization.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\System.Resources.ResourceManager.dll'. Module was built without symbols. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\System.Reflection.dll'. Module was built without symbols. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\System.Runtime.WindowsRuntime.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\System.Diagnostics.Debug.dll'. Cannot find or open the PDB file. Prism.Unity.Windows.PrismUnityApplication 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\System.Collections.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\Microsoft.Practices.Unity.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\System.Runtime.WindowsRuntime.UI.Xaml.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\Get.the.solution.ui.dll'. Symbols loaded. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\System.ObjectModel.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\Microsoft.Xaml.Interactivity.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\Microsoft.Xaml.Interactions.dll'. Cannot find or open the PDB file. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\Tetromino.ui.dll'. Symbols loaded. 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\Microsoft.Toolkit.Uwp.UI.Controls.dll'. Cannot find or open the PDB file. Windows.Foundation.IReference1 'Tetromino.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Tetromino\UWP\Tetromino\bin\x86\Debug\AppX\winsdkfb.winmd'. Module was built without symbols. Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Automation.Peers.AutomationLandmarkType> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Controls.Primitives.PlacementMode> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.FontEastAsianLanguage> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.FontFraction> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.FontNumeralStyle> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Controls.ScrollBarVisibility> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Controls.ScrollBarVisibility> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Controls.ZoomMode> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Automation.Peers.AccessibilityView> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Automation.Peers.AutomationLiveSetting> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.FontCapitals> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.FontEastAsianWidths> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.FontNumeralAlignment> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.FontVariants> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Controls.ScrollMode> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Controls.ScrollMode> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Controls.VirtualizationMode> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Automation.Peers.AutomationLandmarkType> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Controls.Primitives.PlacementMode> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.FontEastAsianLanguage> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.FontFraction> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.FontNumeralStyle> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Controls.ScrollBarVisibility> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Controls.ScrollBarVisibility> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1<Windows.UI.Xaml.Controls.ZoomMode> Exception thrown: 'System.TypeLoadException' in Tetromino.exe Windows.Foundation.IReference1 Exception thrown: 'System.TypeLoadException' in Tetromino.exe`

When removing the UWPCommunityToolkit.Service extension I can run my app.

My current project.json

  "dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
    "Microsoft.Toolkit.Uwp": "1.1.0",
    "Microsoft.Toolkit.Uwp.Services": "1.1.0",
    "Microsoft.Toolkit.Uwp.UI.Animations": "1.1.0",
    "Microsoft.Toolkit.Uwp.UI.Controls": "1.1.0",
    "Prism.Unity": "6.2.0",
    "Prism.Windows": "6.0.2"
  },
  "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

Any ideas how I can get further details about the TypeLoadException issue?

hermitdave commented 7 years ago

Don't know what i can suggest next. Fancy sharing your repo so i can take a look?

ScottIsAFool commented 7 years ago

@mfe- when you get the exception, is it taking you into the unhandled exception bit of code? If so, you should be able to expand out the exception info and it should tell you what type it is (i think).

mfe- commented 7 years ago

@ScottIsAFool The UnhandledException of app.g.i.cs will not be hit :(

hermitdave commented 7 years ago

No even in the repo the exception was not getting caught in UnhandledException.. I think it was Win32 Exception

bartlannoeye commented 7 years ago

@mfe- if your problem still exists, try using the pre-release packages (referencing UWP 5.2.2) of Prism.Unity and Prism.Windows to rule out that as well. Pushed them 17d ago to https://www.myget.org/F/prismprerelease/api/v3/index.json

"Prism.Unity": "6.2.1-pre01",
"Prism.Windows": "6.1.0-pre01"
mfe- commented 7 years ago

Thanks for your suggestion @bartlannoeye. I upgraded to the prelease version but something seems to be wrong.

I'll get (see also here) Error CS0012 The type 'BindableBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'Prism, Version=6.2.0.0, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59'.

bartlannoeye commented 7 years ago

Mm Prism.Windows has a dependency on Prism.Core 6.2.0, so it should find that assembly. Try adding Prism.Core explicitly and I'll have a look into it asap. Might be because we dropped signing for UWP and kept it for the other platforms. I've tested the prerelease packages before, just not sure if I did add the Prism.Core explicitly.

mfe- commented 7 years ago

@bartlannoeye Done.

mfe- commented 7 years ago

@hermitdave Unfortunately, I’m currently unable to publish the source code on github due to security and privacy reasons. Can I somehow send you an unversioned code state (twitter DM, email, ...)?

IbraheemOsama commented 7 years ago

@mfe- you can upload the repo to OneDrive or something and share the link here so we can investigate.

deltakosh commented 7 years ago

I guess you can even drag'n'drop some zipped code here

mfe- commented 7 years ago

Since the beginning of the issue, I was continuing my work on the project without the Microsoft.Toolkit.Uwp.Services Reference. Yesterday I added the Microsoft.Toolkit.Uwp.Services Reference and wow - no LoadException occurred. To determine the reason why the Exception was thrown I checked out some older commits. I removed and added XAML/C# Code to reproduce the issue. Sometimes I was able to reproduce the issue and sometimes not. Since the newest version of my app is working together with the Microsoft.Toolkit.Uwp.Services I don't want to invest more time on this issue. I'm sorry for the trouble guys, and thanks so much for your help! If the error occurs, I'll reopen this issue.

deltakosh commented 7 years ago

Sounds like a good plan:)