.NET Runtime Error Event Id 1026 - c#

I have a WPF application I have created on a Windows 8.1 machine targeting .NET runtime 4.5.1. It runs fine on the development machine.
I am trying to install it on a Windows 7 machine. It has .Net 4.5.1 installed. When I try to run it on the Windows 7 Machine the login window comes up. When I enter the password, the application verifies the password then it crashes. I have verified that it is connecting to the server to verify the password...so it's not a SQL Connection error.
So it appears that it happens when the main application windows is trying to display. Here is the info that gets recorded in the Application log. Notice the framework version. The app is targeting 4.5.1. So I don't understand why it is showing 4.0.30319.
Application: HardwarResources.WPF.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Data.Core.EntityCommandExecutionException
Stack:
at System.Windows.Window.ShowDialog()
at HardwareResources.WPF.MainEntry.Main(System.String[])
The only other pertinent information is Event ID: 1026.
HELP!

I had the same problem when I copied the .exe file (Debug or Release) to another machine and it would simply not work! Showed up in task manager for a few seconds and would disappear leaving only an ArgumentOutOfRangeException and a Kernelbase.dll error in the application event logs. So I decided to install Visual Studio on the machine where the file would not launch. After copying the project folder to a different file structure than on the original machine and hitting compiling it, I found out that I was trying to cut a string (file path) shorter than it was (due to different file structure). So the problem was in the code itself and NOT in any .dlls or .NET versions.
Hope I have helped!

Try adding an event handler to AppDomain.CurrentDomain.UnhandledException to trace more detail about the error. See here for reference on catching unhandled exceptions.
I'm thinking it's something to do with cross-threading, thread synchronization context (requiring invoke) or perhaps missing [STAThread] attribute on Main.
If you're trying to feed data to a dialog, you have to go about it in a thread-safe manner.

Related

Is There Such A Thinig As a C# Application Link Map Or Something Equivalent?

Is is there a C# build construct available that would allow me to create a link map containing symbols and offsets? I need to debug an application that is throwing an exception when running scheduled out of Task Scheduler.
Here are some details of what is going on: I have developed a C# application on Windows 10 Workstation (non-server). I am trying to run this application on Windows Server 2012 R2, which, like the Windows 10 system, has .net framework 4.5.1 installed.
The application runs with no known errors on the development workstation, whether it is run installed or out of Visual Studio 2012.
However, the application will not run at its scheduled time out of Windows Task Scheduler. This is the error 0xE0434352 -- I have been reading SuperUser and stackOverflow posts about this error -- and the Windows application event log shows an exception has occurred.
However, the offsets in the application event log are not a lot of help without having a map of the executable.
Is creating a link map or equivalent possible?
Here is a link to one description of a linker map for gcc.
in .Net the assemblies are self-describing. A debug database file is useful, but not necessary to describe the objects and how the code is structured. So I would not think a link map are relevant for .net assemblies.
You might want to take a look at dnSpy, this is a combined de-compiler, debugger and assembly editor. It is often useful when trying to debug errors. It is however limited to managed code, so it will probably be less useful if the error is in native code.

SEHException (0x80004005): External component has thrown an exception

I have developed a windows service, I can debug it using visual studio and it works as expected. But if I install the service using the installUtil.exe and start it I'm getting the following exception:
System.Runtime.InteropServices.SEHException (0x80004005): External
component has thrown an exception.
I tried cleaning the solution, uninstalled and re-installed it. I even restarted my computer but nothing changes. I tried running the windows service with my local administrator credentials but the result is the same. I can install and start the service successfully on my coworkers computer. What do you suggest to me to start the service successfully on my own computer?
I had a similar problem, where a C# service application installed on one particular computer failed to start, with the same error as above logged in the Windows Event Log.
Deleting the application's installed executable file and copying it manually from the installer image solved the problem. Hence it appears that a corrupt file can lead to that type of SEHException.

Making my app stealth (avoiding leftovers)

