excel file reading error in C# - iis-7

i am tring to read excel file but the iis7 is giving this error:
"Microsoft Office Excel cannot access the file 'D:\Demosites\Domaininterface\Keywordsfolder\keywords2172011 23841 PM.xlsx'. There are several possible reasons: • The file name or path does not exist. • The file is being used by another program. • The workbook you are trying to save has the same name as a currently open workbook."
someone know about this?

Since the path is explicit, it sounds like a permissions issue - simply: the account that the application / app-pool is running as (in IIS) doesn't have access to that folder.
However, unless it has changed recently, you should note that Excel is not supported for use on a server - it is desktop software, and you may run into a multitude of issues using it on a server. And I have no idea whether this would be a licensed scenario ;p

Related

Error 80004005: how to troubleshoot this?

The Microsoft Jet database engine cannot open the file '\100.104.24.12\att2008\att2000.mdb'. It is already opened exclusively by another user, or you need permission to view its data.
/functions.asp, line 36
There is still a lot of detail missing to tell you definitively what the issue is, but try this anyway:
the single backslash at the start of your UNC path is wrong, it needs to be a double backslash: \\100.104.24.12
ensure that the next part of the path att2008 is a valid share, not just a regular file system folder
ensure that the credentials/identity that the ASP.NET process is running under has permissions to modify the mdb file
use a tool like ProcessMon to determine if another process is holding a lock on the mdb file

What's with all the attempts to access \\replace_with_server_name\PIPE\sql\query in my web app?

I have an ASP.NET web app that uses web forms with Telerik controls and a few other libraries, runs on windows azure, and uses sql azure. I'm using Process Monitor to see what happens on the machine during application startup (trying to diagnose why the initial startup takes about 1min but that's a separate question). I see lots of CreateFile events from the w3wp.exe process hosting my app pool that have Path = \\replace_with_server_name\PIPE\sql\query and Result = BAD NETWORK PATH. Where are these coming from!?
I've searched my source code and don't find replace_with_server_name anywhere. I'll try searching through all the referenced dlls of the solution but does anyone recognise this path and have a suggestion where it might come from?
Note that \\replace_with_server_name\PIPE\sql\query is the exact Path that I see in Process Monitor - I haven't modified it for the purposes of this question. I'm guessing some library I'm using has this value as a default, or something like that.
Update -
I've searched through all the dll and config files in my bin directory, and through all the dlls in the .NET Framework directory and through all the config files in the .NET Framework\Config directory, but haven't found "replace_with_server_name" anywhere. I've also searched various locations like all .dlls in c:\windows\system32, all files in c:\windows\Microsoft.NET, and no luck.
Any ideas on other places I can look? I did some of my searching using HxD editor and then I found PSPad which will do a hex search of multiple files - much quicker. I searched using Windows, ANSI, UTF-8, UTF-16 LE, and UTF-16 BE with no luck ... although it's possible I missed a couple of variations. Surely this text has to be somewhere!?
The CreateFile Win32 API is used to open many streams including named pipes. It looks to me like something in your code is trying to created a named pipe connection to your SQL Server, but the server name specified in the connection string is 'replace_with_server_name' by default.
You might want to take a look at your config file and/or any code that describes the name of the SQL server to which you want to connect and be sure to specify the correct server name.
HTH.

ASP.NET File Monitoring errors in Event Log

