WPF Application Crashing Without throwing any Exceptions - c#

Iam created a WPF Application in framework 4.5 and deployed as ClickOnce Application.
It is for Connecting and write the QuickBooks(3rd party) Software.
The Application is working fine On every system except few systems.
In few systems it is got crashed even if I am keeping the Application as idle.(After Connecting to the 3rd party software).
I don't know what is exactly happens with only few systems.
After crashing it is immediately Opens the JIT.
In that the following call stack i had
4036a9ae() Unknown
[Frames below may be incorrect and/or missing]
kernel32.dll!#BaseThreadInitThunk#12() Unknown
ntdll.dll!__RtlUserThreadStart() Unknown
ntdll.dll!__RtlUserThreadStart#8() Unknown
I have added all exception handling mechanisms includes catching Dispatcher Unhandled exception and Unhandled exceptions. even though it is not catch any of the exceptions.
Can anyone tell me, how to resolve this issue or How to find out the exact reason behind it?
The last two weeks I am trying to resolve it.
My event Logs shows below
Exception code: 0xc00001a5
Fault offset: 0x00056738
Faulting process id: 0xe9c

Goto project properties of your solution and set the application build start type to Console Application, then in the Constructor of MainWindow use try catch something like below
public MainWindow()
{
try{
InitializeComponent();
//you remaining code
}
catch(Exception ex){
Console.Out.Writeline(ex.Message);
}
}
then deploy on the pcs where your app crashes...and see in the console whats the error

Related

On Windows 2008 application crashes instead of handling the exception

I have a function which should check, if COM is registered in the system. It may happen, that COM is registered, but dll file is missing - in this case function also should return false. MessageBoxes are only for debugging purposes:
public bool IsCOMInstalled(string name)
{
try
{
MessageBox.Show("?");
var obj = Activator.CreateInstance(Type.GetTypeFromProgID(name));
MessageBox.Show("!");
return true;
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return false;
}
}
On Windows XP and 7 above works fine. On Windows Server 2008, exception is not handled. Application crashes right after showing "?".
Why is that? How can I make my application handle an exception...?
I think its the problem with your framework of windows.
when Framework fail to handle exception that time CLR fail to run further. means your code totally destroys the functionality of CLR.
check the system requirements of windows 8 as maintained in Note of following link.
i found the system requirements for windows 8 to run this.
http://msdn.microsoft.com/en-us/library/8z6watww.aspx

Catching exceptions in console application C#

