views:

388

answers:

5

I want to create a window based application in C# so that we can run it without installing the application into each and every system. It need to connect that application through database as well.

I want to create this application so that it can be run directly through pendrive and can write into database as well.

I know how to work with database though window application but with installer only.

I have created many window application but all runs on client machine after Installing the deployed setup. But now i want client need not install the setup deployed. He can use my application by directly clicking my executable file

A: 

If you just want to connect to a database, you can do that in the EXE without any kind of installer needed. How that is done would depend on which database it is, and how you are connecting to it, but generally the item that requires encoding in the EXE (or in an outboard XML file which the EXE can read) is a connection string. This connection string is probably what the installer is managing.

A good tutorial on building your first Windows application in C# can be found here: http://msdn.microsoft.com/en-us/library/360kwx3z.aspx

Robert Harvey
I know how to interact with database, but I also need window application. So that any user can enter data through GUI interface
Shantanu Gupta
So build one. If you are using Visual Studio or Visual Studio Express, select "Windows Application" from the File/New dialog.
Robert Harvey
Start here: http://msdn.microsoft.com/en-us/library/360kwx3z.aspx
Robert Harvey
@Robert Harvey is it possible to create a something like exe that dont need any installation. But start GUI window
Shantanu Gupta
@Robert Harvey Question elaborated, Plz check
Shantanu Gupta
Yes, you select "Windows Application" from the File/New dialog in Visual Studio, create your application, and build. It will create a single executable file that can be copied to any Windows computer and executed.
Robert Harvey
The example program at http://msdn.microsoft.com/en-us/library/360kwx3z.aspx runs without an installer.
Robert Harvey
A: 
Lukas Šalkauskas
+7  A: 

There is nothing in Windows that requires an application to be installed. That said, installation is intended to:

  • Make things more simple for the end user.
  • Setup the registry, usually for path information and uninstall information.
  • Initialize any initial information the software may need before it's first run.

Simply avoiding using the registry and saving files locally to your application is usually enough to make your application portable.

That said, as long as you allow the user to select a database location within your software, you should be fine. Saving the information on the pen-drive, in an .ini file for instance, would allow each computer you plug into to read these same settings.

If you expect each computer to have a difference connection string to the database, you could save your settings to the %appdata% directory. When the user plugs the pendrive back in later, his settings will still be there, and no other user will see these same settings.

The downside to the second approach, however, is that the user has no way to "uninstall" and recover the space written to %appdata% automatically. However, for most private business applications, this isn't much of a concern.


Edit: If your real question here is how to distribute an application without an installer, simply build the Release version of your application, and look in /bin/Release/ within your project. Copy these files to another location, remove any debug or unneeded files, and make sure you have all your dependencies in order.

Will Eddins
@Will Eddins : thx Eddin, If i didn't understood wrong, do u mean to say that. Carry on with my traditional way of developing window application and handle the exe file that gets created at bin folder as mentioned by u to client. ?
Shantanu Gupta
Exactly. Copy the files to a flash drive, make sure they work on another computer (that you're not missing a DLL), and distribute away.
Will Eddins
@Will Eddins Thx, Will get back to accept this question after practically implementing this. I will make sure that Framework and other necessary files are present
Shantanu Gupta
+1 For a good solution.
KMan
You need to be aware that just taking the executables and running them from pen-drive or network assumes that the correct version of .Net is installed. It could be that projects built with VS2008 or VS2010 will automatically install it when needed, but VS2005 does not.Furthermore, when running from a network drive, the security of .Net may kick in for certain parts of your application. IIRC, by default your application is for example not allowed to write to the registry when run from a network drive.Hope this helps.
Sebastiaan Megens
@Sebastiaan Megens Does it means that we need to install complete VS.NET into client machine to run directly? or does it mean that we only need to install correct version of framework in client machin. ?
Shantanu Gupta
It means that this is something you should consider when it doesn't work. As unlikely that is on modern machines. Getting a 100% success rate on *every* possible machine that boots Windows is impossible. With or without an installer.
Hans Passant
A: 

Simplest form of installation; use an if/else; when application start, it would check for some registry key (lets say, installation=done), if the value of registery key is="done", then run the else part, which means run the app. If its "notdone", then setup all initial settings and then run the app. A pseudo will go as follows:

if(HasValidRegistryKeys()) //Check if initial settings are already there
{
    Runnable=true;
}
else
{
//Not installed, lets setup app settings
//Assume that the application is running for the first time.
try
{
    SetupRegistry(); //Set installation=done
    SetupDatabase();
    //Setup more things.
    Runnable=true;
}
catch()
{Runnable=false;}

}

//Run the app
if(Runnable)
{
    RunApp();
}
else
{
    MessageBox.Show("Some error");
}
KMan
A: 

i'd say don't bother, whats the point.

noname