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.

System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'

See original GitHub issue

Describe the bug Since updating a project to the latest version of WinUI3 (Reunion 0.5) we receive the following error whenever trying to debug:

System.Reflection.TargetInvocationException
  HResult=0x80131604
  Message=Exception has been thrown by the target of an invocation.
  Source=System.Private.CoreLib
  StackTrace:
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
   at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache) in /_/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs:line 4005
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions) in /_/src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs:line 4062
   at System.Activator.CreateInstance[T]() in /_/src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs:line 151
   at WinRT.WeakLazy`1.get_Value()
   at Microsoft.UI.Xaml.Application._IApplicationStatics.get_Instance()
   at Microsoft.UI.Xaml.Application.Start(ApplicationInitializationCallback callback)
   at Project.Program.Main(String[] args) in C:\Users\USER\Source\Repos\Project\Project.UI\Project.UI\obj\x64\Debug\net5.0-windows10.0.19041.0\App.g.i.cs:line 26

  This exception was originally thrown at this call stack:
    System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(int) in Marshal.cs
    WinRT.BaseActivationFactory.BaseActivationFactory(string, string)
    Microsoft.UI.Xaml.Application._IApplicationStatics._IApplicationStatics()

Inner Exception 1:
COMException: Class not registered (0x80040154 (REGDB_E_CLASSNOTREG))

Steps to reproduce the bug We used a project created in WinUI3 v3 and followed the official instructions to upgrade to Reunion 0.5. The original project works as expected until Reunion is installed/WinUI3 removed - then we are unable to run the project with the CLASSNOTREG error.

Expected behavior The project will run as before.

Screenshots image

Version Info NuGet package version: Microsoft.ProjectReunion-v0.5.0-prerelease Microsoft.ProjectReunion.Foundation-v0.5.0-prerelease Microsoft.ProjectReunion.WinUI-v0.5.0-prerelease

Windows app type: Win32

Windows 10 version Saw the problem?
Insider Build (xxxxx)
October 2020 Update (19042) Yes
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
RealTommyKleincommented, Mar 18, 2021

@Noemata - agreed it’s painful. We plan to remove the wapproj and only need a single project for Desktop apps for Project Reunion’s 0.8 release.

0reactions
github-actions[bot]commented, Jul 29, 2023

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why I'm getting System.Reflection.TargetInvocationException
Why I'm getting System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.' when downloading images ...
Read more >
Exception has been thrown by the target of an invocation - ...
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation · You need to add reference to the system.
Read more >
"System.Reflection.TargetInvocationException: Exception ...
TargetInvocationException : Exception has been thrown by the target of an invocation." Was hoping somebody could help me figure out this error.
Read more >
System.Reflection.TargetInvocationException: 'Exception ...
I'm getting this exception when I try to create an instance of ... TargetInvocationException: 'Exception has been thrown by the target of an...
Read more >
Exception has been thrown by the target of an invocation. -- ...
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.
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