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

[Bug] UWP is throwing exception randomly after 4.8.0.1687 and VS 2019 16.8.1 #12884

Closed
EmilAlipiev opened this issue Nov 18, 2020 · 31 comments
Closed
Labels
external-hotreload Non-Forms bugs that affect Hot Reload p/UWP t/bug 🐛
Projects

Comments

@EmilAlipiev
Copy link
Contributor

EmilAlipiev commented Nov 18, 2020

Description

After updating VS 2019 16.8.1 version. I am keep getting exception on the function shown below screenshot. This is happening in different places but mostly when i try to navigate between pages. GetXamlTypeByName(string typeName)
typeName is also different on the crash. I read somewhere that it is related to Uwp Hot reload added into this version and it was suggested that disable hot reload toolbar on top which i did but it didnt help. Still happening.

only message in the debug window is as below. I a worried that this is not VS related but with 4.8.0.1687 version.

Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll
An unhandled exception of type 'System.ExecutionEngineException' occurred in System.Private.CoreLib.dll

image

VS bug #1248154

@EmilAlipiev EmilAlipiev added s/unverified New report that has yet to be verified t/bug 🐛 labels Nov 18, 2020
@samhouts samhouts added this to New in Triage Nov 18, 2020
@jsuarezruiz jsuarezruiz added external-hotreload Non-Forms bugs that affect Hot Reload p/UWP labels Nov 18, 2020
@StephaneDelcroix
Copy link
Member

@maxbrister does this ring a bell ??

@StephaneDelcroix StephaneDelcroix removed their assignment Nov 18, 2020
@YZahringer
Copy link
Contributor

Same random error on UWP after VS 16.8.1 update

@maxbrister
Copy link
Contributor

Yes, this is a known issue with Uwp/Xamarin incremental hot reload.

Disabling the Uwp in-app toolbar should workaround the crash (uncheck Options->Debugging->Hot Reload ->Enable in-app toolbar). Unfortunately the underlying crash is caused by a core clr issue and apps making heavy use of reflection may experience issues. We are working on a fix for 16.9.

@EmilAlipiev
Copy link
Contributor Author

I have that disabled on 16.8.1 and 16.9 pre. it fixes the issue on 16.9 pre but disabling doesnt help on 16.8.1 stable

image

@maxbrister
Copy link
Contributor

Can you try adding the following to your Uwp project head?

<PropertyGroup>
  <EnableTypeInfoReflection>false</EnableTypeInfoReflection>
</PropertyGroup>

@jsuarezruiz jsuarezruiz moved this from New to Needs Estimate in Triage Nov 19, 2020
@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Nov 19, 2020
@jsuarezruiz
Copy link
Contributor

@EmilAlipiev Could you try the latest suggestion from Max?

@YZahringer
Copy link
Contributor

Build error with VS 16.8.2, disabling EnableTypeInfoReflection and UWP in-app toolbar:

\obj\x86\Debug\XamlTypeInfo.g.cs(117,43,117,49): error CS0234: The type or namespace name 'Markup' does not exist in the namespace 'Microsoft.UI.Xaml' (are you missing an assembly reference?)

@YZahringer
Copy link
Contributor

Build error with VS 16.8.2, disabling EnableTypeInfoReflection and UWP in-app toolbar:

\obj\x86\Debug\XamlTypeInfo.g.cs(117,43,117,49): error CS0234: The type or namespace name 'Markup' does not exist in the namespace 'Microsoft.UI.Xaml' (are you missing an assembly reference?)

It works now with disabled EnableTypeInfoReflection, maybe some cache before. Restart VS and clean solution after change it.

@GitSicarius
Copy link

GitSicarius commented Nov 30, 2020

I disabled all of the UWP hot reload debug options and was still getting the ExecutionEngineException randomly. I then added <EnableTypeInfoReflection>false</EnableTypeInfoReflection> to my UWP csproj and haven't had any exceptions.

@EmilAlipiev
Copy link
Contributor Author

question is if that is effecting Release mode as well?? or it is just debug issue. Do i need this EnableTypeInfoReflection = false when i want to make a new release?

@GitSicarius
Copy link

That's a good question. I'm also concerned with adding a new csproj tag not fully understanding the side effects.

@bmacombe
Copy link
Contributor

I've not had any problems with my release builds, it's only with the debugger attached since it's related to Hot Reload

@bmacombe
Copy link
Contributor

also, I can run my debug builds without the debugger attached and I don't receive the error.

@maxbrister
Copy link
Contributor

EnableTypeInfoReflection changes Uwp's auto generated XamlTypeInfo.g.cs to use reflection instead of a compile time generated table. The generated file should be under your obj folder. It is intended to make Uwp hot reload a smoother experience. By default EnableTypeInfoReflection is not enabled in release builds.

@EmilAlipiev
Copy link
Contributor Author

EmilAlipiev commented Dec 10, 2020

are you able to run your app in release mode? For me my app is no longer running in release. i am getting all the time Unhandled exception at 0x00007FFA71E23B29 (KernelBase.dll) in error. I have 0 change in platform level since last successful running version. i have also recognized that in release mode app is starting very fast like debug mode. There is surely something wrong with this VS 2019 version 16.8.3

@EmilAlipiev
Copy link
Contributor Author

