web service .exe crashing on server - c#

I have created just a simple web service as a console application. It works fine on my dev machine and even on one of my servers. when I installed it on my production server I keep catching this error
the error that I am catching says
Retrieving the COM class factory for component with CLSID {BF97F9A2-A475-4F26-9B
5B-3A14F02D9824} failed due to the following error: 80040154.
My dev machine is 32 bit windows 7. The Server that it works on is server 2008 64bit, the server that is DOES NOT work on is also server 2008 64 bit.
any idea how to resolve this?
thanks.

Make sure the COM component you are accessing is registered.

See the answer to this post on social.msdn:
The problem was simply that the 3rd party dll required other dlls that were not on the system. So I installed the required (other) dlls and everything is fine.
Check that everything your service needs is properly installed on the server.

Related

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!!

System.Data.SqlServerCe.SqlCeException.ToString() is Throwing an exception on deployment application

I'm trying to deploy an application with Sql Compact Server 3.5 but I get an error when I try to deploy it on another pc for any database request. Indeed, the deployment works on my dev computer.
The error is a NullReferenceException on :
System.Data.SqlServerCe.SqlCeException.ToString()
But I've already followed the instructions on this link :
http://msdn.microsoft.com/en-us/library/vstudio/aa983326.aspx (the private file–based deployment)
And I'm sure that I'm using the correct dll for my 32 bits application.
What could be my problem?
Thank you for any help.

FATAL: Could not find component we just installed

I have to do a modification on an old COM+ app written in C# 2.0. But when I try to register the DLL on a windows server 2008 machine with 'regsvcs excelserver.dll', I get the error:
The following installation error occurred:
1: FATAL: Could not find component 'Excelserver.CExcelManager' we just installed
I tried to run in as admin, and turned off UAC, but it doesn't make a difference.
If I try it on a windows 7 or windows server 2003 machine, it works.
Any ideas why this doesn't work on a windows server 2008 machine? It seems I don't find any additional logging in the event log.
Thanks,
L
You need to register using the 64-bit version of regsvcs instead of the 32-bit version.

WCF service connection with third party dll with IIS

I am working with Windows 7, VS2010, SqlServer 2008.
My application takes data form a third party dll (which takes data from another process that must be running in the background) and processes the data and send it over a WCF service to the front end.
The application is done and does what it supposed to do. Now when I want to distribute it and Run it in IIS. I am facing a strange problem. The application get the data from a dll when I run it in IIS it fails and gives an error while connecting to the dll.
Retrieving the COM class factory for component with CLSID
{FCEC6861-5866-4F9E9A09-7CC868C30A8B} failed due to the following
error: 80070005 Access is denied. (Exception from HRESULT:
0x80070005 (E_ACCESSDENIED)).
After some research I found out going to component service and inside DCOM config I change the security of the dll to everyone. The error stopped.
But now I don't get the error but I don't get the data like when the software which provides the data is closed. But work ok with my ASP.net development server.
Also I found that when I run Visual Studio in administrator mode I must run the third party data software in administrative mode too.
The dll reference is not copied in bin folder automatically, it put in obj folder and I manually copied it but it does not work.
What I think happens is that the COM component is running in the same context as the caller and it needs elevated permissions to perform its job.
So:
VS in admin mode, COM in admin mode, works because both are having system wide permissions to perform their work.
IIS running under app pool account (not sure which), COM will also be under that account, but it is not an administrator, so too low on permissions to do the work correctly.
My troubleshooting suggestion would be to have the IIS application pool that your app is running under changed to be local admin. If that works OK, restore the access rights on your DCOM to the defaults (before changing to everyone) and try again. You might also try to run the app pool under the local system account to see what happens. If that still works, you have confirmed this behavior to be the problem.

p/invoke dll loads fine on dev machines but distributed applications (xp/windows7) p/invoke .dll cannot be found

We built a project in c# that uses a .dll which we use p/invoke to access functions within the .dll. It works on our development machines, we can create an installation version of our software which runs fine but if we load it on other xp machines and windows 7 machines which aren't dev machines it reports an error that the .dll that it is trying to p/invoke cannot be found. The error is repored as the 'the application has failed to start because its side by side configuration is not correct.'
What are we doing wrong?
Thanks, Ron.
Try installing the VC++ redistributable.
Also check that the dll is in the path. It does make a difference, I swear!

Categories