Running wyUpdate.exe for .NET 2.0 in a pure .NET 4.0 env

Hi,

I have application that needs at least version 2.0 of the .NET framework. Without modifications to the application configuration file (app.config) a .NET 2.0 application does not run on a pure 4.0 installation. To take this scenario into account my configuration file looks as follows:

<?xml version="1.0"?><configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v2.0.50727" /> <supportedRuntime version="v4.0" /> </startup></configuration>

In my installer I distribute wyBuild.exe targeted to .NET 2.0. That means in a pure 4.0 environment your .exe won't run. So I also added the same configuration to your exe, i.e. wyBuild.exe.config which seems to make it work.

Do you see any caveats using it this way, especially in conjunction with NGEN?

Yves

We already distribute a pure .NET 4.0 version of wyUpdate along with wyBuild. Go to "File -> Properties -> wyUpdate" and select the .NET 4.0 radio button:

[attachment=0]build.wyupdate.for.net4.png[/attachment]

Now when you build wyUpdate it builds the .NET 4.0 version of wyUpdate.

Thanks for your swift reply. I know this setting. But that means that I have to distribute two different wyUpdate.exe and install the right one depending on the .NET version installed on the target machine. In my view this is unnecessary work since a .NET 2.0 exe runs fine in a .NET 4.0 environment with the mentioned configuration adjustment.

The only issue I see with wyBuild.exe for 2.0 is with NGEN which has to be found in the .NET 4.0 folder instead of the .NET 2.0 folder. I don't know if this folder is being looked up depending on the running .NET version or if it's hardcoded.

Comments welcome 🙂

Yves

Hey Yves,

I see. This is an interesting setup. If you plan on modify wyUpdate.exe to force it to load for .NET 4.0, then you'll have to maintain your own self-update files on your server (see: How to make a custom version of wyUpdate). If you don't do this, and your user is running on a purely .NET 4.0 system wyUpdate will crash and burn when it self-updates.

We'll look into possibly building wyUpdate with that modified setting. This way you won't have to maintain your own build of wyUpdate. We need to assure there are no adverse effects of using .NET 2.0 code in the .NET 4.0 runtime.

But that means that I have to distribute two different wyUpdate.exe and install the right one depending on the .NET version installed on the target machine.

That's true.

In my view this is unnecessary work since a .NET 2.0 exe runs fine in a .NET 4.0 environment with the mentioned configuration adjustment.

This is an untested code path. That is, we don't test running the .NET 2.0 wyUpdate under .NET 4.0. You can force it, but I'm not sure it's wise. We'll have to look into it.

The only issue I see with wyBuild.exe for 2.0 is with NGEN which has to be found in the .NET 4.0 folder instead of the .NET 2.0 folder. I don't know if this folder is being looked up depending on the running .NET version or if it's hardcoded.

As far as NGENing goes, wyBuild scans your assemblies to detect what .NET version they are built for and wyUpdate tries to NGEN these assemblies based on system locations of the .NET frameworks. If the .NET framework is not found, wyUpdate skips the NGENing step.

With such a complementary .config file there would be no need for a custom wyUpdate. I'm not keen on maintaining my own wyUpdate.

The reason for such a setup is that I'm targeting different os' from XP through Win7 and want to make the setup costs as minimal as possible. I don't want to force people to install the old .NET 2.0 on their new Win7 boxes.

MS provides some documentation on backward compatiblity, means running a .NET 2.0 application on the new 4.0 CLR.

http://msdn.microsoft.com/en-us/library/ff602939.aspxhttp://msdn.microsoft.com/en-us/library/dd889541.aspx

At least for my application everything works fine with the 4.0 CLR. I'll do some tests to see if my assemblies are being correctly converted with Ngen through wyUpdate.

Yves

With such a complementary .config file there would be no need for a custom wyUpdate.

Oh, I see. I thought you were embedding the file into wyUpdate.exe. You're right - no need to maintain your own version.

I don't want to force people to install the old .NET 2.0 on their new Win7 boxes.

.NET 2.0 is installed be default on Windows Vista and Windows 7. (In fact there's no way to remove it from those OSes). You only need to install .NET 2.0 for Windows 2000 and XP.

But I take your point.

Ups, I got mixed up. It's only relevant for Windows XP with only .NET 4.0 installed. Assuming this is a pretty much rare case it's maybe easier just to install .NET 2.0. Thanks for your greatly appreciated help and for getting me back on track 🙂

Yves