InvalidOperationException was unhandled in VB.NET when debugging - vb.net

Dear fellow programmers,
Most of the time the debug works but in some moments when I try to debug this error shows: http://s11.postimg.org/ezs58e4lv/screen.png
http://postimg.org/image/406xwse6n/
What I do most of the time is that I just close that error and re-debug it. But I want to ask if that error will affect my published application and when that error comes to the scene, will the solution is the user will just close my app and restart it again? Seems inconvenient.
How can I fix this error?

Related

How to prevent RCP exit failure?

When I was writing a program yesterday, I failed to exit Eclipse. The UI is closed, but the console is still running (eclipsec.exe). This kind of problem is not common. I checked the error log and found no reason.
How can I avoid this kind of problem if I develop an RCP? Can I check the thread when the Display is destroyed, and force exit (System.exit) after the specified time
Is my method feasible?

WinUI3 Microsoft.UI.XAML.dll "Source Code Not Available" error on Debug

My app builds fine. Attempting to start it in debug mode, however, causes this error. This appeared after I solved an error relating to missing "debug symbols" similar to the one here (enabling the remote symbol servers in the options and then building caused this error to appear instead - this behavior persisted even after turning off the remote symbol servers in the options again).
I am using WinUI3 project on Visual Studio 2022 on Windows 11.
This post seems to suggest the issue was using WPF - but I am not using WPF. I also see a potentially similar issue here, but there appear to be no answers.
I am not sure where to even begin fixing this - it seems to be a Visual Studio issue or a project/solution config issue rather than a code issue. Any ideas?
I fixed it. I was looking at the output in the Visual Studio Console (after stopping the app once the error mentioned in the question happened), and I saw this:
Exception thrown at 0x00007FFD41D4466C (KernelBase.dll) in EmailClient.exe: WinRT originate error - 0x80004005 : 'WinUI: Error creating second Desktop Window on the current process. No more than one Desktop Window is allowed per process.'. onecore\com\combase\winrt\error\restrictederror.cpp(1017)\combase.dll!00007FFD43EAA21E: (caller: 00007FFD43D9A2F3) ReturnHr(2) tid(5e98) 8007007E The specified module could not be found.
I then searched through my project, and found out I was calling new MainWindow() one place in my project outside of the App.xaml.cs when initializing a property. I removed that (initializing the property to null instead), and now the app works fine. Not sure how the two are related... but this may be an unexpected behavior caused by attempting to create multiple windows on the same process. Here is someone else who had the same issue.
If your intention is to create multiple windows (mine was not) and you want to know how, then see this thread (a few months out-of-date... not sure if the mentioned features are still in preview or not as of time of posting).

ArcGIS 10.2 Debug with Visual Studio

I am attempting to debug a custom plugin that was developed so that I can track down some errors that is causing ArcGIS to crash.
My problem is that whenever I set up a breakpoint I get "No symbols have been loaded for this document"
So I tried placing in a Stop point so I can step through after a known event e.g. Mouse click
Still ArcGIS crashes and the debug halts entirely.
It almost seems that ArcGIS has just loaded the program in and isn't returning anything back to Visual Studio.
Any insight on this would be greatly appreciated.
-UPDATE
I think it may have something to do with the API as it will still run once the debugger has stopped.
Try to “clean solution” and “rebuild solution”.
"No symbols have been loaded for this document" message shows that your current code does not used in running application.

WebView.Navigate results in unhandled exception

Using the WebView control in the Windows 8 SDK Samples results in an unhandled 'Unspecified error'.
In my own project it gives me an unhandled exception of 'Unable to get property '1' of undefined or null reference'.
I can't catch it.
It doesn't happen if I deploy it to a Surface or on another machine so I think it's probably my machine.
I need to know what I can do to fix this issue on my machine.
Any help appreciated.
When you debug a XAML app with a WebView whose content has a JavaScript exception, that exception is elevated up through the WebView to Visual Studio where you (presumably) can debug it. When you run this (CTRL+F5) without debugging, these types of errors are swallowed. So your experience is not your machine, but the fact that the debugger is attached.
You can find a similar question and its answer here: https://stackoverflow.com/a/12249831/265706 But beware that the answer to that question suggests disabling the debugging mechanism. Make sure that is what you really want to do.

My Windows 8 Store app crashes in App Certification Kit, how can I found out why?

