I wrote a Windows Forms application (C#) using the 1.1 Framework. It
receives data from an instrument connected to the USB port, processes the
data, and allows the user to save the results in a file. Naturally, the user
can open these saved files in a number of ways:
- Menu bar/toolbar shortcut
- Dragging a file from Explorer onto the application window
- Double-clicking the file in Explorer (filename extension association)
Everything works great. In English.
I then localized this application into Japanese. On the Japanese version of
Win2K and XP, my app loads its files just fine if opened from within the
application or if the file is dragged from an Explorer window onto the
application, but double-clicking the file in Explorer causes the application
to launch, then an error to be immediately displayed and the file will not be
opened.
Details:
1. I don't have the exact text of the error message in front of me, but it
has something to do with an invalid value for "startIndex" -- which is
suspicious to me, since I do not have anything in my source code that's
called "startIndex."
2. I added some logging functionality to dump the contents of the string
array passed into the Main function -- the values that are getting passed in
have nothing to do with the filename. Sometimes the folder is correct,
sometimes it is not, but usually it thinks the filename is "1".
3. Launching the application from the command prompt works fine.
Help?
I tried to write a simple app to duplicate this behavior, and was only
halfway successful. The following code reproduces this error on the Japanese
version of Windows 2000, but works fine on the Japanese Windows XP.
Thanks!
Code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace FileAssociation
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.ComponentModel.Container components = null;
public Form1(string[] args)
{
InitializeComponent();
foreach(string f in args)
{
this.textBox1.Text += (f + "\t");
}
}
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()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1));
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.AccessibleDescription =
resources.GetString("textBox1.AccessibleDescription");
this.textBox1.AccessibleName =
resources.GetString("textBox1.AccessibleName");
this.textBox1.Anchor =
((System.Windows.Forms.AnchorStyles)(resources.GetObject("textBox1.Anchor")));
this.textBox1.AutoSize =
((bool)(resources.GetObject("textBox1.AutoSize")));
this.textBox1.BackgroundImage =
((System.Drawing.Image)(resources.GetObject("textBox1.BackgroundImage")));
this.textBox1.Dock =
((System.Windows.Forms.DockStyle)(resources.GetObject("textBox1.Dock")));
this.textBox1.Enabled = ((bool)(resources.GetObject("textBox1.Enabled")));
this.textBox1.Font =
((System.Drawing.Font)(resources.GetObject("textBox1.Font")));
this.textBox1.ImeMode =
((System.Windows.Forms.ImeMode)(resources.GetObject("textBox1.ImeMode")));
this.textBox1.Location =
((System.Drawing.Point)(resources.GetObject("textBox1.Location")));
this.textBox1.MaxLength =
((int)(resources.GetObject("textBox1.MaxLength")));
this.textBox1.Multiline =
((bool)(resources.GetObject("textBox1.Multiline")));
this.textBox1.Name = "textBox1";
this.textBox1.PasswordChar =
((char)(resources.GetObject("textBox1.PasswordChar")));
this.textBox1.ReadOnly = true;
this.textBox1.RightToLeft =
((System.Windows.Forms.RightToLeft)(resources.GetObject("textBox1.RightToLeft")));
this.textBox1.ScrollBars =
((System.Windows.Forms.ScrollBars)(resources.GetObject("textBox1.ScrollBars")));
this.textBox1.Size =
((System.Drawing.Size)(resources.GetObject("textBox1.Size")));
this.textBox1.TabIndex = ((int)(resources.GetObject("textBox1.TabIndex")));
this.textBox1.Text = resources.GetString("textBox1.Text");
this.textBox1.TextAlign =
((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("textBox1.TextAlign")));
this.textBox1.Visible = ((bool)(resources.GetObject("textBox1.Visible")));
this.textBox1.WordWrap =
((bool)(resources.GetObject("textBox1.WordWrap")));
//
// Form1
//
this.AccessibleDescription =
resources.GetString("$this.AccessibleDescription");
this.AccessibleName = resources.GetString("$this.AccessibleName");
this.AutoScaleBaseSize =
((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
this.AutoScrollMargin =
((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
this.AutoScrollMinSize =
((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
this.BackgroundImage =
((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize =
((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
this.Controls.Add(this.textBox1);
this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.ImeMode =
((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
this.Location =
((System.Drawing.Point)(resources.GetObject("$this.Location")));
this.MaximumSize =
((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
this.MinimumSize =
((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
this.Name = "Form1";
this.RightToLeft =
((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
this.StartPosition =
((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
this.Text = resources.GetString("$this.Text");
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main(string[] args)
{
System.Threading.Thread.CurrentThread.CurrentUICulture = new
System.Globalization.CultureInfo("ja");
System.Threading.Thread.CurrentThread.CurrentCulture =
System.Globalization.CultureInfo.CreateSpecificCulture("ja");
Application.Run(new Form1(args));
}
}
}