Link to home
Start Free TrialLog in
Avatar of Tertioptus
Tertioptus

asked on

My program won't run from executable.

I wrote a desktop app in C# .NET 2.0.

It does not run on my machine at work with out a lot reconfiguring be me.

I literally have to cut the application folder out of the "Program Files" directory, create a new directory with some arbitrary name, copy the contents of my application in to the new directory.  Then it works.

Also it works fine when I'm debugging it from the VS .NET C# express IDE.

I tried using TRACE, DEBUG, and even a simple text file out output to track the problem, but it seems that the code isn't even the issues, because it's not outputing anything.

I don't have this problem on other machines.
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

What is the default location for projects?  Visual Studio.NET also remembers the last place that a project was created when creating a new one.

Bob
Avatar of Tertioptus
Tertioptus

ASKER

In MyDocument>VS 2005>Projects

but I'm not even using that
>>It does not run on my machine at work with out a lot reconfiguring be me.
Can you explain you mean by "reconfiguring"?

Bob
well, the portion about moving folders around is what I meant about reconfiguring.

It's like I have the trick the OS into thinking its a brand new application,  and then it will give it a shot.

I can't even just take the folder out and put it back.  I have to do all of those steps that I previously mentioned.
What happens when you leave the application, and do "reconfigure"?

Bob
If I try to launch the app from the exe (double clicking).  Nothing happens.  So I don't do anything.

If delete the folder, and add a new one, with the same application contents, then I can launch it.

After that I change the name of the folder back to it's original name and it still works.

If build and deploy it to that folder, it will not work again.

I have to go through all those hoops to get it started.
Is this specific to this application, or every one on the same machine?

Bob
Just this application
           [STAThread]
            static void Main()
            {
            TextWriter tw = File.CreateText(@"c:\qlog.txt");

            try
            {
                tw.WriteLine("start");

                string strConn = System.Configuration.ConfigurationManager.AppSettings["DataConnection"];

                DataCom.Init(strConn.Replace("$$$", Application.StartupPath));
                tw.WriteLine("DataCom has been initialized.");

                DataCom.DataFilesPath = Application.StartupPath + @"\DataFiles\";
                tw.WriteLine("Data File Path established.");

                if (!Directory.Exists(DataCom.DataFilesPath))
                    Directory.CreateDirectory(DataCom.DataFilesPath);
                tw.WriteLine("Data File Path checked.");

                PLS.UserControls.Global.HyperLinksValidator = System.Configuration.ConfigurationManager.AppSettings["HyperLinks"];
                tw.WriteLine("HyperLinksValidator established.");

                PLS.UserControls.Global.SlideLineRatio = Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["SlideLineRatio"]);
                tw.WriteLine("SlideLineRatio established.");

                //PLS.HostManager.cHostManager.GetHostManager();//.GoClient();

                //Console.WriteLine("2");
                string[] strFiles = Directory.GetDirectories(DataCom.DataFilesPath, "Qid-*", SearchOption.TopDirectoryOnly);
                tw.WriteLine("Files gathered");

                if (strFiles.Length > 0)
                    switch (MessageBox.Show("You have rouge files in your 'DataFiles' folder, would you like to delete them.", "Data File Maintenance", MessageBoxButtons.YesNoCancel))
                    {
                        case DialogResult.Yes:
                            foreach (string strPath in strFiles)
                                Directory.Delete(strPath, true);
                            break;

                        case DialogResult.No:
                            Process.Start(DataCom.DataFilesPath);
                            break;

                        case DialogResult.Cancel:
                            break;
                    }
                tw.WriteLine("Rouge files checked");

                Application.Run(new PLS.CoreGUI.PLSApplicationContext());
            }
            catch (Exception objEx)
            {
                tw.WriteLine(objEx.Message);
            }
            finally
            {
                tw.Close();
            }

            }
Can you give me some information about the application?  What happens in the startup?  Are you getting assembly binding problems?  Fuslogvw.exe can help you debug that, if you are.

Bob
I just sent the entry point to my app, I know that the app is not getting anywhere past this point
Have you ever looked at log4net? It has a FileAppender that will let you log events pretty easily.  My guess is that the log file is not being created, because there isn't a Close call made until after the application ends.

Bob
ok, I'll give it a shot
I would like to see how far you are getting.

Bob
For the time being, I did the following.  It's still not ouputing any thing to my file.  Please excuse my hacky modification.


