[Bug] An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in System.Private.CoreLib.dll
See original GitHub issueDescription
After getting a ‘Congratulations, everything looks great’ from MAUI check and going file -> new -> .NET MAUI App in VS 16.11.0 Preview 1.0, project will not run due to the error message An unhandled exception of type System.Reflection.TargetInvocationException occurred in System.Private.CoreLib.dll Exception has been thrown by the target of an invocation.
Steps to Reproduce
- Install VS Preview 16.11.0 Preview 1.0
- Install / Run MAUI check, getting green all the way down, and ending with ‘Congratulations, everything looks great!’
- Open VS Preview, go to file -> new -> .NET MAUI App
- Add https://aka.ms/maui-preview/index.json as a nuget package source
- Set the target to WinUI3
- Click Run
- Observe error window entitled ‘Exception Unhandled’, contents:
System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation. Inner Exception: COMException: Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))
- Observe contents of Output window stating
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in System.Private.CoreLib.dll Exception has been thrown by the target of an invocation.
Expected Behavior
Default template app would run
Actual Behavior
Exception described above occurs
Basic Information
- Version with issue: 6.0.100-preview.4.21255.9
- Last known good version: N/A
- IDE: VS 16.11.0 Preview 1.0
- W10Pro 21H1 19043.985
- MAUI nuget versions 6.0.100-preview.4.634
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7
Top Results From Across the Web
'System.Reflection.TargetInvocationException' occurred in ...
The event is probably raised before the elements are fully loaded or the references are still unset, hence the exceptions.
Read more >Why I'm getting System.Reflection.TargetInvocationException
Why I'm getting System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.
Read more >'System.Reflection.TargetInvocationException' in mscorlib.dll
These exceptions are not thrown in Visual Studio 2017. What are they and why are they shown? Is it a setting? My project...
Read more >What is System.Private.CoreLib.dll and why is it giving me ...
When I run the build from visual studio I get an error message in the ... System.Private.CoreLib.dll is the main runtime library on...
Read more >Upgrade: An exception of type 'System.Reflection ...
Upgrade: An exception of type 'System.Reflection.TargetInvocationException' occurred and was caught. Upgrade: An exception of type 'System.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have resolved the problem as follows:
Right Click on the Packaging project and set as startup-project;
Steps to Reproduce
I am having the same problem.
My environment is : Windows 10 Enterprise 20H2 Build 19042.985 Visual Studio Enterprise 2019 Preview Version 16.11.0 Preview 1.0
DOTNET 6 Preview SDK and Runtimes: 6.0.100-preview.4.21255.9 Microsoft.AspNetCore.App 6.0.0-preview.4.21253.5 Microsoft.NETCore.App 6.0.0-preview.4.21253.7 Microsoft.WindowsDesktop.App 6.0.0-preview.2.21154.2 Microsoft.WindowsDesktop.App 6.0.0-preview.4.21254.5
This is what is logged in the Windows Event Viewer
Application: MauiSample.WinUI3.exe CoreCLR Version: 6.0.21.25307 .NET Version: 6.0.0-preview.4.21253.7 Description: The process was terminated due to an unhandled exception. Exception Info: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Runtime.InteropServices.COMException (0x80040154): Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)) at WinRT.BaseActivationFactory…ctor(String typeNamespace, String typeFullName) in Microsoft.WinUI.dll:token 0x6000023+0x6e at Microsoft.UI.Xaml.Application._IApplicationStatics…ctor() in Microsoft.WinUI.dll:token 0x60135ef+0x1c at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x6000632+0x3e — End of inner exception stack trace — at System.RuntimeType.CreateInstanceOfT() in System.Private.CoreLib.dll:token 0x6000632+0x4e at System.Activator.CreateInstanceT in System.Private.CoreLib.dll:token 0x6000950+0x0 at WinRT.WeakLazy`1.get_Value() in Microsoft.WinUI.dll:token 0x6000019+0x20 at Microsoft.UI.Xaml.Application._IApplicationStatics.get_Instance() in Microsoft.WinUI.dll:token 0x60135f0+0x0 at Microsoft.UI.Xaml.Application.Start(ApplicationInitializationCallback callback) in Microsoft.WinUI.dll:token 0x600917b+0x0 at MauiSample.WinUI.Program.Main(String[] args) in MauiSample.WinUI3.dll:token 0x6000011+0x21