c# System.Runtime.InteropServices.COMException: Error code : 0x800a03ec cannot access file - c#

Here i am trying to save excel file at specific path using COM.
In a local server it is working but when I user IIS server to run asp.net web application it is showing an error message as per heading.
string selected_sheet =
DropDownList1.SelectedValue.Remove(DropDownList1.SelectedValue.IndexOf("$"));
string path = Server.MapPath("~/Data/");
xlWorkBook.SaveAs(path + selected_sheet);

Related

Failed to load URL when using ABCpdf on Azure

I'm using ABCpdf to generate a PDF from HTML.
int id = theDoc.AddImageHtml(html);
It's working fine in my local environment but throws an error when running on an Azure server.
Exception:
Failed to load URL data:text/html;charset=UTF-8;base64,........
What does the error mean and how do I fix this?

UWP App proc.Start() Unable to Find the File Specified C#

I have been trying to make a UWP app using the latest Windows 10 SDK and the latest version of Visual Studio 2019 that can launch bat files, but whenever I try to launch the bat file using a Process, and error occurs when doing proc.Start(). The error is the following:
System.ComponentModel.Win32Exception: 'The system cannot find the file specified'
Currently, the code is using the ms-appx protocol, but I have tried granting the app filesystem access by editing the app manifest and granting permissions through settings and giving it the full path to no avail. Sometimes, if the full path is specified in one string (and not concatenated), it gives an access denied error, even if the filesystem access is granted to the app and the windows folder can be accessed by Everyone. Using the ms-appx protocol, all I get is The system cannot find the file specified. The error should be self-explanatory, but the same exact code has worked inside of a C# Windows Forms App, but not in the UWP C# app.
Below is my code using the ms-appx protocol:
string InstallPath = "ms-appx:///App/InstallDir"
string batDir = InstallPath + "/Binaries/Win64/";
Proc = new Process();
Proc.StartInfo.WorkingDirectory = batDir;
Proc.StartInfo.FileName = batDir + "Launcher.bat";
Proc.StartInfo.CreateNoWindow = false;
Proc.Start();
The System.Diagnostics.Process.Start() method does not work in UWP. UWP applications much run in a sandbox. For the sake of system stability, the access to other processes is not supported.
You could try to use StorageFolder.GetFileAsync(String) method with a parameter which is the same full path, and the method will return a StorageFile instance. But the same full path used in Process.Start() will cause a Win32Exception.

System.Diagnostics.Process.Start causes error "No application is associated with the specified file for this operation" when deployed

I am new to c# and have created a web form using ASP.NET 4.7.2 and Visual Studio 2019. One of my buttons links to a url using:
System.Diagnostics.Process.Start("www.google.com", "_blank");
However, when I debug my app locally, it works fine. Once I deploy the app and click on the same button, this error shows up:
Exception Details: System.ComponentModel.Win32Exception: No application is associated with the specified file for this operation
This points directly at the line where I make the call to System.Diagnostics.Process.Start.
What am I doing wrong?

External table is not in the expected format IIS Web Application problem

I have a strange error when trying to import data from files .xlsx from a web application vb.net from an "EXISTING" xlsx file with data inside. The error is throw when the action on my connection object open() is called.
The error is : System.Data.OleDb.OleDbException: External table is not
in the expected format.”
I have an application Winform who connect to a xlsx excel file and import data with the connection with no problems, the app is compile in x86 (32 bits):
MyConnectionDataExcel.ConnectionString
=("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & TxtSourceString & ";Extended Properties='Excel 12.0 Xml;HDR=YES;'")
When I'm doing the same thing in a web application, it return me the error :
System.Data.OleDb.OleDbException: External table is not in the expected format.”
I try all sort of thing, like to compile my application in 32 bits (x86), in 64 bits(x64).
I try to install this database engine 2010 :
https://www.microsoft.com/en-in/download/details.aspx?id=13255 and
this : https://www.microsoft.com/fr-fr/download/details.aspx?id=10910
I enabled too on IIS the 32 bits on my application pool.
My virtual machine is on Windows server 2012.
I found a lot of posts around that subject but no post to really help me out.
It is working for .xls files tough but not with .xlsx files.
I can call the command open when I set an other path for the file xlsx (Like a file that does'nt exist). It then create an empty file.. but that's not what I want... I want to load data from a xlsx file.
Thanks you a lot...

ASP.NET FileUpload control retrieving server path not local path

I am currently having a problem when uploading a file using a file upload control in asp.net
I have published my page using IIS on a remote server and I am accessing that link on my local computer.
Currently when im trying to upload a file I get an error saying that path not found meaning its looking for the file path that is on my pc, on the server which of course doesn't exist.
How do I get this to get the path from my pc because im trying to copy/saveAs the file from my pc to the server.
My code:
String pathCombine = System.IO.Path.Combine(destinationDirectory, Path.GetFileName(file));
File.Copy(sourcePath, pathCombine);

Categories

Resources