1

My app has a Target .NET Framework of 3.0.

I have a PC with a fresh install of Windows XP SP3. Next, I installed .NET Framework 4.0 Full on it.

When I try to run my ClickOnce-deployed app, I get the "Failed to load the runtime" error:

[9/9/2011 11:39:53 AM] System.Runtime.InteropServices.COMException
    - Failed to load the runtime. (Exception from HRESULT: 0x80131700)
    - Source: System.Deployment
    - Stack trace:
        at System.Deployment.Application.NativeMethods.IClrMetaHostPolicy.GetRequestedRuntime(MetaHostPolicyFlags policyFlags, String binaryPath, IStream configStream, StringBuilder version, Int32& versionLength, StringBuilder imageVersion, Int32& imageVersionLength, Int32& pdwConfigFlags, Guid interfaceId)
        at System.Deployment.Application.NativeMethods.GetAssemblyCacheInterface(String CLRVersionString, Boolean FetchRuntimeHost, CCorRuntimeHost& RuntimeHost)
        at System.Deployment.Application.PlatformDetector.VerifyPlatformDependencies(AssemblyManifest appManifest, AssemblyManifest deployManifest, String tempDir)
        at System.Deployment.Application.ApplicationActivator.DownloadApplication(SubscriptionState subState, ActivationDescription actDesc, Int64 transactionId, TempDirectory& downloadTemp)
        at System.Deployment.Application.ApplicationActivator.InstallApplication(SubscriptionState& subState, ActivationDescription actDesc)
        at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
        at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)

It is my understanding that apps Targeting .NET 3.0 should work on machines that have .NET 4.0 installed. What is causing this error? Must I install .NET Framework 3.5 SP1 on Windows XP Machines?

yarone
  • 187
  • 4
  • 14
  • I think I may write a custom Prerequisite and A) [Check if user has .NET Framework 3.0 installed](http://stackoverflow.com/questions/199080/how-to-detect-what-net-framework-versions-and-service-packs-are-installed). (fresh XP won't have it, fresh Vista will have it, fresh Win 7 will have it) B) If .NET 3 is not installed, install 3.5. – yarone Sep 09 '11 at 19:16
  • OK, that worked. Why the app doesn't just run properly (on XP SP3 with .NET 4.0) doesn't make sense to me. – yarone Sep 09 '11 at 19:49

3 Answers3

3

yes I would install the .NET Framework 3.5 and try again, if it does not work I would install the 3.0 ( Microsoft .NET Framework 3.0 Redistributable Package ).

.NET 3.5 SP1 and .NET 4 are both present in the machines we deploy our applications to.

Edit:

also check these questions:

What .NET Framework version should I ship with; 2, 3, 3.5?

Is .net framework 2.0 required if 3.5 is installed?

Community
  • 1
  • 1
Davide Piras
  • 43,984
  • 10
  • 98
  • 147
  • Yuck. This is a commercial application (to be downloaded by anyone on the web). I don't want to require .NET Framework 3.5 to be downloaded and installed if the user already has .NET Framework 4.0 installed! Might I have to write a custom bootstrapper that checks if user is on XP and if so, require 3.5? – yarone Sep 09 '11 at 18:53
  • Are you in control of this application? Is that yours? Can you target .NET 3.5 or .NET 4 ? – Davide Piras Sep 09 '11 at 18:54
  • Sure I could - but I don't want Vista users to have to download .NET 3.5 or 4.0 for no reason. (.NET 3.0 ships with Vista, which is why we're targeting 3.0 to minimize download and install time) – yarone Sep 09 '11 at 18:55
  • as you said in the other comment since it works when .NET 3.5 is installed, I would include .NET 3.5 as prerequisite in the setup so who does not have it will download it. if you do not target framework 4 you will need the 3.5 also in machines which have .NET 4. this most likely happens only on old machines, Vista and windows 7 with their service packs already have 3.5 and 4.0 I think. – Davide Piras Sep 09 '11 at 18:56
  • got what you mean. Read this article: http://blogs.msdn.com/b/tims/archive/2008/03/19/what-does-windows-vista-sp1-mean-for-developers.aspx they explain that Vista SP1 has .NET 3.0 SP1 which executes also .NET 3.5, so if users have Vista SP1 you can absolutely just target .NET 3.5 in your code. – Davide Piras Sep 09 '11 at 19:00
  • I see, but what about standard Vista (not Vista SP1)? I am looking at a fresh install of standard Vista (not SP1) right now and I see that .NET Framework 2.0 and 3.0 are the only versions that are installed. On the machine I'm looking at, if I Target .NET 3.5 in my app, this machine will have to download 3.5 (for no good reason...) – yarone Sep 09 '11 at 19:06
  • it depends on your application needs? I absolutely would switch to .NET 3.5 or even 4, there are so many changes to take advantage of... but it depends really on how big and complex is your application or I agree this could be overkiling. – Davide Piras Sep 09 '11 at 19:08
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/3313/discussion-between-yarone-and-davide-piras) – yarone Sep 09 '11 at 19:29
1

As Davide Piras mentioned you need to install .NET 3.0. The reason why you need to do is that .NET 4 is not a dependency superset of the 3.5/3.0/2.0 libraries.

.NET 3.5 is 3.0 libraries plus some additional ones. .NET 3.0 is the 2.0 libraries plus some additional ones

However, .NET 4 is a whole new set of libraries that exist in parallel to the 2.0/3.0/3.5 ones. I believe that this is a result of the .NET 4 using a new CLR runtime than 2.0/3.0/3.5. The 2.0/3.0/3.5 all use the same runtime, hence each new version required the install of the prior versions.

Eric Johnson
  • 191
  • 1
  • 3
0

It's a COMException, so I'd say that maybe a component is not properly set.

Check your project properties under the publish tab. In Application Files, check Show All Files and make sure that all you need is marked as included.

In there, you can also ask the application to download the required components (such as the proper framework).

Such misleading error message happened to me in the past. May also just be the framework as the other reply states.

Mathieu
  • 4,449
  • 7
  • 41
  • 60