Microsoft Excel application can not access the file "..." - asp.net

I don't what i dod uncorrect.
I did this steps:
To resolve this issue follow this steps
Login to the server as a administrator.
Go to "Start" -> "Run" and enter "taskmgr"
Go to the process tab in task manager and check "Show Processes from all users"
If there are any "Excel.exe" entries on the list, right click on the entry and select "End Process"
Close task manager.
Go to "Start" -> "Run" and enter "services.msc"
Stop the service automating Excel if it is running.
Go to "Start" -> "Run" and enter "dcomcnfg"
This will bring up the component services window, expand out "Console Root" -> "Computers" -> "DCOM Config"
Find "Microsoft Excel Application" in the list of components.
Right click on the entry and select "Properties"
Go to the "Identity" tab on the properties dialog.
Select "The interactive user."
Click the "OK" button.
Switch to the services console
Start the service automating Excel
Test you applica
tion again.
But i get another error - about "Retrieving the COM class factory for component with CLSID".
I loked this link http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91?prof=required
But it didn't help.

Excuse my harsh answer, but your problem is that you use EXCEL in a server environment. It was never build to support that. Microsoft advises against it, because there are many unresolved problems.
It would be better (and more stable and orders of magnitude faster) to use a library like EPPLUS to manipulate the excel files.

Related

How to generate transfer code/script in WinSCP

I have the below command I started writing to copy a file from a local box to the remote directory. I am very new to this and confused by the documentation somewhat. Can I use the "Your Command 1 and 2" params at the end to do like "c:\somefile.txt" "\in\"?
I want to do this without PowerShell, or script. Just raw command line and no additional files to import in command line args. My goal is to set up a Windows Task Scheduler job and has it run this single command.
C:\Program Files (x86)\WinSCP\WinSCP.exe /log="C:\writable\path\to\log\WinSCP.log" /ini=nul /command "open sftp://myusername#myftpsite.com/ -hostkey=""ssh-rsa 2048 wbb2bQRmDJqkaLbuYKsnGdxQ40mIIedeXChRsAYC3ig="" -privatekey=""C:\Users\my.user\Documents\SSHPrivateKey.ppk""" "Your command 1" "Your command 2" "exit"
I see some examples here… https://winscp.net/eng/docs/commandline#scripting
Can't find auto-generate code function in transfer settings for full script code...
The command to upload a file is put. You can place it instead of the "Your command 1" "Your command 2" placeholders like this:
"C:\...\WinSCP.exe" ... /command "open ..." "put C:\local\file.zip /remote/" "exit"
WinSCP GUI can generate a complete command-line including the put command for you:
Initiate a transfer in the GUI. You have to do it a way that pops up the Transfer Options dialog. The dialog does not typically show for drag&drop transfers (unless you opt for it in preferences). Instead, use the main menu or a file(s) context menu, a toolbar button or a keyboard shortcut.
On the dialog, drop down the menu at the Transfer Settings button.
Select the Generate Code command.
Generate Transfer Code Dialog opens.
On the Generate Transfer Code Dialog, select the Command-line format.

How can I connect my eclipse program to SQLite?