EmilAlipiev commented Jan 24, 2021

this still exist in the latest Vs2019 and XF5 it makes hot reload unusable for uwp xamarin

in VS19 16.8.4 even worse whenever i start my application it throws this exception. it seems to be Hot reload is crashing

image

@EmanterolaDN
Copy link

Thanks @maxbrister and @jsuarezruiz this workaround worked for me with XF 5 and VS 16.8.4. I just hope this fix won't affect to Release... I'll keep in touch!

@hupo376787
Copy link

16.8.4, still facing the problem.
image

@LyalinDotCom
Copy link

Sorry for everyone having this issue. An update on the situation is that we've got a tooling fix in 16.9 Preview 4+, but it depends on a related fix that lives inside of the .NET Native NuGet package which is also going to be released soon and is required to make this error finally go away.

Once both things are available, and your projects are updated then this issue should be fully resolved.

Thank you for your patience and for now there is a workaround above that should work.

@maxbrister
Copy link
Contributor

Microsoft.NETCore.UniversalWindowsPlatform 6.2.12 is now available and contains a fix for the ExecutionEngineException. If you're on the preview channel after updating to 16.9 Preview 4 you should be prompted to update your NuGet package on F5. If you're on 16.8 you will need to update Microsoft.NETCore.UniversalWindowsPlatform via the NuGet package manager.

@hupo376787, @EmanterolaDN, @EmilAlipiev, @MattRames can you guys undo your workarounds and give this a try?

@EmanterolaDN
Copy link

Thank you @maxbrister and all the people involved, we'll include in our app ASAP, @juanmalm

@ginomessmer
Copy link

Hi @maxbrister, I've had the same issue and I've been following this issue ever since then. I can confirm that the issue is gone on my end. Thank you for providing the fix!

@StephaneDelcroix
Copy link
Member

closing per @maxbrister request

Triage automation moved this from Needs Estimate to Closed Feb 10, 2021
@EmilAlipiev
Copy link
Contributor Author

@maxbrister Unfortunately not working for me when I enable hotreaload as below. I updated to 6.2.12 and VS 2019 16.8.5. it is still throwing similar exception even on start up now.

image

Exception:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Xamarin.HotReload.Forms
  StackTrace:
   at Xamarin.HotReload.Forms.VisualTreeService.VisualTree.FormsVisualTreeContext.SubscribeToVisualTreeChanges()
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.<>c__DisplayClass28_0`1.<RegisterMessageObserver>b__0(TMessage message)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.HandleMessage[TMessage,TReply](Func`2 callback, Message request)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ProcessInboundMessage(Message message)
   at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ActionThread(Object list)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

  This exception was originally thrown at this call stack:
    Xamarin.HotReload.Forms.VisualTreeService.VisualTree.FormsVisualTreeContext.SubscribeToVisualTreeChanges()
    Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.RegisterMessageObserver.AnonymousMethod__0(TMessage)
    Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.HandleMessage<TMessage, TReply>(System.Func<TMessage, TReply>, Microsoft.VisualStudio.DesignTools.TapContract.Networking.Message)
    Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ProcessInboundMessage(Microsoft.VisualStudio.DesignTools.TapContract.Networking.Message)
    Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ActionThread(object)
    System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, object)
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

@EmilAlipiev
Copy link
Contributor Author

EmilAlipiev commented Feb 12, 2021

I guess that it is about Live VisualTree. When i disable it, works fine.

Exception is thrown even if i disable Live VisualTree

@maxbrister
Copy link
Contributor

@EmilAlipiev that's a different issue. I think the problem you're running into now is Application.Current is null when the tooling tries to initialize. Assuming Application.Current is eventually initialized in your app, you should be able to workaround the issue by doing cntrl+F5 then attaching to the application after it is initialized.

@hupo376787
Copy link

hupo376787 commented Mar 10, 2021

Hi, I'm still facing An unhandled exception of type 'System.ExecutionEngineException' occurred in System.Private.CoreLib.dll.

image

Microsoft Visual Studio Professional 2019
Version 16.9.1
VisualStudio.16.Release/16.9.1+31105.61
Microsoft .NET Framework
Version 4.8.04084

Windows Template Studio   3.9.20351.2
Windows Template Studio quickly builds a UWP app, using a wizard-based UI to turn your needs into a foundation of Windows 10 patterns and best practices.

@maxbrister
Copy link
Contributor

@hupo376787 can you provide a heap dump of your application when it is crashed? You can generate one in VS using Debug -> Save Dump As....

@hupo376787
Copy link

Hi, @maxbrister I met this twice today, and the dump file is in https://github.com/hupo376787/System.ExecutionEngineException/releases/download/1.0/test.zip.
Thx.

@maxbrister
Copy link
Contributor

@hupo376787 from your dump it looks like your app is a normal Uwp app not a Xamarin Forms app. Is that correct?

There's a good chance you're running into the same underlying bug. If you update the Microsoft.NETCore.UniversalWindowsPlatform NuGet package for your project does that fix the issue?

@hupo376787
Copy link

Yes, it's a pure uwp app. I will update and try, thanks.@maxbrister

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external-hotreload Non-Forms bugs that affect Hot Reload p/UWP t/bug 🐛
Projects
Triage
  
Closed
Development

No branches or pull requests