So when I am creating an App Package, the Windows App Certification Kit fails with:
Crashes and hangs • Error Found: The crashes and hangs test detected
the following errors:◦Application
47878User.MyApp_1.0.0.3_neutral__a2qvk4qzttz7j was detected by Windows
Error Reporting and experienced a crash or hang.
In my event log I see the following:
Application: MyApp.exe Framework Version: v4.0.30319 Description: The
process was terminated due to an unhandled exception. Exception Info:
System.Exception Stack: at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
System.Threading.WinRTSynchronizationContext+Invoker.b__0(System.Object)
at
System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
at
System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,
System.Threading.ContextCallback, System.Object, Boolean) at
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,
System.Threading.ContextCallback, System.Object, Boolean) at
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch() at
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
and:
Faulting application name: MyApp.exe, version: 1.0.0.0, time stamp:
0x50546b92 Faulting module name: KERNELBASE.dll, version:
6.2.9200.16384, time stamp: 0x5010ac2f
Exception code: 0xe0434352
Fault offset: 0x00014b32
Faulting process id: 0x1894
Faulting application start time: 0x01cd933a183ece6a
Faulting application path:
C:\Program
Files\WindowsApps\47878User.MyApp_1.0.0.3_neutral__a2qvk0qzyyn7m\MyApp.exe
Faulting module path: C:\Windows\SYSTEM32\KERNELBASE.dll Report Id:
6b9e9db3-ff2d-11e1-be8d-001c42ac6e2f Faulting package full name:
47878User.MyApp_1.0.0.3_neutral__a2qvk0qzyyn7m
The problem is that I can't for the life of me reproduce any crash, neither in Debug mode, Release mode, forcing Suspend/Re-activation events etc..
When the Windows App Certification Kit runs my app the 6th (or the 7th) time, my splash screen shows briefly, then my app disappears (crashing, likely).
What is the WAPK doing in the 6th run, and how can I reproduce/debug this?
I'm not an expert, but i have just been through the same process with my application to see if I could work out what was going on. Below is write up of what I did (in the hope it is useful to someone else).
Certiication Kit results
FAILED: Crashes and hangs
Error Found: The crashes and hangs test detected the following errors:
Application neutral__6j94sra26jgtm was detected by Windows Error Reporting and experienced a crash or hang. Impact if not fixed: An app that stops responding or crashes can cause data loss and is a poor user experience. How to fix: Investigate, debug the executable(s) in question to identify and fix the problem, then rebuild and re-test the app. Using Application Verifier Within Your Software Development Lifecycle.
This did not help at all. I assume the link has been updated since this discussion, however I didnt think it was that useful.
Investigation
Some errors are logged in the Event Viewer (windows key + R, type in "eventvwr"). I can see three useful entries:
A Windows Error Reporting event
An Application Error event
A .NET Runtime event
The Windows Error Reporting Event has a bit more information including some filepaths of where your it has saved its log file.
I ended up running the windows application certification tool from command line and isolated the test that was failing to the PerfromanceShutdown test. Command used to run from command prompt is:
C:\Program Files (x86)\Windows Kits\8.0\App Certification Kit>appcert test -apptype windowsstoreapp -packagefullname <applicationfullname> -reportoutputpath e:\Projects\AlbumFlow.Win8\output1.xml
This lead us towards something happening in the suspend / exit / resume methods.
The other place I looked was in C:\Users\<userName>\AppData\Local\Microsoft\AppCertKit. This had a couple of large files (~100Mb) Windows Performance Analysis trace files. This looked useful, but I didnt understand it.
Solution
Whilst I was looking at the trace files other people in the team found that the suspension manager was not closing the file references correctly.
This could be reproduced by using the DebugLocation toolbar in visual studio. Chooseing Suspend, Resume, Suspend and Terminate reproduced the problem.
Hope this helps someone as it seems to be a bit of a dark art debugging these errors.
Ok, I found the issue a couple of days ago.
I didn't test the suspend and shutdown scenario properly.
If somebody has a similar issue; enable the Debug Location toolbar (View->Toolbars->Debug Location)
Start debugging and select the Suspend and Shutdown option.
I had an unhandled Exception in my OnSuspending event.
For all of you who come visiting this question deeply frustrated and not understanding why there's no dumps, no signs of actual crash or hang, no new entries from Windows Error Reporting appearing in Application Event Log, I have a recipe:
Clear your Application Event Log.
In my case I had the following problem: once upon a time our QA set device time in the future to test some application-specific stuff. We were unlucky enough to launch WACK while still being in the future. And our app crashed. After having time unwound to actual, we never managed to pass WACK crash and hang test on that device again. The reason was that WACK itself seems to use Windows Event Log to find reports from Windows Error Reporting. And in this case it finds them because they are actually still there, in the future. What makes things worse is that these future entries are actually pushed to the bottom in the default event view by ones that arrived later despite the timestamp, so they are hard-to-see unless you explicilty sort event log by date & time.
I wish I saved someone several hours of headbang.
You will also fail these "Crashes and Hangs" tests if you have UAC turned off.