Create Desktop(window) application that can run without installing?
Asked Answered
M

4

6

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

Mystic answered 6/1, 2010 at 7:8 Comment(0)
P
13

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.

Proven answered 6/1, 2010 at 7:19 Comment(6)
@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. ?Mystic
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.Proven
@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 presentMystic
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.Prettify
@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. ?Mystic
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.Duque
P
0

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

Polycythemia answered 6/1, 2010 at 7:11 Comment(6)
I know how to interact with database, but I also need window application. So that any user can enter data through GUI interfaceMystic
So build one. If you are using Visual Studio or Visual Studio Express, select "Windows Application" from the File/New dialog.Polycythemia
@Robert Harvey is it possible to create a something like exe that dont need any installation. But start GUI windowMystic
@Robert Harvey Question elaborated, Plz checkMystic
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.Polycythemia
The example program at msdn.microsoft.com/en-us/library/360kwx3z.aspx runs without an installer.Polycythemia
A
0

If you don't know where and how to start window form application or how to connect to database or so, there are plenty tutorials and you can Google for it very easily ;)

Here are few examples:

GUI related:

Tutorial: Working with Windows Forms - Part I

GUI Windows Forms « C# / CSharp Tutorial

Windows Forms tutorial with C#

Databases related:

Creating a database connection

Apheliotropic answered 6/1, 2010 at 7:19 Comment(0)
T
0

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");
}
Tesch answered 6/1, 2010 at 7:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.