Click to See Complete Forum and Search --> : C# Program Distribution


Lou Arnold
January 11th, 2007, 08:42 AM
After many years programming in C++, I'm considering moving to C#. However choosing an IDE may be a problem if I want to create programs that run without an IDE.

For example, it does not look like Visual C# under .Net V2.0 allows creation of a distributable application. See the the HowTo about setting debug and release configurations. Is there another IDE/framework that would allow that? For Windows under the .NET V2.0 framework? Under Linux? or both?

darwen
January 11th, 2007, 11:19 AM
You can redistribute an executable written in C# on any machine : they have to have the appropriate version of the .NET framework installed on them though (i.e. the one which the exe was built against).

If your exes could only be run on machines which had the Visual Studio IDE installed on them then it'd be pretty limited indeed... but this isn't the case.

Darwen.

Lou Arnold
January 12th, 2007, 08:49 AM
Thanks, Darwen, but maybe I didn't state the context correctly. I was thinking of using Visual C# 2005 Express. The MSDN HowTo I mentioned does not apply to C# - implying that with this version of Visual C#, one cannot create a distributable application. Do you have any documentation or experience contradicting this?

dcell59
January 12th, 2007, 11:57 AM
Could you give us info on how to find the article you are talking about (either a web link or an MSDN ms-help link)? I understood that VC# Express was limited, but I thought you could create applications that would run fine on other systems with .NET.

I haven't installed VC# Express yet because the only reason I need it is for XNA.

Allan Olesen
January 12th, 2007, 02:31 PM
I have recently installed VC#2005 Express too. I understand the confusion. MS uses a somewhat strange wording in the description of the "Publish" function, which led me to think that it was maybe primarily intended for programs running directly from a web site or a file share.

However, after testing I can confirm that it is possible to redistribute programs to PCs which do not have the IDE installed. The .Net Compact Framework 2.0 is required, but the installer for your program will download and install that too, if missing.

When using the "Publish" function, select the option to make the program installable "From a CD-ROM or DVD-ROM". After finishing the wizard, you will have a folder containing a setup.exe and a number of other files which are unfortunately necessary for the installation. No option to distribute everything in one file, it seems.

The setup.exe contains a very basic installer. It will install the program and make a shortcut in the Start menu without asking any questions at all. (If the installer installs .Net CF 2.0 too, you will be asked to agree to the EULA, and that's it).

Lou Arnold
January 12th, 2007, 02:55 PM
The URL for the article is:
http://msdn2.microsoft.com/en-us/library/wx0123s5(VS.80).aspx

It is entitled "How to: Set Debug and Release Configuration". At the very start there is text and a table:
-------------------------------------------------------------
This topic applies to:

Vis Studio Edition Vis Basic C# C++ J#
Express No No Yes No
Standard Yes Yes Yes Yes
Pro/Team Yes Yes Yes Yes
-------------------------------------------------------------

I haven't yet found a reference that says a C-Sharp executable can be distributed (with or without specific DLLS). If anyone has found such info, pls let me know. And yes, one would assume that the .NET Framework is installed on the systems that the app will be installed on.
There is some implication that a web application can be distributed, but not a Windows applications.

Since I have the Vis C# 2005 Express, I could use it, but suggestions for other IDEs are welcome - particularly one that is hosted on both Windows and Linux. I am running Windows 2000 Pro SP4 on one system and a Fedora Core 5 on another much slower computer.

Lou Arnold
January 12th, 2007, 03:06 PM
Perhaps I misunderstand all this. The Publish Wizard tries to create a web application. I don't want to create a web application. Am I using the wrong language?

dcell59
January 12th, 2007, 03:16 PM
All I get from the article is that it doesn't apply to C# Express, and it's only about how to switch between Debug and Release targets and change their settings. It doesn't really have anything to do with distributing an application (note that "Release" in this context just means that it doesn't contain debug code and symbols).

The "Publish" function Allan is referring to can be found in the "Build" menu. Look for it at the bottom of the middle group.

It sounds like Allan has already verified that you can build and distribute applications built with C# Express, but you should be able to verify that yourself if you already have VC#.

There are C# IDEs that work on both Windows and Linux platforms, but I haven't worked with them.

dcell59
January 12th, 2007, 03:27 PM
I ran across an article that explains why the "How To" article doesn't apply to C# Express. In C# Express, if you run a program under the IDE, it automatically runs it in Debug mode. To build the release version, you have to use Ctrl+Shift+B. Or, you can turn on the advanced IDE options as mentioned here: http://cygon.nuclex.org/2006/07/02/debug-and-release-in-visual-c-express/

So far, I haven't seen anything to indicate that you can't distribute C# apps built with this product.

dcell59
January 12th, 2007, 03:30 PM
Perhaps I misunderstand all this. The Publish Wizard tries to create a web application. I don't want to create a web application. Am I using the wrong language?

Are you telling it to put the output into a directory on your filesystem? I typed in "C:\deploy\MyApplication1" into the box, and it then allowed me to choose to deploy it for CD/DVD-ROM.

It does have the abiloty create web pages so that your users can download and install the app from the web, but you can choose to have it be just a set of files.

