I have started building a simple console application and ran into some weird behavior. I have isolated the problem to the below code. For some reason when the the s.replace line is executed I immediately see this in the output: "'appname.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'" and then "The program '[17680] appname.vshost.exe: Managed' has exited with code -2147023895 (0x800703e9)."
Debugging is stopped. The value in the arg for path is the full UNC path where a file is located. I want to strip the path= and use the path value. Did I skip something somewhere and VS isnt giving me an exception? I've used VS 2008 and 2010 both with the same issue. Is this because the s is an arg?
foreach (string s in args)
{
if ((s != "") && (s.ToString().ToLower().Contains("path=")))
{
string a = @"\\computer\dir\";
a.Replace("path=", "");
}
}
This may be a visual studio issue because it appears to happen on any string I assign a value. I simply added the below removing the replace and got the same response:
string a = @"value";
Path example is \computer\directory1\directory2\
I've updated the code based on suggestions but the above still has the same problem. Fails on the replace line of code.
{after yourelse(before thethrow)?void Main(string[]args){}- this could be reopened as different problem.ToLower()onsBEFORE you are checking if it is null. Also, you are not assigning a value to the return of yourReplacecall. While that doesn't cause an exception, you are essentially throwing away the result of the method call. None of these explain the problem you're having, which is why this is just a comment and not an answer.args(assuming arguments toMain) will not have null strings - so no need to check for null there.