1

Closed

CommandLineParser Exception

description

var cmd = CommandLineDictionary.FromArguments(Environment.GetCommandLineArgs()); throws following exception:
 
System.ArgumentException was unhandled
Message="Unsupported value line argument format.\r\nParametername: D:\_Workspace\Projects\TheGamesFramework\bin\x86\Debug\TheGamesFramework.Engine.vshost.exe"
Source="FrameworkUtilities"
ParamName="D:\_Workspace\Projects\TheGamesFramework\bin\x86\Debug\TheGamesFramework.Engine.vshost.exe"
StackTrace:
   bei Microsoft.Test.CommandLineDictionary.AddArgument(String argument) in D:\Downloads\Development\Libs\TestApi v.0.2\Sources\FrameworkUtilities\CommandLineDictionary.cs:Zeile 189.
   bei Microsoft.Test.CommandLineDictionary.FromArguments(IEnumerable`1 arguments, Char keyCharacter, Char valueCharacter) in D:\Downloads\Development\Libs\TestApi v.0.2\Sources\FrameworkUtilities\CommandLineDictionary.cs:Zeile 91.
   bei Microsoft.Test.CommandLineDictionary.FromArguments(IEnumerable`1 arguments) in D:\Downloads\Development\Libs\TestApi v.0.2\Sources\FrameworkUtilities\CommandLineDictionary.cs:Zeile 71.
   bei TheGamesFramework.Core.Managers.ConfigManager.ProcessCommandArgs() in D:\_Workspace\Projects\TheGamesFramework\Core\Managers\ConfigManager.cs:Zeile 59.
   bei TheGamesFramework.Core.Managers.ConfigManager.LoadConfiguration(Boolean processCommandArgs) in D:\_Workspace\Projects\TheGamesFramework\Core\Managers\ConfigManager.cs:Zeile 174.
   bei TheGamesFramework.Engine.MainWindow..ctor() in D:\_Workspace\Projects\TheGamesFramework\Engine\MainWindow.xaml.cs:Zeile 37.
   bei TheGamesFramework.Engine.App.StartupClient(StartupEventArgs e) in D:\_Workspace\Projects\TheGamesFramework\Engine\App.xaml.cs:Zeile 65.
   bei TheGamesFramework.Engine.App.OnStartup(StartupEventArgs e) in D:\_Workspace\Projects\TheGamesFramework\Engine\App.xaml.cs:Zeile 42.
   bei System.Windows.Application.<.ctor>b__0(Object unused)
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   bei System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   bei System.Windows.Threading.DispatcherOperation.InvokeImpl()
   bei System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   bei System.Threading.ExecutionContext.runTryCode(Object userData)
   bei System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   bei System.Windows.Threading.DispatcherOperation.Invoke()
   bei System.Windows.Threading.Dispatcher.ProcessQueue()
   bei System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   bei System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   bei System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   bei System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   bei MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   bei System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   bei System.Windows.Threading.Dispatcher.Run()
   bei System.Windows.Application.RunDispatcher(Object ignore)
   bei System.Windows.Application.RunInternal(Window window)
   bei System.Windows.Application.Run(Window window)
   bei System.Windows.Application.Run()
   bei TheGamesFramework.Engine.App.Main() in D:\_Workspace\Projects\TheGamesFramework\Engine\obj\x86\Debug\App.g.cs:Zeile 0.
   bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   bei System.Threading.ThreadHelper.ThreadStart()
InnerException:
Closed Feb 10, 2011 at 10:49 PM by ivom
Overlord,I am closing this issue. Please reactivate if you still need help.ivo

comments

alexisr wrote Jul 23, 2009 at 7:29 PM

Hi Overlord,

The CommandLineDictionary is designed to recognize key/value pairs of the form ‘/key=value’. The error is saying that one of the string arguments being passed into CommandLineDictionary.FromArguments is: D:\_Workspace\Projects\TheGamesFramework\bin\x86\Debug\TheGamesFramework.Engine.vshost.exe
Which is not of key-value pair form. Given that you are using Environment.GetCommandLineArgs, it is possible that you have a space between the key and value, which causes Environment.GetCommandLineArgs to split them. In that case you can either a) remove the space, or b) encapsulate the overall key-value pair in quotes.

Hope this helps!

Overlord123 wrote Jul 23, 2009 at 8:08 PM

The path to the exe is automatically passed as a command line parameter by the .NET Framework and not by me.
http://msdn.microsoft.com/en-us/library/system.environment.getcommandlineargs.aspx See Remarks.

wrote Aug 26, 2009 at 5:44 PM

wrote Feb 10, 2011 at 10:49 PM

wrote Feb 14, 2013 at 9:08 PM

wrote May 16, 2013 at 11:02 AM