[STAThread]
            static void Main()
            {
            TextWriter tw = File.CreateText(@"c:\qlog.txt");

            try
            {
                tw.WriteLine("start");
                tw.Close(); tw = File.AppendText(@"c:\qlog.txt");

                string strConn = System.Configuration.ConfigurationManager.AppSettings["DataConnection"];

                DataCom.Init(strConn.Replace("$$$", Application.StartupPath));
                tw.WriteLine("DataCom has been initialized.");
                tw.Close(); tw = File.AppendText(@"c:\qlog.txt");

                DataCom.DataFilesPath = Application.StartupPath + @"\DataFiles\";
                tw.WriteLine("Data File Path established.");
                tw.Close(); tw = File.AppendText(@"c:\qlog.txt");

                if (!Directory.Exists(DataCom.DataFilesPath))
                    Directory.CreateDirectory(DataCom.DataFilesPath);
                tw.WriteLine("Data File Path checked.");
                tw.Close(); tw = File.AppendText(@"c:\qlog.txt");

                PLS.UserControls.Global.HyperLinksValidator = System.Configuration.ConfigurationManager.AppSettings["HyperLinks"];
                tw.WriteLine("HyperLinksValidator established.");
                tw.Close(); tw = File.AppendText(@"c:\qlog.txt");

                PLS.UserControls.Global.SlideLineRatio = Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["SlideLineRatio"]);
                tw.WriteLine("SlideLineRatio established.");
                tw.Close(); tw = File.AppendText(@"c:\qlog.txt");

                //PLS.HostManager.cHostManager.GetHostManager();//.GoClient();

                //Console.WriteLine("2");
                string[] strFiles = Directory.GetDirectories(DataCom.DataFilesPath, "Qid-*", SearchOption.TopDirectoryOnly);
                tw.WriteLine("Files gathered");
                tw.Close(); tw = File.AppendText(@"c:\qlog.txt");

                if (strFiles.Length > 0)
                    switch (MessageBox.Show("You have rouge files in your 'DataFiles' folder, would you like to delete them.", "Data File Maintenance", MessageBoxButtons.YesNoCancel))
                    {
                        case DialogResult.Yes:
                            foreach (string strPath in strFiles)
                                Directory.Delete(strPath, true);
                            break;

                        case DialogResult.No:
                            Process.Start(DataCom.DataFilesPath);
                            break;

                        case DialogResult.Cancel:
                            break;
                    }
                tw.WriteLine("Rouge files checked");
                tw.Close(); tw = File.AppendText(@"c:\qlog.txt");

                Application.Run(new PLS.CoreGUI.PLSApplicationContext());
            }
            catch (Exception objEx)
            {
                tw.WriteLine(objEx.Message);
            }
            finally
            {
                tw.Close();
            }
How far do you get in the log?

Bob
it doesn't get anywhere.  No output.

Unless I run it from VS.
1) Does the application process stay in memory when it is executed?

2) Have you looked at Fuse Log Viewer (Fuslogvw.exe) before?

bob
I don't think so.  I can't see any relevant processes running.  I am on Novell client for Windows though.

Also I just read up on the Fuslogvw.exe  I just don't know where to find the exe.  Should it alredy be on my machine
If you start the Visual Studio command prompt, the environment variables should be set up to allow you to type that command in and have the application start.  I believe that the .exe is installed with the SDK.

Bob
I don't have it.
I got it. Ran it.  It didn't show any errors.  I hope I'm running it right.
From the <Settings> button, did you change the 'Log Settings' to 'Log bind failures to disk'?

Bob
no
It won't do anything if you don't take it off the default setting.

Bob
I keep getting "Unable to open cache file"
Where are you getting that from?

Bob
From the fuslogvw.exe.


I think I should try loading all my libraries dynamically.  
Do you set 'Log Location' = Default in Fusion Log?  

Bob
I don't see such a property.

There is no where to choose a file path either.
On the main screen, there should be a line of buttons, and then underneath that the 'Log Location', and under that the 'Log Categories'.  If you have something different, then you aren't running the 2.0 version.

Bob
you i don't have that version.  It doesn't come with the express edition.  Do you know how i could get it?  I couldn't find anywhere to download it.
Aah, the downside of free ;)

You could try to attach to the AssemblyResolve event, which gets fired when you have assembly reference problems:

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(OnCurrentDomain_AssemblyResolve);

...

        private Assembly OnCurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
        }

Bob
Tertioptus-
Have you tried to "Clean" your solution?
This has fixed some "odd" errors for me in the past.
After Cleaning the solution, you could also "output" all of your assemblies to the "directory of choice" and run it from there.