I am just a new programmer., can someone please give me a step by step procedure on how to connect my eclipse program to sqlite?
from http://wiki.eclipse.org/Connecting_to_SQLite
1) Download the SQLite drivers from: [1]. The actual zip file with the driver is at [2]. Expand the zip somewhere locally and note the location.
2) Put the sqlite_jni.dll from the zip into your JRE's bin directory. The driver requires this file to be in the java library path.
3) In Eclipse with DTP 1.0 installed (preferably the final build or a nightly build dated 110806 or later), go to the Preferences (Window->Preferences) and select the Connectivity->Driver Definitions page.
4) Select the "Generic JDBC" category in the Available Driver Definitions tree and click "Add...".
5) Select "Generic JDBC Driver->Generic JDBC Driver" in the Available Driver Templates tree. Give the new generic JDBC driver a name like "javasqlite JDBC driver". Click OK.
6) Click "Add Jar/Zip" and select the sqlite.jar from the driver zip you expanded in step 1. Click Open.
7) In the Properties table, select the Driver Class property and click the "..." button. If the jar is accessible, you will see a dialog appear with at lease one class in the list. Select "SQLite.JDBCDriver". Click OK.
8) Also in the Properties table, select the Driver URL property and type the following: jdbc:sqlite:/DRIVE:/dirA/dirB/dbfile
9) Click OK on the Edit Driver Definition dialog. You should see your new driver appear in the driver list on the Driver Definitions preference page.
10) Click OK to close the Preferences dialog.
11) If the Data Source Explorer is not open, open the Connectivity->Data Source Explorer view from the Window->Show View menu or open the Database Development perspective from the Window->Open Perspective.
12) In the Data Source Explorer, right-click on the Databases category and select New...
13) In the New Connection Profile wizard's Wizard Selection Page, choose the SQL Model-JDBC Connection entry in the list and click Next.
14) Give your new profile a name like "SQLiteTestDB". Click Next.
15) In the "Select a driver from the drop-down" combo box, select your new SQLite driver definition. Modify the file path in the sample URL to match the path to your local SQLite database.
16) Click "Test Connection" to verify you can connect to your database.
17) Click Finish to create the profile.
18) In the Data Source Explorer, right-click on the new profile and select Connect. You should see content appear in the tree beneath the profile. Browse through your database to view available tables and their columns.

How to fix 'Microsoft Excel cannot open or save any more documents'

I am running C# ASP.NET 4.5 web application on Windows 7 64-bit using IIS 7.5. The application pool it uses has the name 'ASP.NET v4.0' and its identity is ApplicationPoolIdentity. The application uses MS Office Interop (Microsoft Excel 14.0 Object Library).
At line wBook = wBooks.Add(Missing.Value);, it throws the following error:
Microsoft Excel cannot open or save any more documents because there
is not enough available memory or disk space.
u2022 To make more memory available, close workbooks or programs you
no longer need.
u2022 To free disk space, delete files you no longer need from the
disk you are saving to.: at
Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template)
1) I gave the account IIS apppool\ASP.NET v4.0 full control on MS Excel Application in DCOM Config.
2) I gave IIS apppool\ASP.NET v4.0 full control on 'C:\Windows\SysWOW64\config\systemprofile' and created a Desktop folder in it.
3) I need to continue using Interop though it's not recommended.
4) The application works fine on Windows Server 2003/Windows XP 32-bit.
5) MS Office 2010 (64-bit, trial version) is installed on the machine.
6) I would prefer not to change the app. pool identity from ApplicationPoolIdentity to Network Service etc.. ApplicationPoolIdentity is the new type of Identity in IIS 7 and it's recommended.
It works fine if I select 'Interactive User' (I have logged in as an admin) in DCOM Config, but it causes other problems. I need to use 'Launching User' which is ASP.NET v4.0. So it looks like it's a permission issue.
Please help.
Thank you.
Right click on the file with file explorer, choose Properties, then General tab and click on the Unblock button. This error message is very misleading.
Go to this key on Registry Editor (Run | Regedit)
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
change key Cache to something like C:\Windows\Temp
My similar problem was solved like this.
Regards,
Ripley
I had this same issue, there was no issue regarding memory in my server machine, Finally i was able to fix it by following steps
In your application hosting server, go to its "Component Services"
3.Find "Microsoft Excel Application" in right side.
4.Open its properties by right click
5.Under Identity tab select the option interactive user and click Ok button.
Check once again. Hope it helps
NOTE: But now you may end up with another COM error "Retrieving the COM class factory for component...". In that case Just set the Identity to this User and enter the username and password of a user who has sufficient rights. In my case I entered a user of power user group.
Test like this.Sometimes, permission problem.
cmd => dcomcnfg
Click
Component services >Computes >My Computer>Dcom config> and select
micro soft Excel Application
Right Click on microsoft Excel Application
Properties>Give Asp.net Permissions
Select Identity table >Select interactive user >select ok
I too encountered the same scenario and found out two solutions after googling for several times. Hope this helps.
Way 01:
Before trying to open the file in Excel, find it in Windows' File Explorer. Right-click the file and select Properties. At the bottom of the General tab, click the Unblock button. Once you unblock a file, Windows should remember and Excel should not ask you again.
This option is available for some file types, but not others. If you don't have an Unblock button, use Way 2.
Way 02:
This option is better if you usually store your downloaded Excel files in one folder. In Excel, click File » Options » Trust Center » Trust Center Settings » Trusted Locations. Click Add new location. Browse to the folder where you store your Excel files, select Subfolders of this location are also trusted, and click OK.
If none of the above worked, try these as well:
In Component services >Computes >My Computer>Dcom config>Microsoft Excel Application>Properties, go to security tab, click on customize on all three sections and add the user that want to run the application, and give full permissions to the user.
Go to C:\Windows\Temp make sure it exists and it doesn't prompt you for entering.
After giving necessary permissions in DCOM configurations I also needed to change the identity of my application in the IIS to a custom account

