WCF service connection with third party dll with IIS - c#

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.

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.

Windows Service not writing text file after installation in Windows

I have created a console based app and running fine, and same app converted into windows services. When i install it through visual studio for debugging its install and run smoothly, but when the code flow goes to change the app.config file value 0 to 1 it throw an exception UnauthorizedAccessException' and access denied.
The issue can be due to one of these 2 reasons:
If you are not accessing file using an absolute path, the service might be looking for the file at a location other than where you are expecting.
Services are started from an application called Service Control
Manager. This application lives in the system directory
%WinDir%\System32
On a Windows 7 Ultimate - 64 bits this path is actually : %WinDir%\SysWOW64
The WindowsService process could be running under an account different
from what the Visual Studio might be running under.
Either you can make the service run under an account that already has permission to the file or give permissions to the account that the service is already running under.

Microsoft.ACE.OLEDB.12.0 Provider is not registered on the Local Machine?

I am getting this error when i am trying to install VS project in a 64 bit System. I already download and install AccessDatabaseEngine . There is any other method to do that, i am using MS Access(Office 2007) database to my application. both systems are using x32 system tools **. if i am installing **AccessDatabaseEngine(x64) it is getting an error your system consists of (x32 system tools)
Try to find out your solution from here
For Web
If you have installed the AccessDataEngine and are still getting the Not Registered error
AND
you are running IIS7 on a 64 bit server,
MAKE SURE
you have enabled 32-bit applications for the application pool associated with the website. In IIS, Right click on the application pool. In the properties window, the 2nd option from the top is "Enable 32-Bit Applications". Set it to true.

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