开发者

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

I want to create a window b开发者_运维技巧ased 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


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.


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


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


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");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