To Clean your solution, right click on it in the Solution Explorer and click the 'Clean Solution'.
This removes any references,outputs,registry entries, ect....

Clean
Redirect out put
compile
close the ide
launch from new output directory.

Good luck
BillyDvd
I found where it's crashing.  I have a Access DB in the application's folder named DocuBase.mdb.  It crashes when I try to open the connection.

string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DocuBase.mdb;User Id=admin;Password=;";

Console.WriteLine("Get Connection");
Console.In.ReadLine();
OleDbConnection m_objConn = new OleDbConnection(strConn);
                                   
Console.WriteLine("open");
Console.In.ReadLine();
m_objConn.Open();
Gladd to hear you found it!!
Why didn't you get that exception?

Bob
I don't know, and I'm still not getting it.  I works when I'm stepping through the application.

But when I deploy to my work machine, it just crashes when i get to open.  I have it in a general try-catch block as well.

any ideas on why this would crash.  Is there something wrong with my connection string.
I even tried "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DocuBase.mdb"

to no avail

1) Is this a Console application?

2) What is the exception when it crashes?

Bob

1) I changed it to a console application for the purposes of debugging

2) I believe the app just completely terminates before an exception can be throw.  Basically I'm not getting any exceptions.
Have you tried placing some message boxes in various places to see if they pop before it crashes?
no need.  The code above sends messages to the command prompt.
The only difference I can think of between the msgbox vs console would be you might be able to "see" the real error in a nesgbox as it Hlts the code till you click the msg. in a console it will pump and continue.
i have a readline after the open
Did the exception get written to the log file?

Bob
no log file, but i don't see how the log file would be any different at this point.
do either of you know of a good example online that I can download.  To see if it's connection to a mdb file works on this machine.
To test a connection, you can create a text file with a .udl extension.  Then, when you double-click the file, it will give you a Data Link dialog to create a connection string, and a <Test Connection> button.

Bob
Create a simple win app.
add textbox as textbox1
Add these references:
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Microsoft.Data.ConnectionUI.dll
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Microsoft.Data.ConnectionUI.Dialog.dll


in the form load event or after initialize add this:
            DataConnectionDialog datadialog = new DataConnectionDialog();
            DataSource.AddStandardDataSources( datadialog );

            if ( DataConnectionDialog.Show( datadialog ) == DialogResult.OK )
            {
                this.textBox1.Text = datadialog.ConnectionString;
            }

Compile and run the exe outside of the ide.

Now you can test and see your string after it works outside of the IDE!
it does work, there is nothing wrong with string.  It just doesn't work on my work machine.  

FYI, i just download .NET 2.0 SDK from MicroSoft, which gave me the latest fuslogvw,  I will try to use it.
What happens on the work machine when you test the connection?

Bob
Doesnt the datasource need a complete "path" like "C:\\mydatabase.mdb" ?

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DocuBase.mdb;User Id=admin;Password=;";

Bob -
Off/On Subject -
I never knew about that udl extension, that is really handy!!
If you leave off the path, the database needs to be in the same location as the application.

Bob
That's how it's set.  I even tried debugging it on my work machine and it was fine.

Check this out.  I found a sample project online that updates an Access database.  And it worked at first.  But then I changed it's connection string my database, which i copied over into the project folder,  and it would not open the connection.  So then I changed the connection string back.  And it still doesn't work.
Even after I restarted the computer, the sample with it's original connection string, and database does not work anymore.

I'm thinking it has something to do with the OS, and it's registry.  How else could it eternally condemn a sample application that once worked in it's current state.
Did you try cleaning the solution before and after the string change?
Yeah, i got it to work.  Even though it's a  .NET 2.0 application, I made a setup project of the release files with VS 2003.

When I installed the new msi on my work machine, it launched.  I'm not totally sure why it works, though I still think it has something to do with the registry.

Anyways, I don't know if it's ethical to give you guys point just for your perseverance.  If you don't mind I would like to give you guys the points, because I really appreciated your efforts, though there was no solid solution given.

However, you could give your best shot at explaining why it may have worked via my new msi, and not from a copy/paste of my latest build.

let me know, thanks again
I don't need no stinkin' points, if I didn't help with a solution.

Bob
:) I figured that much Bob.  I thought I'd offer though.

keep up the good work.  your the NEO of the EE universe
I concur woth Bob :)
ASKER CERTIFIED SOLUTION
Avatar of Vee_Mod
Vee_Mod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial