all groups > dotnet windows forms > may 2005 >
You're in the

dotnet windows forms

group:

MessageBox in app started from command line


MessageBox in app started from command line Merit
5/31/2005 7:20:04 AM
dotnet windows forms:
Hi,
I'm trying to add a couple of command line switches to a windows forms
application which will perform a short operation and possibly display a
message box to the user then immediately exit.
It works fine when I run from the debugger but if I run the app from a cmd
window the messageboxes show up with no text on the form or the ok button.

This simple application shows what I mean. If I run this from the VS
debugger it behaves as I would expect, but if I run it directly from a cmd
prompt I get blank message boxes.
(this is in VS 2005 with .net 2.0 btw)

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace WindowsApplication2
{
static class Program
{
[STAThread]
static void Main( string[] args )
{
foreach (string arg in args)
{
MessageBox.Show(arg);
}

}
}
Re: MessageBox in app started from command line Merit
5/31/2005 5:43:15 PM
Testing on a different machine (without VS installed) with your code or
mine gives me the expected (correct) behavior. My personal machine has
a good bit of bleeding edge beta code on it, so I guess that something
is causing this strange result. Since it appears to usually work I'm
not going to worry about it.
Thanks for your time.
-Merit

[quoted text, click to view]
RE: MessageBox in app started from command line johnknox NO[at]SPAM online.microsoft.com
5/31/2005 8:27:57 PM
I had difficulties getting your code to build. VS did not like the 'static'
lable. Pare down the following code to fit your needs.
The following works for me in debug and if I copying the .exe and the .pdb
to a remote machine:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication7
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form1";
}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
class Program
{
[STAThread]
static void Main( string[] args )
{
foreach (string arg in args)
{
MessageBox.Show(arg);
}

}
}

}
}

Thanks

--------------------
[quoted text, click to view]

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fprq2\fcharset0
MS Sans Serif;}{\f1\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.21.2500;}\viewkind4\uc1\pard\f0\fs20 Cheers,\par
\par
johnKn [MS-SDK]\par
\par
\par
\par
-Please do not send email directly to this alias. This alias is for \par
newsgroup purposes only\par
\par
-This posting is provided "AS IS" with no warranties, and confers no
rights.\par
\par
-To provide additional feedback about your community experience please send
\par
e-mail to: sdkcomm@microsoft.com\par
\f1\par
}
AddThis Social Bookmark Button