we just have a excelpackage object given, which was saved using SAVEAS(file) correctly. But when I try to save_as another time (after re-arranging worksheets), then it will be thrown this exception:
An unhandled exception of type 'System.InvalidOperationException'
occurred in EPPlus.dll
Error saving file (report.xlsx)
Already using the latest version 4.0.5 EPPLUS.
Also tried the other post without luck:
var reportFileInfo = new FileInfo(reportFile);
if (reportFileInfo.Exists)
reportFileInfo.Delete();
ExcelReportStream.SetLength(0);
ExcelReport.Stream.Position = 0;
ExcelReport.Stream.CopyTo(ExcelReportStream);
using (var excelToSave = new ExcelPackage())
{
excelToSave.Load(ExcelReportStream);
excelToSave.SaveAs(reportFileInfo); <<<<< EXCEPTION again!
}
An unhandled exception of type 'System.InvalidOperationException'
occurred in EPPlus.dll
Error saving file (report.xlsx)
The ExcelPackage is a property and with the first try, it will be ExcelPackage.SaveAs(reportFile) works on first time. But not on second.
No further information from the compiler...
Any ideas?
Thank you.
Related
I'm having troubles setting columns format in Excel with Interop. I'm using C#, below is the code:
Excelop.Range rg = (Excelop.Range)wb.Worksheets[1].Cells[1, i];
rg.NumberFormat = "#"; //Exception is raised here
I get the below exception when compiled:
"An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: Unable to set the NumberFormat property of the Range class"
Appreciate your support.
My guess is that your worksheet is protected.
You likely need to do something like:
wb.Worksheets[1].Unprotect (Password:"your_password")
These may be of assistance:
https://www.mrexcel.com/forum/excel-questions/449829-run-time-error-1004-unable-set-numberformat-property-range-class.html
"Unable to set the NumberFormat property of the Range class"
I am trying to generate/run some report by querying work items from TFS using C#.
Referred this link. This code worked fine couple of months back and was able to retrieve the results.
Not sure why am getting below exception at Line 2
var tfsUrl = ConfigurationManager.AppSettings.Get("TfsCollection");
var uri = new Uri(tfsUrl);
var projCollection = TfsTeamProjectCollectionFactory
.GetTeamProjectCollection(uri);
//var workItemStore = projCollection.GetService<WorkItemStore>(); //Line 1
var workItemStore = new WorkItemStore(projCollection); //Line 2
Tried other ways of querying work items like Line 1, but no luck. Any help here would be highly appreciated. Also, is there any better way of querying TFS using C#?
Exception details:
A first chance exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
Additional information: Value cannot be null.
System.ArgumentNullException occurred
_HResult=-2147467261
_message=Value cannot be null.
HResult=-2147467261
IsTransient=false
Message=Value cannot be null.
Parameter name: value
Source=mscorlib
ParamName=value
StackTrace:
at System.Enum.TryParseEnum(Type enumType, String value, Boolean ignoreCase, EnumResult& parseResult)
InnerException:
My bad. Enabled this option in VS.
Debug -> Exceptions -> CLR exceptions
Code will execute despite of the exception.
I am hoping that someone who has worked with ArangoDB and .Net and C# can help me out.
When I call ArangoClient.AddConnection() an exception gets thrown (of type 'System.ArgumentException' occurred in mscorlib.dll). The message is "An item with the same key has already been added."
The call to ArangoClient is: ArangoClient.AddConnection("127.0.0.1", 8529, false, "NancyTest", "NancyTest", "root");
Any ideas?
You most probably already created a connection with specified alias. With a driver version 0.9.0 and higher you can check if the specified alias already exists through ASettings.HasConnection(string alias) static method.
I have some program on my 1st pc (everytinh works fine)
but when I copy my full project to another PC and try to run application I get this error :
A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Formaty identyfikatorów URI nie są obsługiwane.
If there is a handler for this exception, the program may be safely continued.
and than:
A first chance exception of type 'System.BadImageFormatException' occurred in Emgu.CV.dll
Additional information: Próbowano załadować program w niepoprawnym formacie. (Wyjątek od HRESULT: 0x8007000B)
If there is a handler for this exception, the program may be safely continued.
in this code:
BackgroundSubtractorMOG2 pMog11 = new BackgroundSubtractorMOG2(0, 80, false);
I have really have no idea what to do with this. What is the problem with Emgu.CV in the 2nd pc?
Here is the code I am working with:
p = new Process();
p.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "\\scan.cmd";
p.Start();
p.WaitForExit();
// Read the file and display it line by line.
string line;
System.IO.StreamReader file = new System.IO.StreamReader("\\log.txt");
while((line = file.ReadLine()) != null)
{
itemBeiingScanned_Label.Content = line;
}
file.Close();
When building it runs everything up until this point and then throws two identically worded unhanded exception's:
Exception:
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: The invocation of the constructor on type 'SpywareKing.MainWindow' >that matches the specified binding constraints threw an exception.
If there is a handler for this exception, the program may be safely continued.
Any insight would be appreciated-- I can provide more information if there is something that you need to help with looking into the root of the problem.
Here is some potentially useful information from the debug console in Visual Studio:
'SpywareKing.vshost.exe' (CLR v4.0.30319: SpywareKing.vshost.exe): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero2\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero2.dll'. Symbols loaded.
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
A first chance exception of type 'System.Xaml.XamlObjectWriterException' occurred in System.Xaml.dll
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: The invocation of the constructor on type 'SpywareKing.MainWindow' that matches the specified binding constraints threw an exception.
The thread 0x33dc has exited with code 0 (0x0).
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: The invocation of the constructor on type 'SpywareKing.MainWindow' that matches the specified binding constraints threw an exception.
The program '[13492] SpywareKing.vshost.exe' has exited with code 0 (0x0).
Most probably the line
System.IO.StreamReader file = new System.IO.StreamReader("\\log.txt");
is the cause of the error. You cannot safely assume that the current directory is the one where the log file resides. Always specify the full path.
string logFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log.txt")
System.IO.StreamReader file = new System.IO.StreamReader(logFie);
The current directory can change at any time when the user is selecting a directory in a FileOpenDialog or FileSaveDialog. It's not automatically the applications directory. Also the applications directory will be \SolutionFolder\ProjectFolder\bin\Debug when debugging. Is this the directory you are looking for?