Publishing a C# App

Associate
Joined
24 Jun 2007
Posts
1,869
Location
Landan.
I've just finished coding a small and simple C# app. By simple I mean it uses just the basic Forms components (textboxes, radio buttons, labels...) - there's nothing fancy or flashy about it at all (though it does manipulate an XML file if that makes any difference).

So I've used the publishing wizard to create the 'One Click Installer', and it works great on my development machine. However, the app is going to be used on an offline XP (RTM) machine. I've just tried to install it on my laptop which has Windows 7, and it took 10 mins to do so because it had to download a .NET framework update (and now it requires a reboot :() - so there's no chance in hell it can go on the XP workstation without having to connect it to the net.

So my question is: is there any way I can ensure compatibility with a RTM version of XP? I want the user to just run the setup.exe and be ready to go within a minute or two without them having to get any deeper involved - considering the app is about 300KB I'd hope that's achievable :p

I'm pretty new to C#, Visual Studio, and indeed Windows development (I come from a purely Java background), so presume I know nothing :p
 
You will need to create a new project inside your solution of type Setup Project.

From here you need to add .NET framework as a prerequisite and include it in the installer.

This goes through it in good detail. If your on VS 2010 it wont be much different.

However, if your on the express edition of VS, and not the full blown version you cant cant add projects of the Setup Project type. Your only option here really is to download a full version of the relevant framework to local media and install it on the XP boxes first.

Good luck.
 
Cheers for the reply. Yeah I'd read about making a full blown installer with the Framework updates included.

I was more after doing away with any frameworks though, and just use whatever XP came bundled with. As I say, I'm not doing anything complex at all - and certainly I would have thought that everything I'm using was available at the time of XP's release.

It seems ridiculous to have to use big bulky frameworks when it's such a simple app. The reason I wanted to use C# was to get away the requirement for the people to have a JRE installed (I realise you can bundle a JVM in with an app) - that is, make it as compatible as possible, and as much a 'Drag, Drop, Click and Go' app as possible. I might aswell have done it in Java by the looks of things :(
 
To run a windows application in C# you are going to need some version of the .NET framework. Yes, mono could do it as well but thats just complicating things.

If you dont want to include any updates with the installer you are going to have to target the framework that those boxes currently have. I believe XP shipped with .NET 2.0 but you might want to check this. Are those XP boxes without any service packs? If so it might be .NET 1.1.

You can change the target framework of an existing project by right clicking on it the solution explorer -> properties -> target framework

It seems ridiculous to have to use big bulky frameworks when it's such a simple app. The reason I wanted to use C# was to get away the requirement for the people to have a JRE installed (I realise you can bundle a JVM in with an app) - that is, make it as compatible as possible, and as much a 'Drag, Drop, Click and Go' app as possible. I might aswell have done it in Java by the looks of things :(

As you point out, you'd be in the same boat with Java. If the XP boxes didnt have the correct JRE version. You are using C# but writing against the .NET framework and therefore all the libs that come with that. Same as any framework.
 
Cheers - that's exactly what I was looking for - I've got a fair few warnings to work through now :p

Code:
Warning	1	The primary reference "System.Core", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "System.Core" or retarget your application to a framework version which contains "System.Core".	QuizApp
Warning	2	The primary reference "System.Xml.Linq", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "System.Xml.Linq" or retarget your application to a framework version which contains "System.Xml.Linq".	QuizApp
Warning	3	The primary reference "System.Data.DataSetExtensions", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "System.Data.DataSetExtensions" or retarget your application to a framework version which contains "System.Data.DataSetExtensions".	QuizApp
Warning	4	The primary reference "Microsoft.CSharp", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "Microsoft.CSharp" or retarget your application to a framework version which contains "Microsoft.CSharp".	QuizApp
Warning	5	The referenced component 'System.Core' could not be found. 	
Warning	6	The referenced component 'System.Xml.Linq' could not be found. 	
Warning	7	The referenced component 'System.Data.DataSetExtensions' could not be found. 	
Warning	8	The referenced component 'Microsoft.CSharp' could not be found.

I guess I should have asked this question at the start :D
 
No worries mate, glad thats done it.

Although I have to say I find C# 2.0 and below, without LINQ, anonymous types etc like coding with my elbows!

<edit>It looks like you originally targeted 4.0 framework from those namespaces it is warning you about. Remove them all and see what breaks. Ask away if need any pointers.
 
Last edited:
No worries mate, glad thats done it.

Although I have to say I find C# 2.0 and below, without LINQ, anonymous types etc like coding with my elbows!

Yeah, from the looks of it I've used a fair bit of .NET 2.0 components. :(

I'm just wanting the easiest possible method from the users perspective. I'm not installing the application, so I just want them to be able to double click on a setup.exe and be ready to go, or even better just drag and drop a folder or similar.

Basically I can't afford for their to be problems, as I won't be in a position to go out and support the installation.

Just setting up a XP VM as we speak - it's unbelievably hard to get a vanilla XP RTM release.
 
<edit>It looks like you originally targeted 4.0 framework from those namespaces it is warning you about. Remove them all and see what breaks. Ask away if need any pointers.

Cheers, really appreciate your help.

I've removed all those libs, and the only error (so far!) I'm getting on build is:

Code:
Error	1	Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Line 123, position 5.	D:\Users\Luke\Desktop\Current\Quiz App\QuizApp\QuizApp\Properties\Resources.resx	123	5	QuizApp

When I look within the resources directory within the solution explorer, that file is there. Will try removing and readding :)
 
