C# Command Line arguments problem in Release build

  • Thread starter Thread starter Ankit Raman
  • Start date Start date
A

Ankit Raman

Guest
Hi All,

I am working on WinForms application.
I have a project where I am using Command Line Argument, It is working fine for debug configuration but when I am going for release configuration, It is throwing exception.
It is also showing the same exception on Jenkins server.


Application: VstoManifestGenerator.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentNullException
at System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding, Int32, Boolean)
at System.IO.StreamWriter..ctor(System.String, Boolean)
at VstoManifestGenerator.Program.WriteOutput(System.String, System.Object[])
at VstoManifestGenerator.Program.Main(System.String[])
my command line argument is :

C:\Dev\Applications\AddIns\Office\Outlook2010AddIn\bin\Store.Office.AddIn.Outlook.dll Debug amd64

Below is the part of the code:


static void Main(string[] args)
{
string outputDestinationFile = string.Empty;
Dictionary<string, string> movedFiles = new Dictionary<string, string>();

string target = args[0];
string configuration = args[1];
var platform = args.ElementAtOrDefault(2);

var redirections = new Dictionary<string, string>();

try
{
if (args.Count() > 3)
{
foreach (var redirect in args[3].Split(';'))
{
var r = redirect.Split('@');

var oldversion = string.Format(@"name=""{0}"" version=""{1}""", r[0], r[1]);
var newversion = string.Format(@"name=""{0}"" version=""{1}""", r[0], r[2]);

redirections.Add(oldversion, newversion);
}
}
}
catch
{
WriteOutput("Error splitting redirections: {0}", args[2]);
throw;
}

}

So, as per seeing exception, It looks like that when exe is run no arguments are passed in release mode.
Command line arguments are effective only when I start the application from visual studio.

What code should be changed to make it possible for release configuration as like debug configuration ?

Any help is appreciated.

Thanks.

Continue reading...
 
Back
Top