Frage

I have been able to run my C# .net 3.5 app just fine on my development machine, but I can't seem to get it run anywhere else. The client machines have the 4.0 .net client profile installed and after looking up what is left out of the client profile, I doubt that installing the full 4.0 framework would make a difference.

I am using classes from these libraries:

using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
using System.Diagnostics;
using Microsoft.Win32;

The only thing out of the ordinary that I am doing is defining a CustomApplicationContext instead of the normal App Context that you would use for a Forms application. My app runs primarily as a NotifyIcon in the System Tray, so I just set up a class who's main interface is that System Tray Icon. Nothing too bizarre.

For testing purposes I have my first line of code display a MessageBox and even this won't run. Whenever I start it on the deploy machine is just pops up a box saying "App failed to start" and shuts down.

Does anyone have any idea why it would be doing this? I can't seem to get it to run a bit of code.

War es hilfreich?

Lösung

Perhaps what you need is to add .Net4.0 to your supported runtime list. Add the following lines to your app.config

<configuration>
   <startup useLegacyV2RuntimeActivationPolicy="true">
      <supportedRuntime version="v4.0"/>
   </startup>
</configuration>

Andere Tipps

Perhaps not everything will run correctly on the new framework, but have you tried explicitly setting the target framework as descriped on http://msdn.microsoft.com/en-us/library/ms171868.aspx

Copied:

The .NET Framework 4 is highly compatible with applications that are built with earlier .NET Framework versions, except for some changes that were made to improve security, standards compliance, correctness, reliability, and performance.

The .NET Framework 4 does not automatically use its version of the common language runtime to run applications that are built with earlier versions of the .NET Framework. To run older applications with .NET Framework 4, you must compile your application with the target .NET Framework version specified in the properties for your project in Visual Studio, or you can specify the supported runtime with the Element in an application configuration file.

having only .NET Framework 4 installed won't run a .NET 3.5 application sadly. 3.5 will run 2.0, 3.0 and 3.5 applications, but 4 is a major overhaul so it won't work if the users don't have 3.5 installed on their machines.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top