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] >Thread-Topic: MessageBox in app started from command line
>thread-index: AcVl69bKz9Eae6AiQqCTGK944xOMGA==
>X-WBNR-Posting-Host: 57.67.17.3
>From: "=?Utf-8?B?TWVyaXQ=?=" <Merit@discussions.microsoft.com>
>Subject: MessageBox in app started from command line
>Date: Tue, 31 May 2005 07:20:04 -0700
>Lines: 31
>Message-ID: <D8C85D32-C8CE-4CE8-8D0D-789AFC42BD5B@microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.dotnet.framework.windowsforms
>NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
>Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
>Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.windowsforms:21201
>X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
>
>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);
> }
>
> }
> }
>}
>
{\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
}