How to change to .exe file?

Hi expert,

Currently I'm using Microsoft Visual Studio.Net to program an application.
Now I need to run the application in scheduler task.
May I know to change the program so that it can run as .exe file?
Thanx.

Regards,
Joanne84
joanne84Asked:
Who is Participating?
 
dapcomConnect With a Mentor Commented:
It seems your project is a Web Application, so there's no exe file created.

It might have been a better idea to create a Windows application?

What do you expect from the scheduled application? Is it supposed to open in a browser? Is the aspx supposed to run on your PC or on a server?

If a Web application is really what you need (or can't change it). You need to use the URL of the aspx in the web server.
If on your own PC, it must be something like : http://localhost/Seminar/scheduler.aspx, unless you configured your web server otherwise.
If on another web server, it depends where it was installed.

Did I add some light?

Dan


0
 
guidwayCommented:
when you compile your project it should create the executable automatically. You may need to search for the name of it on the computer. If you have errors during the compile it will not create the executable until they are all fixed.
0
 
joanne84Author Commented:
Hi,

The compilation is error free.
But how can I find the .exe file?

Is it namely filename.exe?

Please advise.
Thanx.

Regards,
joanne84
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
harris_cCommented:
Hi Joanne84,

The name is usually the project name.  It is in *bold* letters in the solution explorer window.

You can find the executable in the "bin" directory in your project folder.



hec",)
0
 
cookreCommented:
<ProjectDirectory> \ bin \ 'debug' or 'release'
0
 
joanne84Author Commented:
Hi,

The schedule task still show me the status: Could Not Start...

For ur information, the scheduler that I want to run is scheduler.aspx, which is inside a project namely, Seminar. I can only found Seminar.pdb and Seminar.dll in the bin folder.

I tried to run both file, also cannot. Do I need to create a new project name Scheduler instead?
Otherwise, please advise.

Thanx.

Regards,
joanne84
0
 
joanne84Author Commented:
I get what you mean.
So, now I've created a window application.
And I copied the coding in .aspx to the window application.

Where  should I put the db connection as in web application, we put it in web.config?

It shows a break point at       
dr = myCommand.ExecuteReader();

An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: The ConnectionString property has not been initialized.

I still fresh to .net, so sorry for my poor understanding...

Regards,
joanne84

0
 
dapcomCommented:
To start, just put it in your code:
    Dim myConnectionString as String = "Your connection string"
    Dim myConnection As New SqlConnection(myConnectionString)
    Dim myCommand As New SqlCommand(mySelectQuery, myConnection)
    dr = myCommand.ExecuteReader();

when it works, create an application.config file in the same folder as the exe, same name, but extension .config:
<configuration>
   <appSettings>
      <add key="ConnectionString" value="type your connection string here" />
   </appSettings>
</configuration>

Then use the ConfigurationSettings class to replace the hardcoded connection string.

myConnectionString=ConfigurationSettings.AppSettings("ConnectionString")

(you can have a look at : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vboriintroductiontoapplicationsettingstorage.asp)

Dan
0
 
joanne84Author Commented:
Hi Dan,

For your info, I'm using C#...
I've created a Form1.config to put the database configuration, but the previous error still occur...

To have clear idea of my project, below are some of the code:

[STAThread]
static void Main()
{      Application.Run(new Form1());           }

private void button1_Click(object sender, System.EventArgs e)
{      this.Close ();      }
public Form1()
{      InitializeComponent();
      Run();
}

In the Run(), I retrieve information from a userclass, which return datareader, dr.

It shows a break point at      
dr = myCommand.ExecuteReader();   //Occur in the user class file

Do you have any solution?
Thanx in advance.

joanne84
0
 
dapcomCommented:
Hi joanne84,

Thanks for the points :)

Your file should have the name of the application, not the form. In your case I think it is Seminar.config and must be in the same directory as your exe (in bin).

Did you translate the code i gave you in C# or do you need help for that?
Do you have the same error message?
It seems the connection string is not set. You must retrieve it with the

ConfigurationSettings.AppSettings("ConnectionString")

The easiest would be if you send the code of the Run() procedure (or the relevent part of it, around the error), so I can have a look at it.



Dan

0
 
joanne84Author Commented:
Hi Dan,

Thanx for your help.
I already solved the problem.

Actually, I just need to create a console application, then use a web client to call the URL of the file that I want it to run, for this case is Scheduler.aspx.

Then in the scheduler task, I call the console application's application file, then can already.

Thanx:-)

Regards,
joanne84

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.