The. NET Framework version error issue that appears today when uploading company servers

Source: Internet
Author: User

Do a website today (. net4.0), there are static pages also have ASPX page, post, filled with joy to upload to the server, after the run, static page no problem, but through the navigation bar once clicked into the ASPX page, there will be an error

, the target framework of Web. config is 4.0, changed to 2.0 after the page error, so think of the generation and release should choose 2.0, so back to. NET 2010, in the property page of the build option, Select 2.0 (refer to other people's article 2.0 version can also use 4.0 of things)

Generate a lot of errors, the most is not support LINQ namespace, can only temporarily tolerate the deletion (later development when the server's application pool is only supported to 2.0 version), after the successful release of the deployment, the success of the launch, from the online check, 2.0 framework can also use 3.5 of the features

This is a reference to someone else's article:

Programs that develop the. NET Framework 3.5 in the. NET Framework 2.0 Environment

First, case analysis:

Because of the client deployment and installation, you only want to install the. NET Framework 2.0 framework, and your project needs to use some of the features of the. NET Framework 3.5, such as LINQ, extension methods, and so on. If you install a legacy, you need to create a. NET Framework 3.5 project in order to use these features, and I need our clients to use only 2.0 of the frames that are installed on the machines of friends. This article shows you how to develop a 3.5 program in the. NET Framework 2.0 environment.

Second, how to do:

1. Create a WinForm project for the. NET Framework 2.0:

2. Then add the reference, browse to the directory below C:\Program files\reference assemblies\microsoft\framework\v3.5, and you can see that the directory contains many 3.5 dll files:

If you want to use the LINQ feature, you can choose to System.Core.dll this file, and you will be prompted with the following:

Skip directly, choose Yes, and look at our solution Project view:

It can be found that System.core hit a yellow exclamation mark, stating that there is no reference to success.

3. Next, select System.core in the reference and right-select properties to see:

Then please set the specific version to False,copy local set to True, you can find that the original yellow exclamation mark is missing, indicating the success of the reference.

Now you can start using features such as LINQ.

The code is as follows:

Code Public Partial ClassForm1:form {PublicForm1 () {InitializeComponent (); }
Private voidButton1_Click (Objectsender, EventArgs e) {//Initializing a random array Int[] Array= New Int[8] {5,1,1,3,2,4,4,3};
//Filter duplicates and sort in ascending order Array=Array. Distinct (). (O=O). ToArray ();
MessageBox.Show (Array. Joinwith (",")); } }
//Extension method Static Class Public Static Classarrayextension {//Array concatenated into a string method Public Static StringJoinwith (This IEnumerable arr, string separate)     {        StringBuilder result = New StringBuilder ();         foreach (object I Span style= "color: #0000ff;" >in arr)             result. Append (i). Append (separate);         return Result. ToString (). TrimEnd (separate. ToCharArray ());    }

4. The last edit succeeds, run as follows:

OK, you are done:)

The. NET Framework version error issue that appears today when uploading company servers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.