1

First of all I am newbie in C# so please be indulgent.

My friend created for me simple project using Visual Studio. Program is showing buttons, after click on single button proper folder or file is opened.

I build the program using .Net 2.0 and the program is working fine on computers with installed .NET 2.0 but is not working on computers with newest .Net libraries like .Net 4.0. I also buid program using .Net 4.0 and it is working on computers with installed .NET 4.0 but it is not working on computers with .Net 2.0.

How I can create this program to get this working on every version of .Net? I just want to add that this opening function is very basic, because I used below:

System.Diagnostics.Process.Start

I just want to add that I can't use installer of newest .Net because I have no admin rights.

I based on similar program which copied text to clipboard after clicking on button. It was working on every .Net environment. I simply replaced "Clipboard.Settext" function with "System.Diagnostics.Process.Start" and here I have problems.

3
  • As far as I know the .net are individuals. If you have a machine that has only .net 4 some .net 2 features will not work. You must have on that machine .net2 .net3.5 and .net 4 Can read about it here - support.microsoft.com/en-us/kb/2696944 Commented May 10, 2015 at 21:40
  • I just want to add that I want to use it in office to get quickly to favourite files or folders. Because of it this program has to be simply, without any instaler because I have no admin rights. On some servers we have .Net 2.0 on other .Net 4.0 and when I am logging in I am randomly added to server. Commented May 10, 2015 at 21:41
  • I suggest build it in .net 4 and use the installer. It will make people who don't have .net 4 install it. Commented May 10, 2015 at 21:43

1 Answer 1

4
  1. Compile for .NET 2.0
  2. Add this to the config file:

myapp.exe.config:

<configuration>
   <startup>
      <supportedRuntime version="v2.0.50727"/>
      <supportedRuntime version="v4.0.30319"/>
   </startup>
</configuration>
Sign up to request clarification or add additional context in comments.

2 Comments

Better yet, put both v2.0 and v4.0 in the config file as a supported runtime. That way, you don't need to see what framework version is installed on the server: as long as either is installed, it will just work.
@hvd good catch, didn't know that you can specify multiple runtimes in the config line!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.