Your best bet to avoid any headaches, might be to start a new project and target 2.0 from that start.

You can choose that when creating a project here:



And just copy your code over.

It can be a nightmare reverting to an earlier version, especially down from 4 to 2.

If you really cant copy over to a new version, the VS toolbox is probably still trying to add 4.0 controls. Restart VS, delete any controls that its moaning about and try adding them again. To verify the versions of controls its trying to add, right click on the toolbox and go "choose items" This will (eventually, its a right slow PITA) load up a list of all controls. All the ticked ones are your current controls, make sure the version is 2.0.

Hey, at least your getting to know your way around the IDE :)
 
Last edited:
Your best bet to avoid any headaches, might be to start a new project and target 2.0 from that start.

You can choose that when creating a project here:

And just copy your code over.

It can be a nightmare reverting to an earlier version, especially down from 4 to 2.

If you really cant copy over to a new version, the VS toolbox is probably still trying to add 4.0 controls. Restart VS, delete any controls that its moaning about and try adding them again. To verify the versions of controls its trying to add, right click on the toolbox and go "choose items" This will (eventually, its a right slow PITA) load up a list of all controls. All the ticked ones are your current controls, make sure the version is 2.0.

Hey, at least your getting to know your way around the IDE :)

Blarg - I thought sod it, if I could just make it a simple one file installer, it'd still be alright. So I added an installer project to my solution, and after a couple of hours getting my head round all the options, I thought I had it all sorted.

But I've just tried to install it on my XP test bed and it bombs out trying to install .NET 4 with exit code 5100:

.NET 4 requires a reasonable up to date Windows XP installation. You need at least Windows installer 3.1 and Service Pack 3 to be present on the system for the installation to succeed. However, with only those 2 you may still run into problems with WindowsUpdate and other packages, so it would be wise to bring the system up to date through Windows update before performing the install.

http://www.depopo.net/content/faq/f...-4-install-fails-with-code-5100-on-windows-xp

*weep* :p
 
Ouch :(

Sorry fella, i didnt realise .NET 4.0 was dependant on XP Service Pack 3.

Ok, try

1)Revert project framework from 4.0 to 2.0
2)Expand references and delete all with ! mark next to them in yellow.
3)Build -> Clean
4)Build -> Rebuild
5)Clean up any using statements that are no longer needed.
6)Nuke all your resources, re reading your earlier post this looks like an issue.
7)Add all of #6 again.
8)Build -> Clean
9)Build -> Rebuild
10)Now work through any new exceptions. Post here if struggling and ill have a look

Failing that, its either including the XP service pack 3 framework with the installer, or start project from scratch.

Good luck!
 
Unfortunately XP RTM was released before the first version of .NET so what ever happens your going to need to include the framework installer and most likely a service pack too.

The only version of .NET which works with RTM would be 1.0/1, anything above that and you'll start needing service packs. If the program was quick to put together I'd suggesting just re-writing in a non .NET language, other wise get some offline installers for SP3 and the .NET framework and get updating that machine! :)
 
Ouch :(

Sorry fella, i didnt realise .NET 4.0 was dependant on XP Service Pack 3.

Ok, try


Failing that, its either including the XP service pack 3 framework with the installer, or start project from scratch.

Good luck!

It's taken me all day but I'm all sorted :D It's now using .NET 2.0, and comes with the redist frameworks bundled with the installer should it require them.

It wasn't as painful as I'd imagined to move everything over to .NET 2.0 (as you hinted at, largely a case of copy and paste) - though it wasn't without issue :D

Thanks again for all your help - much obliged!

Unfortunately XP RTM was released before the first version of .NET so what ever happens your going to need to include the framework installer and most likely a service pack too.

The only version of .NET which works with RTM would be 1.0/1, anything above that and you'll start needing service packs. If the program was quick to put together I'd suggesting just re-writing in a non .NET language, other wise get some offline installers for SP3 and the .NET framework and get updating that machine! :)

Yep, cheers for that - I should have checked the release dates before starting :o
 
It's taken me all day but I'm all sorted :D It's now using .NET 2.0, and comes with the redist frameworks bundled with the installer should it require them.

It wasn't as painful as I'd imagined to move everything over to .NET 2.0 (as you hinted at, largely a case of copy and paste) - though it wasn't without issue :D

Thanks again for all your help - much obliged!

No worries, glad you got it sorted.
 
Back
Top Bottom