agileobjects / ReadableExpressions

A library and Debugger Visualizer which translates Expression Trees into readable C# source code. .NET 3.5+ and .NET Standard 1.0+.
MIT License
396 stars 22 forks source link

Exception when showing window #95

Closed cbeamond closed 1 year ago

cbeamond commented 3 years ago

I get this exception when viewing a certain automapper expression. I can't give give source due to NDA, but I can give you some limited other information.

Visual Studio 2109 v16.11.2 Automapper 10.1.1 .NET Core 3.1 ReadableExpresssions.Visualizer 4.1.0

I followed the instructions on https://agileobjects.co.uk/view-automapper-execution-plan-readableexpressions

It happens both with my code and the code as shown on the example. Installed from the market place https://marketplace.visualstudio.com/items?itemName=vs-publisher-1232914.ReadableExpressionsVisualizers

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at System.Windows.Forms.UnsafeNativeMethods.IWebBrowser2.get_RegisterAsDropTarget()
   at System.Windows.Forms.WebBrowser.set_AllowWebBrowserDrop(Boolean value)
   at AgileObjects.ReadableExpressions.Visualizers.Dialog.Controls.VisualizerViewer.HandleShown(String translation)
   at AgileObjects.ReadableExpressions.Visualizers.Dialog.VisualizerDialog.<>c.<.ctor>b__8_0(Object sender, EventArgs args)
   at System.Windows.Forms.Form.OnShown(EventArgs e)
   at System.Windows.Forms.Form.CallShownEvent()
   at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
   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.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()

image

cbeamond commented 3 years ago

I forgot to add that half an hour earlier I did get the expression viewer to show up when going through automapper internals and it did show a limited amount of code.

cbeamond commented 3 years ago

I uninstalled and installed the previous version from commit 6a61c372b7ab3ce1a1b10f60d77db51ef21b4c67 and that works fine on my code. So either there was a change in the last version that broke something or a reinstall fixed it. I don't have time right now to test the reinstall theory or to test with the code from the example, but I am happy that the tool is working for me.

I'd be willing to test a few versions if you need help trying to pinpoint the issue.

SteveWilkes commented 3 years ago

Thanks for letting me know about this - I've seen this error before when the debugger gets into a particular state, and closing + reopening Visual Studio has always fixed it. Whenever I've seen this happen the ToReadableString() extension method always still works, which implies it's something to do with the visualizer framework code.

Glad you sorted it out in the end!

cbeamond commented 3 years ago

No problem! I did try restarting several times without success, in fact that's the first thing I tried. Only using the earlier version helped. Still, it's working well now :)

SteveWilkes commented 3 years ago

Thanks for letting me know! That's actually more concerning for me, of course :D I'll have an updated version soonish, so we'll see how that one behaves...

SteveWilkes commented 2 years ago

I've added a try/catch around the browser-control property-setting statements in v4.1.1 of the visualizers (now on the VS Marketplace) - apparently this error can be thrown if you try to set them before the control is quite 'ready', but it shouldn't be considered fatal, and shouldn't render the control unusable. With a bit of luck that'll be the end of these exceptions!

Tvde1 commented 2 years ago

I'm also getting the same issue with version 4.1.1

SteveWilkes commented 1 year ago

I've released v4.6 of the visualizers to VS Marketplace, which has changes to hopefully improve the visualizer's stability.