WCF + Website. File is being used by another process - asp.net

I'm getting this error:
Could not load file or assembly 'EntityFramework' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020) (C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config line 111)
The problem is that this works locally, but when I publish it at www.medicallperu.com/services/Medicall.svc/Login it gives me that error. I've no way to restart the server or anything, I just know that it works on my local server.
I'm running a WCF on the same domain that a website, I saw somewhere that this might cause an issue, like the one I'm experimenting.

I solved this by creating a Virtual Dir for my WCF instead of just having it on a subfolder of my web application.

Error
Error 12 Unable to copy file "obj\Debug\CloudKase.exe" to "bin\Debug\Some.exe". The process cannot access the file 'bin\Debug\Some.exe' because it is being used by another process.
I have solution for this error that go to the task manager and find some.exe to makes end task closed that first after that you can run the project without any bug.
Happy Coding :)

Related

WebDeploy to Azure oca failing: Insufficient acces to site folder

I am using WebDeploy (msdeploy.exe) to deploy an ASP.NET Core app to an Azure App Service instance.
This works fine most of the time, but sometimes the deployment fails with the error message: Unable to perform the operation ("Create File") for the specified directory. (...) ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER.
I believe this is some file locking issue, because the only way out of this is to log into Azure Portal and stop the App Service, and then redeploy. After this, deployment is fine for a while, until the same happens again.
Having spent some time setting up automatic deployment, this hickup is very annoying.
Is there any way around this issue?
It has nothing, as i understand, with the Azure - the error is a bit common.
As for Azure Web Apps, there are two options:
1) Stop your site and deploy.
2) If the first one is not OK, then use Kudu Console, find your file (for example, d:\home...\something.blocked) and rename the file. After that, the problem should be away
If that is the helpful answer, please mark it as a helpful or mark it as the answer. Thanks!

vs2010 publish fails: Unable to add 'app_ofline.htm' to the website

I've created an online asp.net app using VS2010 with VB. It has been online and working for over a year. It's on our company's public web server but it's only for employee use. For as long as the site has been active and in use, I have had to made periodic changes to improve performance or to fix bugs; no problem until now. Suddenly, though, VS is throwing an error during the publishing process:
Unable to add 'app_offline.htm' to the Web site. The file 'app_offline.htm' already exists in this Web site.
The IDE is set up to create the site files in a local directory on my workstation machine, and then I copy the files to the server.
The local directory does not contain the app_offline.htm file, so I don't get why the error is saying that it already exists.
It appears that even with this error, all of the files are being properly created, and the site works fine after I copy them to the server, so this is apparently not a fatal error. But it's still unnerving to me to not know why it's doing that, and why just now when it has been fine for over a year.
I would either like to find what's causing the problem and fix it or to find a way to inhibit the process of creating the app_offline.htm file. Anyone have any ideas? No search has turned up any helpful information.
Thanks!
Have you tried removing the file in question from the project, publishing again, then adding it back and publishing?
You can right click on the file(s) and choose "Exclude from project..."

P/Invoke gives AccessViolationException in ASP.NET

My goal is to call a native DLL via P/Invoke from an ASP.NET application. So far, I can successfully call the DLL from a Console app, or even from an OWIN server running on HttpListener, hosted in an Azure WorkerRole.
Troubles arise when I try to host the exact same code in ASP.NET/IIS, either in a simple ASP.NET app or in an Azure WebRole. In such a context, the call to the DLL throws an AccessViolationException.
From my research, it looks like the issue could come from the fact that the native DLL is not thread-safe - and a test trying to call it from concurrent threads even in a Console app throws the AVE, which shows that it's not thread-safe indeed. So I'm checking with the DLL's author on that.
But in the meantime, I'm still wondering if that's really the root cause of the crash on ASP.NET/IIS, because during my tests I only do one request at a time. So waiting for the thread-safety to be fixed, I wanted to know if you guys would be aware of other specificites that could cause the P/Invoke to fail in ASP.NET/IIS.
UPDATE
Based on my numerous tests, it turned out that the crash was caused by the DLL trying to load external files. In a non-IIS application, placing these files at the same folder level as the DLL just works; but on my dev machine for example, the same code running on IIS tries to look for the files in "C:\Program Files (x86)\IIS Express".
So my question now is: is there a way to control the path where a simple File.Open would look for and if not, is there a way to get the default path so that I can copy the required files there at startup?
Thanks
What you observe simply indicates that you use relative paths. That means when running under IIS Express (not IIS) the process tries to search under C:\Program Files (x86)\IIS Express as it assumes that's the base directory to use when interpreting the relative paths.
You should always use absolute paths instead of relative paths, and then this issue won't happen.
http://msdn.microsoft.com/en-us/library/ms178116(v=vs.100).aspx
Please don't muck around with copying files on every app startup, that can only go south.
A better solution would be to get the provider of the DLL to add some code that checks the Windows Registry for a path value. If that value exists in the Registry, the DLL will attempt to load its associated libraries from the path in that value; otherwise it will fall back to attempting to load them from the DLL's current directory.