I have a portable app that isn't stealth. And by stealth, I mean:
"Stealth" means when an application is launched, used and terminated properly, it does not leave behind any entries in the registry or filesystem.
My app runs under .Net Framework 4.6.1 and leaves behind a log file under the folder:
%AppData%\Local\Microsoft\CLR_v4.0_32\UsageLogs\ [App Name].exe.log
Who is creating this log file?
Is there any way to avoid the creation (without breaking the app)?
What's the purpose of this log?
With Windows 8 (.NET 4.5), a new NGen mode: "Auto NGen" has been
introduced. Basically, the .NET runtime generates usage logs for
managed applications. Source
Every time the application run it creates a new type of logs called
“Assembly Usage Logs” in the AppData windows directory.
Source
On my research I found out mostly that it only does this job on Windows 8+.
But in this source it says also on Windows Server 2012, but I have tried it on a Windows Server 2012 R2 and could NOT reproduce it!
I did not find a way to disable this, one solution could be to target a lower .net Framework within our application.

Windows Service in C# works on dev machine, crashes in test environment

I have been working on an application using .NET 4 and c# in Visual Studio 2010 Express. It's purpose is to watch a directory and import any documents it finds into our imaging system.
I included an installer class which provides the information needed by installutil.exe.
So to install locally, I build the solution, and then at command line:
installutil.exe MyProjectExecutable.exe
Which installs it as a service. This works fine in my development environment.
To deploy to the test environment, I use the same method:
installutil.exe MyProjectExecutable.exe.deploy
Except of course the executable has a second extension, .deploy. This is the way the application is published by Visual Studio. Everything works up tot his point
Here is the problem: once I have done this, I run the service and it starts properly, as indicated in the log file. However, once it detects files in the directory, the service will not do anything with them and will eventually crash. The only way I can tell it has crashed is to look in the windows Event Viewer. It will show the message:
"An unhandled win32 exception occurred in MyProjectExecutable.exe.deploy [4108]. Just-In-Time debugging this exception failed with the following error: Debugger could not be started because no user is logged on."
Two questions:
1) What could be causing this
2) Am I going through the correct steps to install a windows service, or is there a better way?
Both environments have .NET 4 installed.
In both environments I am placing the same documents in the import directory.
In both environments the service runs under the Local System account.
If my question reflects a lack of C# experience, my apologies in advance.
subscribe to AppDomain.UnhandledException Event
Are you watching a directory under 'Documents and Settings?' You mention that you're running under Local System, but is that in the C# code or in the Services Panel?
Start->Run
services.msc
< Find your App >
Right-click, Properties
Log On Tab
Log On As
This Account
< Plug in a user / pass with permissions >
In my experience this it is always a security problem. Check the rights that the service running user has. Can it access the folders you are monitoring and make the needed changes?
I have found the problem. in the config file, the listen directory was "c" whereas it should have been "C". Until now, I didn't think Windows was case-sensitive. Thanks for the help guys.

.NET Winforms app dies on startup

I have a .NET Winforms app written in C# which works everywhere but on one particular machine. On that machine it dies without ever starting. There is no error message, but the following is written to the event log:
Type: Error
Source: .NET Runtime 2.0 Error Reporting
Description: Faulting application myapp.exe, version 4.2.0.0, stamp 4bcf05d0, faulting module kernel32.dll, version 5.2.3790.4480, stamp 49c51f0a, debug? 0, fault address 0x0000bef7.
There doesn't seem to be anything odd about that machine - it is one of a number of clones created with VSphere, and doesn't exhibit any other issues. The other clones run my app without any problem. It is Windows Server 2003 SP2 with .NET Framework 3.5 SP1, running Citrix, which was reinstalled after the clone to take the new name (as were the other clones).
Any advice on how to diagnose or trap the issue?
Also, I am soon going to release a new version of my app, is there anything I can do to the new version to give more information on this kind of problem?
EDIT: Thank you all for your answers, unfortunately the sysadmins for the machine decided to just rebuild it from scratch, and the problem went away. So I'll probably never know what the problem was.
Install Debugging tools for Windows on that machine, and use WinDbg to launch your application. Then it should tell what exceptions happen.
If the error is related to environment (such as missing assembly) then the app will not reach a point where you can trap & log it.
I would create a new console application and then load such app into new AppDomain and run it with ExecuteAssembly. If the errors are .NET exceptions you will be able to catch them and write to a console window.
Is your MyApp.Exe.Config a correct XML file? Open it in Visual Studio, and see if there are any errors against the XML format.

Categories