We are getting frequent errors in the Event Viewer, Application section. The source is ASP.NET 4.0.30319.0, category is File Monitoring. The Event ID is 1185. Text says "Failed to start monitoring changes to "file-path-here" because the network BIOS command limit has been reached." Then there is a reference to Microsoft knowledge base article 810886.
The question is: what process or service is doing this file monitoring, and why? We are not aware of how this is running or how it started. The monitoring seems to look at various folders on our web site, some are .NET folders, some are not.
We are looking for explanation of what is causing this monitoring; then we will try to address the errors.
When a asp.net starts to run a site, is monitoring one basic file (on the root of the web site), this is the app_offline.htm and if he finds it is stop the program showing only this file.
If find that other file change is recompile them if this is nessesary, but still showing the app_offline.htm if exist and not run the site.
Ones you remove the app_offline.htm the web pages starts run again, but asp.net still monitoring for this file - if exist or not.
So this is the monitoring of the asp.net you search for. Of course this is the default behaviour of asp.net. If you have install other software or something else have been on computer and fill it with monitoring, this is something different. I assume that you have too many web sites asp.net on the same server ? 500 or more ? if not then maybe you start searching for other software that make this monitoring of your files.
Analysis
How to find your self whats happends, download the Handle from sysinternals and run it, make the out on a text file like handle.exe >> result.txt and look the results.
http://technet.microsoft.com/en-us/sysinternals/bb896655
Look there if any suspicious program have open huge amount of files and what program is that. Monitoring files and directories are shown like
runningprogram.exe pid: 1352 ServerName\User
AC: File (RW-) D:\Monitor1
E8: File (RW-) D:\Monitor2
F8: File (RW-) D:\Monitor3
408: File (RWD) D:\InetPub\MySite
More
I check on my servers and found that a blog creation program have add a monitoring on every directory blog - I do not know why - but this is the way they have made it, to monitoring every blog for some reason, maybe you have something similar that creates a lot of file/directory monitoring for some reason.
The monitoring is being done by IIS (or the aspnet process with IIS6). It's watching for changes to files so that the site can be recompiled when needed.
You didn't mention your environment, but I used to run into this problem frequently when trying to run websites from Windows XP when the sites were located on a remote file share. I think the error comes up due to a limitation in CIFS (the network stack for file shares). Windows Server didn't seem to have the same limitations.
So, a few possible fixes:
Switch to Windows Server (or possibly Win 7)
Switch to a Web Application (doesn't allow recompiles)
Move your files from a remote share to a local drive

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" />

Publishing Web App Project with Visual Studio

I am using Visual Studio 2008 and trying to publish a Web Application Project, but it keeps failing when trying to add files in the project. Below is a sample of the message;
Publishing folder JavaScript... Unable
to add 'JavaScript/hoverIntent.js' to
the Web site. Unable to add file
'JavaScript\hoverIntent.js'. The
specified file could not be encrypted.
This happens for image files too. I am lost as to why it is happening. I should add that I am using Windows 7 build 7100, not sure if this is casuing the issue??
Any help greatly appreciated
I know this is an old topic, but I found it when I googled for the same problem.
My solution was to remove the "Encrypt" flag from Windows Explorer for the files listed (Right click -> Properties -> Advanced)
This blog post at BlackMarble is suggesting that you may have the target directory set to use encryption. Sounds like the exception you're seeing is the inability for the VS publish process to handle that.
To get around this problem:
use VS to publish to an intermediate directory. Somewhere on your PC perhaps.
copy the files yourself (with a batch file maybe) to the server
That's a workaround, at least.
Disable windows encrypted file system in cmd with the following:
fsutil behavior set disableencryption 1
Then restart your PC.
When I had this problem on publishing a Visual Studio 2010 web project either to a local folder or to a host, I was stumped. Visual Studio didn't indicate which files or even folders had caused the problem. I wasn't aware there were any encrypted files in the solution and I couldn't find any. I was unable to update my website.
I googled how to find encrypted files but none of the solutions involving efsinfo.exe were appropriate to Windows 7 then I found an example using the cipher command:
https://superuser.com/questions/58878/how-to-list-encrypted-files-in-windows-7
There were a number of different answers to finding the encrypted files. I used the command prompt method.
I opened a command prompt in the root of my application and did:
D:\Data\Code2011>cipher /s:MyWeb >Encryption.txt
I then did a case sensitive search in Encryption.txt for lines beginning E[space] or 'the file is encrypted'
I found two .htc files which were encrypted in a styles subfolder and was able to unencrypt them in the advanced tab of explorer file properties.
The Web then compiled and published OK.
I had this issue as well. I set the source files properties to not be encrypted but that still wasn't working. Turned out that the files were cached in the temporary deployment folder and I had to uncheck encryption there as well. It probably would have worked to delete the temporary deployment directory but the other way worked.

Resources