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?
Related
TextWriter textWriter = new StreamWriter(#System.Environment.GetEnvironmentVariable("OUTPUT_PATH"), true);
when I run this, I am getting the following error.
Exception thrown: 'System.ArgumentNullException' in mscorlib.dll An unhandled exception of type 'System.ArgumentNullException' occurred in mscorlib.dll Value cannot be null.
How to fix it?
Environment Variable OUTPUT_PATH is not set.
System.Environment.GetEnvironmentVariable("OUTPUT_PATH")
This statement is returning null.
Please check environment variables to confirm if path is correctly set or not.
If path is there, then there may be access privilege issue. Your code may not have permissions to read the environment variable.
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.
I'm following a selenium C# tutorial and I'm in the first stage. So when I run my console application I got the following error.
An unhandled exception of type 'System.InvalidOperationException'
occurred in WebDriver.dll
Additional information: unknown error: unrecognized Blink revision:
3b3c00f2d95c45cca18ab944acced413fb759311
And in the console it says
Only local connections are allowed
My code
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://www.google.lk");
}
}
try downloading the driver and give its path to constructor - LINK
driver = new ChromeDriver(DRIVER_PATH);
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?
I am writing a code to copy files from one directory to another. I am picking the file path from a 2D array.
for (int row = 1; row <= numRows; ++row)
{
path = valueArray[row, 13].ToString();
fileName = valueArray[row, 4].ToString();
CopyDirectory.myCopy(path, "C:\\TestCopyDest", fileName);
}
The above program copies the first directory well. However, it then generates an exception:
A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll.
What should I do? Do I need to create different threads for copying?
A First Chance Exception doesn't mean your code has a problem.
Read the above link.
I think this will help you
First chance means the program hasn't been able to deal with it yet, the debugger comes first. When you let it through, the app will deal with it nicely, so you don't get errors.
You should set up Visual Studio to ignore thrown (1st chance) exceptions, and only break on unhandled ones.
Comment out the action line and write out the contents of your strings to make sure you're getting valid paths and don't have dupe file names:
Console.WriteLine("path: " + path + ", file: " + fileName);
//CopyDirectory.myCopy(path, "C:\\TestCopyDest", fileName);
Did you mean to copy everything into 1 target folder?
Your program is running as a 64-bit process. Your DLL contains 32-bit unmanaged code.