Windows service only working on my local machine - c#

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.

Related

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.

Service Fabric Deployment Error: "Could not load file or assembly or one of its dependencies"

I'm getting the error "Could not load file or assembly {project dll} or one of its dependencies. The specified module could not be found" when attempting to publish a service fabric application to a cluster.
This application publishes to the local cluster without any problem, and runs exactly as expected. However, when I attempt to publish the application to the cluster, it fails, stating that a project dll cannot be found.
The missing dll is in the list of dlls that get packaged with the application, and all of its dependencies are non-local (system.dll, system.net.dll, etc.). The project is built for x64 to run with Service Fabric.
This answer worked after restarting the machines after the installation. I also packaged a release build to keep debug dlls out.

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.

C# - InstallUtil 32bit installs service but throws error on startup

I've been working on a Windows Service off and on for some time now and I have finally finished it. On my local machine (Win7, 64bit, .NET 4.5, VS 2013), I've been able to successfully install and run the service which takes info from a website and places it in a SQL table.
Now I want to install this service on a different computer on the network, and it has to be this computer because I've been told to do it like this.
The other computer is running 64 bit Windows Server 2003 R2.
My problems arise when I try to install the service. I'm using plain old command prompt because I do not have the VS command prompt. The code is:
C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe C:\MyService.exe
Doing this gives me the error "Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'filepath' or one of its dependencies. An attempt was made to load a program with an incorrect format.."
So I tried doing this instead:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>InstallUtil.exe C:\MyService.exe
Using this 32 bit InstallUtil.exe seemed to work as the service would install successfully and it showed up in my services.msc list. When I try to start the service I then get this error message: "Could not start the service on Local Computer. Error 193: 0xc1"
I'm getting really frustrated/confused with this, so any help what-so-ever would be greatly appreciated!! Thanks for reading.
<---------------------------------------------EDIT---------------------------------------->
I've changed the configuration to Release and Any CPU, copied and pasted it to the server via Network Folder and installed it once again. Still getting the same error.
<---------------------------------------------EDIT---------------------------------------->
The answer is in my post below if anyone is wondering, or are having the same issue I was.
And I've figured it out. Where I was using Windows Server 2003, it tends to like the .NET 4 Framework and where the service was developed in Visual Studio 2013 it defaults to the .NET 4.5 Framework. All I had to do, along with several edits to make the service a bit more efficient, was change the target in the VS project to the .NET 4 Framework and rebuild/reinstall on the server.
It has now started without an issue and is communicating with the SQL server as intended. Big thanks to Hans Passant for pointing me in the right direction, I would more than likely still be in the process of figuring this out. So thanks!!

StreamInsight Service on Windows doesn't recognize the application dlls

I have my project worked fine with embbed stream insight instance.
But when I tried to use the standardalone StreamInsight service on Windows, I got an exception when this code is run
using (matchQuery.Bind(sink).Run())
An exception of type 'Microsoft.ComplexEventProcessing.ConnectionException' occurred in Microsoft.ComplexEventProcessing.Diagnostics.dll
It said that The management service encountered an error: Could not load file or assembly 'MyApplication, Version=1.0.5198.16312, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
My question
1. Why doesn't StreamInsight recognize the dlls?
2. Do I need to installing the dlls to GAC?
Im using StreamInsight 2.1
My system is 64 bit.
My project is configurated with any CPU.
Put your dlls to the debug folder and restart the windows service.

Categories