How do I set a default run configuration in Aptana?

When I click the run button in Aptana, my application is opened in a browser using Aptana's built-in web server.
I have a couple of run configurations set up for running on an internal server (one for chrome one for ff), but I find having to use the run button's drop down menu every time I want to run my application quite tedious. I'd rather just click the green button and have it use one of my internal server configurations.
When I press run now, a new configuration called "Default" is created using the built-in web server. Is there any way to set one of my internal server configurations as the default?
When pressing Run, it executes the last run configuration. It looks like you could bind a key to a specific configuration by using:
Assigning a keyboard shortcut for a specific Eclipse build configuration

System.Security.SecurityException when writing to Event Log

I’m working on trying to port an ASP.NET app from Server 2003 (and IIS6) to Server 2008 (IIS7).
When I try and visit the page on the browser I get this:
Server Error in ‘/’ Application.
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application’s trust level in the configuration file.
Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and the location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.]
System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly) +562
System.Diagnostics.EventLog.SourceExists(String source, String machineName) +251
[snip]
These are the things I’ve done to try and solve it:
Give “Everyone” full access permission to the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Security. This worked. But naturally I can’t do this in production. So I deleted the “Everyone” permission after running the app for a few minutes and the error re-appeared.
I created the source in the Application log and the Security log (and I verified it exists via regedit) during installation with elevated permissions but the error remained.
I gave the app a full trust level in the web.config file (and using appcmd.exe) but to no avail.
Does anyone have an insight as to what could be done here?
PS: This is a follow up to this question. I followed the given answers but to no avail (see #2 above).
To give Network Service read permission on the EventLog/Security key (as suggested by Firenzi and royrules22) follow instructions from http://geekswithblogs.net/timh/archive/2005/10/05/56029.aspx
Open the Registry Editor:
Select Start then Run. Enter regedt32 or regedit
Navigate/expand to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security
3. Right click on this entry and select Permissions
Add the Network Service user
Give it Read permission
UPDATE: The steps above are ok on developer machines, where you do not use deployment process to install application.
However if you deploy your application to other machine(s), consider to register event log sources during installation as suggested in SailAvid's and Nicole Calinoiu's answers.
I am using PowerShell function (calling in Octopus Deploy.ps1)
function Create-EventSources() {
$eventSources = #("MySource1","MySource2" )
foreach ($source in $eventSources) {
if ([System.Diagnostics.EventLog]::SourceExists($source) -eq $false) {
[System.Diagnostics.EventLog]::CreateEventSource($source, "Application")
}
}
}
See also Microsoft KB 2028427 Fail to write to the Windows event log from an ASP.NET or ASP application
The problem is that the EventLog.SourceExists tries to access the EventLog\Security key, access which is only permitted for an administrator.
A common example for a C# Program logging into EventLog is:
string sSource;
string sLog;
string sEvent;
sSource = "dotNET Sample App";
sLog = "Application";
sEvent = "Sample Event";
if (!EventLog.SourceExists(sSource))
EventLog.CreateEventSource(sSource, sLog);
EventLog.WriteEntry(sSource, sEvent);
EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Warning, 234);
However, the following lines fail if the program hasn't administrator permissions and the key is not found under EventLog\Application as EventLog.SourceExists will then try to access EventLog\Security.
if (!EventLog.SourceExists(sSource))
EventLog.CreateEventSource(sSource, sLog);
Therefore the recommended way is to create an install script, which creates the corresponding key, namely:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\dotNET Sample App
One can then remove those two lines.
You can also create a .reg file to create the registry key. Simply save the following text into a file create.reg:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\dotNET Sample App]
The solution was to give the "Network Service" account read permission on the EventLog/Security key.
For me ony granting 'Read' permissions for 'NetworkService' to the whole 'EventLog' branch worked.
I had a very similar problem with a console program I develop under VS2010 (upgraded from VS2008 under XP)
My prog uses EnLib to do some logging.
The error was fired because EntLib had not the permission to register a new event source.
So I started once my compiled prog as an Administrator : it registered the event source.
Then I went back developping and debugging from inside VS without problem.
(you may also refer to http://www.blackwasp.co.uk/EventLog_3.aspx, it helped me
This exception was occurring for me from a .NET console app running as a scheduled task, and I was trying to do basically the same thing - create a new Event Source and write to the event log.
In the end, setting full permissions for the user under which the task was running on the following keys did the trick for me:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Security
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog
I try almost everything in here to solve this problem... I share here the answer that help me:
Another way to resolve the issue :
in IIS console, go to application pool managing your site, and note the identity running it (usually Network Service)
make sure this identity can read KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog (rigth-click, authorisations)
now change the identity of this application pool to Local System, apply, and switch back to Network Service
Credentials will be reloaded and EventLog reacheable
in http://geekswithblogs.net/timh/archive/2005/10/05/56029.aspx , thanks Michael Freidgeim
A new key with source name used need to be created under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application in the regEdit when you use System.Diagnostics.EventLog.WriteEntry("SourceName", "ErrorMessage", EventLogEntryType.Error);
So basically your user does not have permission to create the key. The can do the following depending of the user that you are using from the Identity value in the Application Pool Advanced settings:
Run RegEdit and go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog
Right click in EventLog key and the select Permissions... option
3.Add your user with full Control access.
-If you are using "NetworkService" add NETWORK SERVICE user
-If you are usinf "ApplicationPoolIdentity" add IIS APPPOL{name of your app pool} (use local machine location when search the user).
-If you are using "LocalSystem" make sure that the user has Administrator permissions. It is not recommend for vulnerabilities.
Repeat the steps from 1 to 3 for HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Security
For debugging with Visual Studio I use "NetworkService" (it is ASP.NET user) and when the site is published I used "AppicationPoolIdentity".
I ran into the same issue, but I had to go up one level and give full access to everyone to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\ key, instead of going down to security, that cleared up the issue for me.
Same issue on Windows 7 64bits.
Run as administrator solved the problem.
There does appear to be a glaringly obvious solution to this that I've yet to see a huge downside, at least where it's not practical to obtain administrative rights in order to create your own event source: Use one that's already there.
The two which I've started to make use of are ".Net Runtime" and "Application Error", both of which seem like they will be present on most machines.
Main disadvantages are inability to group by that event, and that you probably don't have an associated Event ID, which means the log entry may very well be prefixed with something to the effect of "The description for Event ID 0 from source .Net Runtime cannot be found...." if you omit it, but the log goes in, and the output looks broadly sensible.
The resultant code ends up looking like:
EventLog.WriteEntry(
".Net Runtime",
"Some message text here, maybe an exception you want to log",
EventLogEntryType.Error
);
Of course, since there's always a chance you're on a machine that doesn't have those event sources for whatever reason, you probably want to try {} catch{} wrap it in case it fails and makes things worse, but events are now saveable.
FYI...my problem was that accidently selected "Local Service" as the Account on properties of the ProcessInstaller instead of "Local System". Just mentioning for anyone else who followed the MSDN tutorial as the Local Service selection shows first and I wasn't paying close attention....
I'm not working on IIS, but I do have an application that throws the same error on a 2K8 box. It works just fine on a 2K3 box, go figure.
My resolution was to "Run as administrator" to give the application elevated rights and everything works happily. I hope this helps lead you in the right direction.
Windows 2008 is rights/permissions/elevation is really different from Windows 2003, gar.
Hi I ran into the same problem when I was developing an application and wanted to install it on a remote PC, I fixed it by doing the following:
1) Goto your registry, locate: HKLM\System\CurrentControlSet\Services\EventLog\Application(???YOUR_SERVICE_OR_APP_NAME???)
Note that "(???YOUR_SERVICE_OR_APP_NAME???)" is your application service name as you defined it when you created your .NET deployment, for example, if you named your new application "My new App" then the key would be: HKLM\System\CurrentControlSet\Services\EventLog\Application\My New app
Note2: Depending on which eventLog you are writing into, you may find on your DEV box, \Application\ (as noted above), or also (\System) or (\Security) depending on what event your application is writing into, mostly, (\Application) should be fine all the times.
2) Being on the key above, From the menu; Select "FILE" -> "Export", and then save the file. (Note: This would create your necessary registry settings when the application would need to access this key to write into the Event Viewer), the new file will be a .REG file, for the argument sake, call it "My New App.REG"
3) When deploying on PRODuction, consult the Server's System's administrator (SA), hand over the "My New App.REG" file along with the application, and ask the SA to install this REG file, once done (as admin) this would create the key for your applicaion.
4) Run your application, it should not need to access anything else other than this key.
Problem should be resolved by now.
Cause:
When developing an application that writes anything into the EventLog, it would require a KEY for it under the Eventlog registry if this key isn't found, it would try to create it, which then fails for having no permissions to do so. The above process, is similar to deploying an application (manually) whereas we are creating this ourselves, and no need to have a headache since you are not tweaking the registry by adding permissions to EVERYONE which is a securty risk on production servers.
I hope this helps resolving it.
Though the installer answer is a good answer, it is not always practical when dealing with software you did not write. A simple answer is to create the log and the event source using the PowerShell command New-EventLog (http://technet.microsoft.com/en-us/library/hh849768.aspx)
Run PowerShell as an Administrator and run the following command changing out the log name and source that you need.
New-EventLog -LogName Application -Source TFSAggregator
I used it to solve the Event Log Exception when Aggregator runs issue from codeplex.
Had a similar issue with all of our 2008 servers. The security log stopped working altogether because of a GPO that took the group Authenticated Users and read permission away from the key HKLM\System\CurrentControlSet\Services\EventLog\security
Putting this back per Microsoft's recommendation corrected the issue. I suspect giving all authenticated users read at a higher level will also correct your problem.
I hit similar issue - in my case Source contained <, > characters. 64 bit machines are using new even log - xml base I would say and these characters (set from string) create invalid xml which causes exception. Arguably this should be consider Microsoft issue - not handling the Source (name/string) correctly.
My app gets installed on client web servers. Rather than fiddling with Network Service permissions and the registry, I opted to check SourceExists and run CreateEventSource in my installer.
I also added a try/catch around log.source = "xx" in the app to set it to a known source if my event source wasn't created (This would only come up if I hot swapped a .dll instead of re-installing).
Solution is very simple - Run Visual Studio Application in Admin mode !
I had a console application where I also had done a "Publish" to create an Install disk.
I was getting the same error at the OP:
The solution was right click setup.exe and click Run as Administrator
This enabled the install process the necessary privilege's.
I had this issue when running an app within VS. All I had to do was run the program as Administrator once, then I could run from within VS.
To run as Administrator, just navigate to your debug folder in windows explorer. Right-click on the program and choose Run as administrator.
try below in web.config
<system.web>
<trust level="Full"/>
</system.web>
Rebuilding the solution worked for me

Resources