I have a strange issue with my C# UWP-Win10 app. When I re-size the window often or clicking a random button often (>3 times), I'm getting the error:
An unhandled win32 exception occurred in bla.exe [bla-id]
After closing this window the app crashes and in the output-window I get:
The program '[bla-id] bla.exe' has exited with code -1073741811 (0xc000000d).
No more information from Visual Studio. I'm using the serial-port in this app and I've noticed that this error occurs only when I'm connected to the device. But: I've added an empty button (without a Click-handler) and the same error occurs on this button.
Additionally I've looked in the eventviewer and saw the crashed-module:
ntdll.dll (offset 0x00000000000f5670)
How can I trace down the issue? I'm not using external APIs or something else.
After a while (two weeks) of testing and debugging I've found the issue: The garbage collector is closing the serialport inputstream and thus the DataReader (which is reading the serialport) dies instantly and throws this unspecified exception. Basically this was an issue with the datareaader not disposing correctly in code. "Mystery" solved.
I know this post is three years old, but I found it when I was searching for a solution to this exact same problem, and maybe my experience can help the next person who stumbles upon it.
After reading the OP's response to his own question, I started investigating garbage collection, object disposal, and etc. I found that if my DataReader and DataWriter objects were global in scope, then they were at risk of being garbage collected mid-use. What worked for me was to locally scope those objects every time I needed them, with a using(DataWriter dw = new DataWriter(EventHandlerForDevice.Current.Device.OutputStream)) { ... } block, or similar for the DataReader object. Since implementing them like this, I haven't had any of the win32 exceptions whatsoever. Hope this helps!
Related
It looks like a duplicate, but believe I checked other answers, nothing worked.
My application started crashing while closing the application with below error. It was working properly few days back, some recent changes is causing the issue. And one this starts on a machine, even though I replace with previous working DLL, still the issue comes.
Microsoft Visual C++ Runtime Library
Runtime Error!
Program:C:\DigiMic\...
This application has requested the Runtime to terminate it in an unusual way...
This pop-up comes for 1 second with OK button, then automatically closes. The main problem is it happens while shutting down my application.
My Application: It is a WPF, C# application which uses Matlab used business DLL for few functionality. The application works fine while using the Matlab used DLL and its function, only crashes while exiting the WPF.
I tried to Wrap the App.Current.ShutDown with try..catch... but the it never hits catch orfinally block. Then I also tried AppDomain.Current.UnHandledException += new..., it still does not hit the function on exception.
The other problem is, I am not able to see the complete path of the exe that causes this exception.
Question:
Is there a way, I can suppress this error?
Where is this error gets logged in windows?I tried to look into Event Viewer, but nothing is there.
Is there any workaround? Since it's software delivery time for the product. :(
A program I developed in Microsoft Visual Studios 2010 using c# has been generating the following error: https://dl.dropboxusercontent.com/u/19853155/code%20error%2001.jpg
I have kind of isolated the issue down to this segment of code:
if (gui.rawLogLSM.InvokeRequired)
{
gui.rawLogLSM.Invoke(new MethodInvoker(delegate
{
gui.rawLogLSM.AppendText(t.ToString());
gui.rawLogLSM.ScrollToCaret();
}));
}
else
{
gui.rawLogLSM.AppendText(t.ToString());
gui.rawLogLSM.ScrollToCaret();
}
Basically in this segment of code, I am reading raw data from a serial port, and printing it into a text box, byte by byte. (I can't read the whole buffer in at a time, as that invalidates what we're doing for the project).
I am not wholly sure how this error is actually generated or under what conditions. The error has only presented itself when a co-worker is using the application in my absence, and I've been unable to recreate the error.
The error from info from the exception comes up in form of a message box due to me having a try/catch around a larger block of code, within which the above code is apart of.
So my question is mostly, how can I solve this error or what should I be doing to force said error to show itself?
Thanks for the help!
Could it be that the invoke is on a different thread and the exception is thrown when trying to invoke the textbox while another thread has disposed the textbox(on form close maybe?)? If this is because the textbox is disposed on different thread, one solution would be to surround AppendText and ScrollToCaret inside the invoke with try/catch and swallow that specific error.
The error itself is pretty straightforward: your rich text box is being disposed before you access it. Unfortunately, these can be very nasty to track down, especially if you can't reproduce it.
Do a sanity check and make sure that the RTB is indeed created before the Append()'ing code is called, but my gut tells me you'd get constant errors if it wasn't.
To me, the first step is to reliably reproduce it. Use your coworker's machine, have them demonstrate what they were doing when the error popped up, ensure the framework and application versions are the same, etc etc.
Once you can reproduce it, you'll have to find WHERE the object is disposed. You can do it manually by right-clicking a call to the dispose and choosing "show all references". Set breakpoints on each of them, or use some other monitoring scheme (like a log, which can be used to watch programs on non-development machines). Remember that the System.Diagnostics.StackTrace class is useful for seeing what called Dispose.
There are also tools that monitor memory usage and disposal that can help you out.
I'd also recommend turning debug mode on and giving your coworker the debug-enabled executable and the symbol file (pdb) as this may help track the problem.
Other things to check are race conditions, simultaneous/cross-thread access, exceptions in other threads that may be swallowed by the CLR, only to fudge up your code later on, and make sure you end all threads before you close your form. If you don't, weird stuff can happen. At best, your program will continue to hang in memory, invisible to all but task manager. Worse, you can pop up random error dialogs "out of the blue" as something finally fails. In your case, it might be failing immediately.
I am trying to get the keyboard state in my XNA application with the following code:
this.OldKeyboard = this.NewKeyboard;
this.NewKeyboard = Keyboard.GetState();
this.OldMouse = this.NewMouse;
this.NewMouse = Mouse.GetState();
However, sometimes (I think about 60%) when I start my game, I get an InvalidOperationException with the following message:
An invalid operation occurred when trying to query the keyboard state.
The result code was 126.
at Microsoft.Xna.Framework.Input.Keyboard.GetState(PlayerIndex playerIndex)
at Microsoft.Xna.Framework.Input.Keyboard.GetState()
at GameLib.GameBase.Update(GameTime gameTime) in MY_PATH\GameLib\GameLib\GameBase.cs:Line 58.
at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
at ...
My searches on google and SO did not give me any results on this code.
What could be the cause for this and why doesn't it occur everytime or never, but only sometimes when starting the project?
Edit: My thread layout:
Main thread
starts Game.Run
starts a network initializer in a separate project (in Initialize)
which starts a new thread for network I/O
When creating a new project only containing Keyboard.GetState(), I apparently get an error code of 0, which translates to
ERROR_SUCCESS
0 (0x0)
The operation completed successfully.
See my screenshot below, I do not know why a success would trigger an InvalidOperationException.
Keboard.GetState uses the win32 function GetKeyboardState (MSDN) internally. If that fails, it gives an error code from this list, which XNA fetches and packs into that exception for you.
That error code translates to: "The specified module could not be found."
Where "module" basically means DLL. And "not found" might refer to the DLL being loaded, or a DLL that it, in turn, requires (and so on). It's an extremely unhelpful error message.
I'm not really sure what DLL GetKeyboardState might be trying to load, or why it might fail intermittently.
Probably the first step to try and fix this would be to create a new, blank project and see if you get the same result, so you can figure out if it's your code, or something wrong with your system or XNA install.
(I imagine actually debugging this properly might involve using Process Monitor to catch what DLL it is failing to load.)
Also, Blau is correct - all input in XNA must be done on the main thread.
I don't know how old this thread is, but I heard it has something to do with your firewall. The same error happened to me when I updated my antivirus (do you happen to use Comodo?) Anyway, check that out, and see if it helps. It has nothing to do with XNA, I tested in visual c# express, visual studio 2012, and 2013, with same results, then I tried with a fresh project that only called the keyboard state, and it happened again. And none of that happened before I updated the antivirus...
We are currently trying to incorporate Lync communication (Lync SDK 2010) into our application and we have run into an issue with the VideoWindows (CaptureVideoWindow, RenderVideoWindow) of the AVModality's VideoChannel: They are always null, even after successfully calling BeginStart. The connection is definitely established. We can talk. Our own video is shown in a remote Lync client. AVModalityState is Connected. VideoChannelState goes from Connecting to Receive to Send.
It does not matter when and how we try to access them: Directly after BeginStart, in the AsyncCallback of BeginStart, in response to various state changes or in response to an external trigger (user click event); in the main/UI thread or in an event/callback thread. The two video windows are always null.
In the example application "%PROGRAMFILES%\Microsoft Lync\SDK\Samples\AudioVideoConversation", everything works as intended: As soon as BeginStart has finished, we can access the non-null video windows. In our little stand-alone prototype project, it works, too. But in our real application, it does not.
We have double checked everything and we have really run out of ideas of what might cause this problem.
Any ideas, any hints? Anything that we should be aware of?
(Link to corresponding MSDN forum thread)
Update (4th July 2012, 15:46 CET):
When we take a look at the members of the VideoChannel we find that internally a COMException occured in "Microsoft.Office.Uc": Error loading DLL, HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY). More details in the attached screenshot.
We did some research on this error, but found nothing that worked for us. Any ideas what causes the Exception?
Update (9th July 2012, 16:43 CET):
We did some further testing...
Our software consists of one main application and many plugin-like "apps" loaded via MEF. We created a minimal test app that makes a video call: The video windows did not work (as expected). But when we took the identical code and created a separate solution outside of our architecture, then it did work. So, it was an issue with the environment, not the code.
At first, we suspected MEF might be the problem. So, we hacked the lync code into our main application - circumventing the whole app architecture. Still not working.
Then we sliced off our whole system, bit by bit, until we finally reached a point where it did work. After following wrong tracks several times, we finally found the culprit... Quartz.NET!
For some strange reason the mere presence of an assembly reference to the Quartz.dll v.1.0.3.3, even without a single line of Quartz code, causes the video windows to not work. Unbelievable, but it's 100% reproducible: If we take the previously mentioned test solution and do nothing but add the reference, it stops working.
Any idea how such a thing is possible?
We solved it! Kind of. A reference to a Quartz.NET DLL somehow caused the issue. More details in the updated question.
For now, we have removed the component that used Quartz. We currently do not need it.
But I'm still interested in further input how a mere reference can cause such an issue.
I have a web application I am developing that seems to crash completely at random when clicking links on any page. When this happens, I'm told 'An unhandled win32 exception occured in iexplore.exe'. When I try to debug, it says one is already attached.
What could this be relating to? I know without code it will be hard, but this seems like a very strange error to occur at random.
I have had this happen to me before and the problem usually had to do with styling on html elements that IE just couldn't handle. A good test would be to run the app in Mozilla and Chrome to see if they crash. For me, 4/5 times it had to do with the overflow attribute on a div. For some reason, ie is quirky when it comes to scrolling. To find it, after you have tested in the other browsers, start taking blocks out one piece at a time and see if you get the error. If you don't get the error, then the problem is in that block, otherwise put it back in and take the next block out. Keep going until you find it.