On Windows 2008 application crashes instead of handling the exception - c#

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

Related

WPF Application Crashing Without throwing any Exceptions

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

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.

C# WPF OpenFileDialog causing crash in XP, not in Vista

I have a WPF application that runs fine on my Vista development machine, but not on the production XP boxes. The only problem is with a call to OpenFileDialog.Show(). As soon as I call the method, the application is terminated on the XP box.
The problem does not trigger an exception. (I've surrounded the block in a try-catch block to no avail.) When I click on File->Open the application just up and quits in XP. Interestingly, I can write files to disk with File->Save and using the Save As dialog. I've tried building it to .Net 3.0 and 3.5 but it doesn't make a difference.
I've tried both Microsoft.Win32.OpenFileDialog and System.Windows.Forms.OpenFileDialog and get the exact same symptom.
The code block for the Microsoft.Win32 variant:
try
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog().Value)
{
//do something
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error!");
}
The only clues I have is the following (partial) entry from the security event log.
Event Type: Failure Audit
Event Source: Security
Event Category: Object Access
Event ID: 560
Description:
Object Open:
Object Server: Security
Object Type: Key
Object Name: \REGISTRY\MACHINE\SOFTWARE\Microsoft\EnterpriseCertificates\Disallowed
Accesses: DELETE
READ_CONTROL
WRITE_DAC
WRITE_OWNER
Query key value
Set key value
Create sub-key
Enumerate sub-keys
Notify about changes to keys
Create link
Any ideas? (Pleeeease!)
Thanks for the advice. I verified both the registry permissions and the full-trust issue. It turns out that, although I specifically built my application to .Net 3.0 (based on the standard organizational image), there was a dependency on .Net 3.5 SP1 that I still don't fully understand. The solution to my problem was to install .Net 3.5 SP1 on all the affected computers.
I just wanted to close the loop. Thanks, again, to all who contributed ideas.
It seems there is a permission problem with the registry key. My first suggestion would be to check the permissions on that key and verify that the ACL's are correct (best compare them to another XP box where the app is working).
If the permissions are OK, then you should try reinstalling .NET (maybe the installer will reset some required permissons on the registry keys).
If all else fails, reinstall XP on problematic machines, unless someone has a better idea.
It doesn't appear your production assembly is running under full trust. Are you running from a network share?

Permanently running executable

I created a winform (monitoring) application using VS 2005 (c#), and now, I have a problem when this application crashes for some reason, I have to be sure that it will be restarted automatically.
How can I resolve this? (maybe by using windows services application?)
Thanks
Yes, a creating a Windows Service would work as you can set it to automatically restart if it crashes but a better way would be to prevent it crashing in the first place! Is there a specific reason it crashes?
With good error handling and reporting you can write it so that it simply reports any errors that occur and carries on, which IMHO would be the best route to go
Consider this:
http://msdn.microsoft.com/en-us/library/cc303699.aspx
[DllImport("kernel32.dll")]
public static extern int RegisterApplicationRestart(
[MarshalAs(UnmanagedType.BStr)] string commandLineArgs,
int flags);
Minimum supported server
Windows Server 2008
http://msdn.microsoft.com/en-us/library/aa373347(VS.85).aspx
Creating a Windows service is a very good idea for any long-running background process for many reasons, however re-starting a crashed application is not one of them!
You should work out why the application is crashing and prevent it from happening.
By all means, also convert your application to a Windows service - you will see many benefits, however the correct way to solve your problem is to fix the application crash in the first place.
For*strong text* a watcher app.
You should create a timer on the windows service and code something like this in the timer tick event:
Process[] procs = Process.GetProcessesByName("you app name");
if (procs.Length == 0)
Process.Start("your app filename");
if you really cant do anything about the crash problem i would recommend a try-catch instead of a watcher. (Dont forget to re-throw handled major exceptions)
[STAThread]
static void Main()
{
try
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
catch(Exception ex)
{
//log the exception here
Application.Restart();
}
}
Since you say that you use a Windows Forms application you cannot use a Windows Service for that, since a Windows Service is not allowed to have a GUI.
What I would do it that I would create an invisible "watchdog" application which monitors the process and automatically restarts it when it crashes.
Thanks you all, the solution I choose is : in the main program I add an exception events (UnhandledExceptionEventHandler & ThreadExceptionEventHandler see above) in these events I restart the program (also putting log & email to trace errors). And for the reboot problem I add registry key in [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] with my application path to be sure that my application will be restarted after the windows reboot ;)
You can put a try catch block around the code that is most likely causing the crash. Then write the exception message to a log file. You can also set a debug point in the catch block to see other details like call stack, etc.

COM Exception 0x800A11F9 - Cannot activate application

I have a C# 2.0 (WinForms) project in which I try to activate word 2003 (word is installed on the system). By using the following code:
private void ActivateWord()
{
this.Activate();
if (m_WordDocument != null)
{
try
{
m_WordDocument.Activate();
if (m_WordDocument.Application != null)
{
m_WordDocument.Application.Visible = true;
m_WordDocument.Application.Activate();
}
}
catch (COMException comEx)
{
ShowError(this, comEx.Message, false);
}
}
}
When my application executes m_WordDocument.Application.Activate() I receive a COM Exception 0x800A11F9.
Stacktrace:
"System.Runtime.InteropServices.COMException (0x800A11F9): Cannot activate application
at Word.ApplicationClass.Activate()
at Roxit.SquitXO.GUI.DocumentCreatie.frmSelectVeld.ActivateWord()"
What could be the cause of this problem?
COM error 0x800A11F9 is a well-known permission problem that occurs when an underprivileged user (such as Network Service) tries to activate an Office application.
In your case, the problem can't come from IIS since you're developing a WinForms application. Rather, it looks like your app is started by a Windows service running under the Local Service or Network Service user account.
If that's indeed the case, you need to change the user account used by the service in the Log on tab of the service's properties dialog box.
EDIT: You might want to try putting the code that activates Word into a COM+ component and configuring the identity of the component so it runs under a user account that can launch Word.
Just a thought i've seen a similar error when doing word automation on the server (which we no longer do due to flakiness), however at that time it was caused by permission issues from the ASP.net account, I know you are running in winforms but could this possibly be related to permissions ?
If it is a permissions problem, and you can't get Sitecore to run as a user with sufficient permissions, perhaps you could write a different service ("WordService") for your Sitecore application to send requests to. Then WordService could run as a slightly more privileged user, do your stuff with Word, then e.g. write the filled-in Word file to a known location SiteCore can access, or whatever you want it to do.

Categories

Resources