Lou Arnold
January 12th, 2007, 03:30 PM
Yep, I ran a test with the Publish Wizard. Its unusual, but seems to allow saving the executable to web site, to a file share (assume some intranet common file store) or to a CD or DVD (why would one do that rather than just to a local disk folder.....anyway. I guess the wnaser is yes - you can distribute it.

Lou Arnold
January 12th, 2007, 03:33 PM
to dcell59...
Thanks for the article. I will review it. Its good to hear that I can distribute an application.

dcell59
January 12th, 2007, 03:42 PM
Yep, I ran a test with the Publish Wizard. Its unusual, but seems to allow saving the executable to web site, to a file share (assume some intranet common file store) or to a CD or DVD (why would one do that rather than just to a local disk folder.....anyway. I guess the wnaser is yes - you can distribute it.

When you choose CD/DVD, it actually puts it into a local disk folder. The dialog asks "How will users install your application?" and how it builds the installer depends on these things. If your application is on a web site or file share, the application can be installed permanently or temporarily, and can be updated as needed. If it's on a CD/DVD, it doesn't need all of that.

It's worth your while to read up on ClickOnce deployment.

Zaccheus
January 12th, 2007, 04:50 PM
I recommend using InnoSetup instead, it's a very easy to use installation package generator and it's free!
:)

http://www.jrsoftware.org/isinfo.php

Allan Olesen
January 12th, 2007, 05:49 PM
It's worth your while to read up on ClickOnce deployment.
Heh, never heard of it before. But I can see now that the strange wording I referred to is very identical to the wording on the MS ClickOnce webpage:

http://msdn2.microsoft.com/en-US/library/142dbbz4(VS.80).aspx

After reading that page, including the "any user can install these programs" stuff, I began to check where the program from my test was installed. I found it here:

C:\Documents and Settings\aho\Local Settings\Apps\2.0\BXWW3V6A.728\7DZAD0E9.Y49\udpc..tion_8f0ff60a51edcbe9_0001.0000_ee967965f0442e86

So basically, every user on the PC will have to install the program to be able to run it if it installed with the installer created by C# Express. And the random letters in the install path are different for every user. On the bright side, it seems to offer good options for automatic updates.

I guess this is not an installer you would want for all programs. In some situations this will be better, but there is also a lot of situations where I would want my programs to be installed to a folder under c:\Program Files\ by a user with administrative right, ready to user for any other user on the PC.

dcell59
January 12th, 2007, 06:29 PM
Yeah, it's not for everyone, but I still think it's worth knowing about. There are some environments where it's a great way to go.

Lou Arnold
January 13th, 2007, 04:02 PM
I must agree, the ClickOnce approach may be overkill in some situations, but exactly what one wants in others. My applications probably too small to be concerned about upgrades. If I change it, I will probably change enough of it to create a whole new executable. And I have no DLLs to distribute with it.

But this may get more complicated when a license key is added. I'll have to dig into that.

Allan Olesen
January 14th, 2007, 05:11 AM
I must agree, the ClickOnce approach may be overkill in some situations,
To me it looks like underkill. Except for the autoupdate feature, this installation is (too) simplified, compared to a program with a real installer.

Zaccheus
January 14th, 2007, 05:23 AM
To me it looks like underkill.Indeed.

If you can write a C# application, you should be able to use a proper installation package generator.

dcell59
January 15th, 2007, 11:57 AM
I think you guys are going a bit overboard. The point of ClickOnce deployment is not to replace all installers, but to provide a simplified installation experience for simple programs. It's especially useful for programs that a user might only use once in a while to perform a quick task. I think it's perfect for what it does - it's certainly better than handing a user a bunch of files to hand-install or a full-blown installer for installing a single file and setting up a bunch of registry entries.

Note that even with ClickOnce, Visual Studio still provides the ability to create full installers. I don't know if C# Express provides this, though.

Allan Olesen
January 15th, 2007, 12:43 PM
I don't know if C# Express provides this, though.
That is exactly the point. It doesn't.

ClickOnce publishing is the only option if you want to create an installer directly from C# Express. Using it for the first time is a somewhat confusing/frustrating experience because the Publish function does not tell you that you will get a ClickOnce installer. ClickOnce is not mentioned by name, and the ClickOnce concept is not explained. Instead, the dialogs gives some descriptions and asks some questions which seem a little off, and you sit there wondering why they ask these questions for a normal installer - until you discover that this is not a normal installer.

Anyway, I agree that ClickOnce is perfect for what it does - and I can't complain over a free programming IDE of C# Express' quality.

dcell59
January 15th, 2007, 01:14 PM
You're definitely right that it's frustrating and confusing for a first-timer. It's no better in VS 2005, either.

Zaccheus
January 15th, 2007, 01:29 PM
I still prefer InnoSetup:


[Setup]
AppName=MyApp
AppVerName=MyApp v1.0
DefaultDirName={pf}\MyApp
DefaultGroupName=MyApp

[Files]
Source: "MyProg.exe"; DestDir: "{app}"

[Icons]
Name: "{group}\MyApp"; Filename: "{app}\MyProg.exe"


The above source code creates a single installer which has a standard user interface and asks the user where they want their application installed (* defaulting to "C:\Program Files\MyApp\") and where they want the start menu icon (* defaulting to "Start->Programs->MyApp"); it also creates an uninstall entry in Add/Remove Programs called "MyApp v1.0".
:)

Yet on the other end of the scale InnoSetup is powerful enough to let you define your own interface pages and use OLE items like MSXML.

And it's free!

-------

* All placeholders like {pf} do of course expand to the appropriet local value when the installer is run. For example, in Germany {pf} expands to "C:\Programme".

Allan Olesen
January 15th, 2007, 02:18 PM
(defaulting to "C:\Program Files\MyApp\")
You had me worried there. But fortunately it seems to default to the standard program path defined on that PC. Looks like a fine program BTW.

(As a non-English user, I really hate it when installers assume that they do not need to ask Windows for a installation path. Other language versions of Windows do not have a C:\Program Files\ .)

Zaccheus
January 15th, 2007, 02:32 PM
Yeah, sorry, I should have made that clear: Placeholders like {pf} always expand to the appropriet local values, whatever they may be.

Lou Arnold
January 16th, 2007, 12:15 PM
I'm pleased the thread went this far. I learned alot. Many thanks for your experience and opinions.