I have a console application written in C#. This application runs as automation to test a web service.
Flow:
Log in to network share (impersonate user)
copy mp3 file to local disc
convert mp3 to wav
downsample
trim wave
extract some useful data from wav
send http request
delete local files
write out some stuff to tsv
The application will run great for several hours (usually takes about 24 hours to complete the test). but every once and a while I will get this message: "The application has stopped working. I have been running this is VS 2012 in debug mode so, I can see what line throws any error. problem is, that I have not been able to catch the line (or method) that is throwing the error. I originally thought that the Domain controller was causing this issue due to power settings.
How can I capture exactly what error is bubbling its way up the stack?
Does all that run in a loop of some kind? Or on a timer?
Perhaps put a try-catch around the body of the loop or the method that runs all your code, add a logging framework of your choice (log4net or nlog seem good) and then in the catch log the exception. Most logging frameworks allow you to include the exception and will include stacktrace, etc.
Putting debug logging throughout the process can also help to narrow down where it's happening.
You can go to the Event Viewer on the operating system the console application is running on and then click on "Application". Event viewer logs and displays all exceptions thrown on any application running on the operating system.
try
{
// your code
}
catch (Exception e)
{
System.IO.File.WriteAllText(#"Z:\err.txt", e.ToString());
}
Note that access to windows drives are denied for non administrators so replace Z: with your choice.
I recommend you using a logging framework.
I use log4net in almost all applications. Its very simple to use and configure.
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
try
{
// do whatever
}
catch(Exception ex)
{
// Log an error with an exception
log.Error("Exception thrown", ex);
}
By using these kind of libraries you can get your log data output to file, database or even written to the windows event-viewer for instance.
It looks like the exception code you are getting happens when you try to use something that is already been garbage collected. Are you using anything after it is disposed?
Knowledge Base Article for 0xc0000005

C# WinForm nothing happen

i have created C# WinForm on my Windows server 2008 and it works fine.
but when i transfert this MyProg.exe into computer window 7, and i run it, nothing happen.
my code:
[STAThread]
static void Main()
{
try
{
Application.SetCompatibleTextRenderingDefault(false);
DevExpress.UserSkins.BonusSkins.Register();
Application.EnableVisualStyles();
//Pour TEST
//Le_ClientID = "850001";
//Le_Login = "850001FA";
using (var loginForm = new Login())
{
if (loginForm.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;
}
Application.Run(new Le_MainForm());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Anybody have an idea ?
event log show:
- System
Provider
[ Name] Application Error
EventID 1000
[ Qualifiers] 0
Level 2
Task 100
Keywords 0x80000000000000
TimeCreated
[ SystemTime] 2012-05-14T09:40:39.000000000Z
EventRecordID 3557
Channel Application
Computer anjouachemineme
Security
EventData
FrontEnd_Offline.exe
1.0.0.0
4fb0c28b
KERNELBASE.dll
6.1.7601.17651
4e2111c0
e0434352
0000d36f
f84
01cd31b59ee78b7d
C:\Soft8_Local\FrontEnd_Offline.exe
C:\Windows\system32\KERNELBASE.dll
dcb7cb01-9da8-11e1-bf8c-1c6f65c1ad74
Thanks you in advance,
Stev
PS: As i lunch MyProg.exe, it listed on Task Manger, but it disapear (killed) in about 3 second after.
Execute the exe (Start as Administrator)
or
this may happen if you dont have Framework Installed in which you created the application by default windows 7 comes with 2.0 and 3.5 Framework . if you created application in visual studio 2010 then you need to download FrameWork 4.0 from Microsoft website to run that exe in Windows 7
you can download Framework 4.0 from here
I just encountered this issue in a Windows form App I created. Apparently there is a plethora of issues that can cause this. In my case you could open the Task Manager, click the application, see it open in the task manager, and immediately close. The only way to see what the issue was, was to look at the event viewer and find the error.
The first is dependencies. Like mentioned above, ensure all required .dlls are included and that you have the required framework(s) installed.
Second KERNELBASE.dll can become corrupted. To ensure that is not the case you can run the System File checker. Instructions can be found here: http://support.microsoft.com/kb/929833
Third, is my case. I had a method running in the constructor of Program.cs which is the first thing instantiated when you start a windows form app. I had a bug in code that was causing an exception before any exception handling was created. To fix the problem I moved the code to a point after I create an unhandled exception method as such:
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
in my forms constructor. Now the program would start and actually throw an error. I then just had to fix the bug in my code.
I hope this can help you or anyone else out there.

Error "A type load exception has occurred." using apns-sharp with mono

I'm trying to move my APN backoffice from PHP to C# for performance issue. Bear with me, I'm new to C# and mono.
I've just downloaded MonoDevelop 2.8.6.4 and APNS-sharp merge 26 on my OSX 10.7.2
I opened the entire solution with all libraries and test executables and built the entire solution without errors. I modified the fields (token id, cert file, ...) in the Program.cs in JdSoft.Apple.Apns.Notifications.Test to meet my specs.
After a few tries I managed to get my certificate file OK and the connection to Apple servers is now up. I see the message saying I'm connected in the output of the application.
Probleme comes now. Everytime the application tries to send a message to Apple I get the error "A Type load exception has occured". I tried a little debug and the error seems to come from the NotificationPayload constructor.
Doing step by step follow up, it appears the NotificationAlert is correctly instantiated inside the NotificationPayload constructor. The error appears when coming back to the Notification constructor where the Payload member appears in the debugger as "A type load exception has occurred." instead of an object.
From there the Notification object ends up with the same behavior.
From my research on the Internet this could come from the version of Newtonsoft.Json.Compact.dll but I have no idea what to do with this piece of information.
For information I can see the same error when running the compiled test on my CentOS server.
And for more information the application message (changed ex.Message to ex.ToString() in the test program to get a full error) :
Notification Queued!
Sleeping 15000 milliseconds before next Notification...
Connecting...
Connected...
Error: System.TypeLoadException: A type load exception has occurred.
at JdSoft.Apple.Apns.Notifications.Notification.ToBytes () [0x0006c] in /Users/laurent/Downloads/Redth-APNS-Sharp-595275f 2/JdSoft.Apple.Apns.Notifications/Notification.cs:90
at JdSoft.Apple.Apns.Notifications.NotificationChannel.Send (JdSoft.Apple.Apns.Notifications.Notification notification) [0x00000] in /Users/laurent/Downloads/Redth-APNS-Sharp-595275f 2/JdSoft.Apple.Apns.Notifications/NotificationChannel.cs:371
at JdSoft.Apple.Apns.Notifications.NotificationConnection.workerMethod () [0x00035] in /Users/laurent/Downloads/Redth-APNS-Sharp-595275f 2/JdSoft.Apple.Apns.Notifications/NotificationConnection.cs:381
I didn't put the code, as I didn't change anything from the one you can see at https://github.com/Redth/APNS-Sharp.
I send an SOS to all mono guru around.
Have a nice day fellow developers and thanks in advance for your help and time. Any suggestion is gladly welcome.
(As the OP can't post the answer himself...)
In this particular case, the solution was to fetch the latest version of Newtonsoft.Json.Compact.dll.
In general, you need to try to get as much information from the exception as possible, to find out what it was trying to load - then check that the problematic library is present, and that you've got the version everything else expects.

C# console application

I have sample exe say console.exe on "programfiles\myAppFolder" .It serves the purpose of logging the message to eventviewer
EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Warning, 234);
I need to call this exe on un-install of appcn from NSIS script .However it gives me an error always that "thisappConsole has encountered a problem and needs to close. We are sorry for the inconvenience."
Even browsing to the path "programfiles\myAppFolder\thisappConsole.exe" and manually clicking on it to execute even throws the same error. I do have admin access to m/c.
Can anyone help me with this.
If I put any other simple console app without any additional "using statements". it works fine ..
Press F5.
This will run the programme in the debugger, and you the unhandled exception will be displayed on screen. It will give a exception type, message, and line number.
Sounds to me like your event log application is throwing an unhandled exception, quite ironic considering it is an application for logging events!
I would put my money on it being a permissions issue as the event log needs to access the registry. As a work-around try running your application as an Admin. Would be handy to handle the AppDomain.UnhandledException event and log the exception.
you could try
Try
{
your app code here
}
Catch (Exception ex)
{
//Logg ex.ToString()
}
Try
{
your code here
}
Catch (Exception ex)
{
ex.message="";
}
finally
{}
Check to be sure you have the same version of the .Net framework installed on that machine, and also any referenced .dll's are in the same folder as the .exe.

Categories

Resources