?
Solved

My program won't run from executable.

Posted on 2007-08-06
62
Medium Priority
?
381 Views
Last Modified: 2013-11-26
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.
0
Comment
Question by:Tertioptus
  • 29
  • 23
  • 8
  • +1
61 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19639609
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
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19639634
In MyDocument>VS 2005>Projects

but I'm not even using that
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19639648
>>It does not run on my machine at work with out a lot reconfiguring be me.
Can you explain you mean by "reconfiguring"?

Bob
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 5

Author Comment

by:Tertioptus
ID: 19639692
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19639736
What happens when you leave the application, and do "reconfigure"?

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19639779
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19639792
Is this specific to this application, or every one on the same machine?

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19639817
Just this application
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19639840
           [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();
            }

            }
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19639845
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
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19639850
I just sent the entry point to my app, I know that the app is not getting anywhere past this point
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19639868
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
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19639902
ok, I'll give it a shot
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19639959
I would like to see how far you are getting.

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19640542
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();
            }
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19640586
How far do you get in the log?

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19640627
it doesn't get anywhere.  No output.

Unless I run it from VS.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19640685
1) Does the application process stay in memory when it is executed?

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

bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19640767
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
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19640779
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
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19640828
I don't have it.
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19641069
I got it. Ran it.  It didn't show any errors.  I hope I'm running it right.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19641157
From the <Settings> button, did you change the 'Log Settings' to 'Log bind failures to disk'?

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19641385
no
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19642982
It won't do anything if you don't take it off the default setting.

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19645447
I keep getting "Unable to open cache file"
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19645867
Where are you getting that from?

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19646620
From the fuslogvw.exe.


I think I should try loading all my libraries dynamically.  
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19647052
Do you set 'Log Location' = Default in Fusion Log?  

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19647772
I don't see such a property.

There is no where to choose a file path either.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19647798
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
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19648065
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19648157
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
0
 
LVL 11

Expert Comment

by:William
ID: 19651373
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
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19654620
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();
0
 
LVL 11

Expert Comment

by:William
ID: 19654639
Gladd to hear you found it!!
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19654669
Why didn't you get that exception?

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19654726
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.
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19654734
I even tried "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DocuBase.mdb"

to no avail

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19654739
1) Is this a Console application?

2) What is the exception when it crashes?

Bob

0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19654801
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.
0
 
LVL 11

Expert Comment

by:William
ID: 19654818
Have you tried placing some message boxes in various places to see if they pop before it crashes?
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19654861
no need.  The code above sends messages to the command prompt.
0
 
LVL 11

Expert Comment

by:William
ID: 19654894
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.
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19654957
i have a readline after the open
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19655047
Did the exception get written to the log file?

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19656513
no log file, but i don't see how the log file would be any different at this point.
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19656526
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19656576
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
0
 
LVL 11

Expert Comment

by:William
ID: 19656744
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!
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19656891
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.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19657642
What happens on the work machine when you test the connection?

Bob
0
 
LVL 11

Expert Comment

by:William
ID: 19657997
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!!
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19659158
If you leave off the path, the database needs to be in the same location as the application.

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19659237
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.
0
 
LVL 11

Expert Comment

by:William
ID: 19659432
Did you try cleaning the solution before and after the string change?
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19670250
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
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19670517
I don't need no stinkin' points, if I didn't help with a solution.

Bob
0
 
LVL 5

Author Comment

by:Tertioptus
ID: 19670617
:) I figured that much Bob.  I thought I'd offer though.

keep up the good work.  your the NEO of the EE universe
0
 
LVL 11

Expert Comment

by:William
ID: 19670819
I concur woth Bob :)
0
 
LVL 1

Accepted Solution

by:
Vee_Mod earned 0 total points
ID: 19722192
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question