Publishing failed

We are using Tridion 2011 SP1. Some of the pages/components are getting failed while publishing with below mentioned error.
Phase: Deployer Prepare Phase failed, Unable to unzip,
D:\Inetpub\TridionPublisherFS4SP\incoming\tcm_0-286137-66560.Content.zip (The process
cannot access the file because it is being used by another process),
D:\Inetpub\TridionPublisherFS4SP\incoming\tcm_0-286137-66560.Content.zip (The process
cannot access the file because it is being used by another process), Unable to unzip,
D:\Inetpub\TridionPublisherFS4SP\incoming\tcm_0-286137-66560.Content.zip (The process
cannot access the file because it is being used by another process),
D:\Inetpub\TridionPublisherFS4SP\incoming\tcm_0-286137-66560.Content.zip (The process
cannot access the file because it is being used by another process)
Components/Pages are failing under stage Preparing Deployment, how should we fix it?
Do you have multiple Deployers using the same incoming location?
It looks like you’re running the Deployer as a WebApp – is the Deployer service also running on the system?
If you search for all files named “cd_deployer_conf.xml”, do they have the same incoming folder (D:\Inetpub\TridionPublisherFS4SP\incoming) defined?
Otherwise, you might use ProcMon to watch the folder and see what else is accessing the file.
If you still have this issue, you may try
1. deleting all files under incoming,
2. making sure there is no encryption enabled for the incoming folder (Some companies apply encrypt script immediately to the files that are added to the drive) or
3. making sure your antivirus is not screening that folder (As Nuno mentioned).
Do a restart of the deployer app and verify in the logs?

ASP.NET File IO Issue - System.UnauthorizedAccessException - stranger than you think

I am getting a strange issue where I seem to have read access, because I can
1. Get a list of files from a directory (Directory.GetFiles())
2. Load an XML document using XmlDocument instance's Load() method
But I can't use File.ReadAllText() to load a text file into memory. Gives me an System.UnauthorizedAccessException. I am not even trying to read from a network directory, just a local one. I've also used System.Security.Principal.WindowsIdentity.GetCurrent().Name to check the working user which is [CompanyDomain]/[MyUserName] and this user has full access to the directory I am using. I've also checked that the directory actually exists.
My environment
1. Windows Server 2003 Standard Edition
2. Visual Studio 2008
3. Just using the built in web server that launches every time i run the project.
Note: I couldn't find the IUSR_MACHINENAME user on this machine.
Any idea what steps I should take next?
Cheers,
James
One thing to assert:
the file that can be Xml Load()-ed is the very same file that cannot be ReadAlText()-ed ?
When things get odd like this, I found that turning auditing on, at the level of the directory or even of the file, often ends up pointing me towards a proper diagnostic and hence resolving the issue.
Also: In looking online reference for ReadAllText() I noted that (oddly, I think), this exception can be caused by:
path specified a file that is read-only.
Not sure why write access should be sought by this apparent read-only operation, but, maybe just try to make the file r/w-able.
http://msdn.microsoft.com/en-us/library/72wdk8cc%28VS.71%29.aspx
<identity impersonate="true" />

Resources