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

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.

Related

Windows service can't connect to OracleDB when installed but working ok when debugging

So I wrote service that is constantly checking some folder and if there are files, they are uploaded to Oracle Database.
Everything is working fine when I'm running it in Visual Studio in debug mode. But when I'm doing release and installing actual service and run it, it throws oracle exception when trying to connect:
Could not load file or assembly 'Oracle.DataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Service is running and working and writing this exception to log file, so this is not direct service problem. I'm installing this service on same machine where I run debugging so Oracle client is installed and working fine. I also tried to install in on another machine but it trows same exception.
My guess is that there is some problems with rights and how service runs but since it's my first windows service I have no idea where exactly problem is and what to look for. It's installing as local service, when debugging it's running as my user (if I'm correct).
Thanks everybody. It was indeed 62/32 version problem. It was 64 bit oracle client installed and debugging was in 64 bit mode but I didn't notice that this setting is completely separate for debugging and release, now changed release to strictly x64 and it's working.

Windows service only working on my local machine

I have developed a windows service which has been working fine, but when I use installutil to install it on any machine other than my own I receive an error stating "Exception Occurred while initializing the installation: Unable to load file or assembly [WindowsServiceName].exe or one of its dependencies. Operation is not supported". Is there something in the build of my project that would cause this? I am unable to find any errors in the event log. It is like it cannot even find the file, but I have verified the path.
Answering my own question. I had to right click and unblock each DLL file in the project. Once I did that the service installed on the remote machine.

Exchange Web Service program work at development station but not on the other

I wrote a program which work with Exchange Mailbox and it seems to work fine,
but if i copy the .exe file from debug folder to another PC and run the .exe i got tis exception
Unhandled Exception: System.IO.FileNotFoundException: COuld not load file or assembly 'Microsoft.Exchange.WebServices, Version=15' ... or one of its dependencies. The system cannot find the file specified
I installed EWS Managed API and add reference to Microsoft.Exchange.Webservices in the project and on development machine it works fine. But when i run it on another PC it throw the reference error. Must i install that EWS Management API to production PC too or its only needed for development, how can i solve this error ? Thank you
Solution: Installing Microsoft Exchange Web Services Managed API 2.1 on client machine helped.

Published application cannot start, but release/debug version starts well

I have a problem when I try to Run published Application. When I Run Release or Debug Version from VS (key F5) everything work well. So I try to publish my application (no problem). After this I Installed application by oneClick installer. Instalation was finished without problem, but when I try to run this installed application, I only see message: Program has Stop Working.
Please, does anybody know where should be a problem? It´s really wierd, I suppose, when the application run correctly from VS, then it Should run after installing to!? Or am I wrong?
Or is there some option to reset Publish settings in Visual Studio?
Thanks a lot!!!
It depends how you have ClickOnce setup, but the main reason this happens is the ClickOnce system encounters an error while checking for updates or running the .application from the remote location.
It should give you the option to see a log of the problem (or at least the nasty temp file it threw it in).
From here you can determine the problem ClickOnce is having.
Most Common Problems I would Suspect:
The User's having trouble communicating thier auth token / credentials to the web server the ClickOnce app is on.
There's another web-related issue downloading the app manifest or .application from the server
Group / Local Policy Problems
Broken install in on local machine's ClickOnce somewhere causing it to have problems overwriting on disk or finding an appropriate location to setup the clickonce package.
Broken install in on local machine's ClickOnce causing a GUID Conflict (I.e. your app and the broken install can't be upgraded, but share the same GUID)
Antivirus / Firewall blocking access to the web component from the executable clickonce deploy.
These are all the problems I've encountered with ClickOnce and the reasons we've primarily moved away from it to a Wix style installer.

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.

Categories