Hello,
I'm having trouble trying to deploy my Windows Forms project using the Windows Installer (.msi file output). I built a simple application (C# using VS2005 running on Windows Vista) which consists of a main form with a single button, and a StreamWriter object used to create a text file in the application's startup folder. When the user clicks the button, ten integer values are written to a text file.
The application works properly when a) debugging out of Visual Studio or b) when I run the executable that gets generated by the normal build process. However, I added a Windows Installer project to the solution and specified that the primary output of my simple application should be the basis of the installation. Now, when I build and run the .msi to install the app and run it, the installed executable seems to run properly, except it doesn't generate the output file. It also does not generate any exceptions or any of the message boxes which I put into catch blocks to try to diagnose the problem.
Below is the code block from my Form1.cs file.
Thank you for looking,
Bob
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace DeploymentTester
{
public partial class Form1 : Form
{
public StreamWriter SW;
public Form1()
{
InitializeComponent();
string fname = Application.StartupPath + "\\logfile.txt";
try
{
SW = new StreamWriter(fname);
SW.AutoFlush = true;
MessageBox.Show("Opened " + fname + " for writing.");
}
catch
{
MessageBox.Show("Could not open " + fname);
}
}
private void button1_Click(object sender, EventArgs e)
{
Random rnd = new Random();
int writeVal;
try
{
button1.Enabled = false;
System.Threading.Thread.Sleep(100);
for (int i = 0; i < 10; i++)
{
writeVal = rnd.Next(100);
SW.WriteLine(writeVal.ToString());
}
button1.Enabled = true;
}
catch
{
MessageBox.Show("Could not write file data");
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
SW.Dispose();
}
}
}