unoplatform / uno

Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
https://platform.uno
Apache License 2.0
8.62k stars 696 forks source link

`ObjectDisposedException` from SourceGenerators showing UI dialog #12844

Open mrlacey opened 12 months ago

mrlacey commented 12 months ago

Current behavior

Not sure what caused this (or how), but I had this message box displayed image

The dialog was raised by the VBCSCompiler process.

Full text of the message:

---------------------------
Assertion Failed: Abort=Quit, Retry=Debug, Ignore=Continue
---------------------------
System.ObjectDisposedException: Cannot access a disposed object.

Object name: 'default'.

   at Microsoft.ApplicationInsights.Extensibility.TelemetrySink.EnsureNotDisposed()

   at Microsoft.ApplicationInsights.Extensibility.TelemetrySink.set_TelemetryProcessorChain(TelemetryProcessorChain value)

   at Microsoft.ApplicationInsights.Extensibility.TelemetrySink.get_TelemetryProcessorChain()

   at Microsoft.ApplicationInsights.Extensibility.TelemetrySink.Process(ITelemetry item)

   at Microsoft.ApplicationInsights.TelemetryClient.Track(ITelemetry telemetry)

   at Uno.UI.SourceGenerators.Telemetry.Telemetry.TrackEventTask(String eventName, IDictionary`2 properties, IDictionary`2 measurements)

   at Uno.UI.SourceGenerators.Telemetry.Telemetry.TrackEventTask(String eventName, IDictionary`2 properties, IDictionary`2 measurements)

   at Uno.UI.SourceGenerators.Telemetry.Telemetry.<>c__DisplayClass16_0.<TrackEvent>b__0(Task x)

   at System.Threading.Tasks.Task.Execute()

   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)

   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)

   at System.Threading.ThreadPoolWorkQueue.Dispatch()

---------------------------
Abort   Retry   Ignore   
---------------------------

Expected behavior

I'm assuming this was displayed to the UI as it fell through the full call stack as an unhandled exception.

I'd expect this to be logged somewhere more appropriate than letting an exception create a dialog where the user can't do anything useful with it.

How to reproduce it (as minimally and precisely as possible)

???

Workaround

???

Works on UWP/WinUI

None

Environment

Uno.SourceGenerationTasks

NuGet package version(s)

No response

Affected platforms

No response

IDE

Visual Studio 2022

IDE version

17.6.4

Relevant plugins

n/a

Anything else we need to know?

No response

jeromelaban commented 12 months ago

This is only happening in debug, as far as I can tell.