在Framework2.0环境下运行3.5的代码
http://www.cnblogs.com/imfunny/archive/2011/08/11/2134639.html 因为许多的服务器特别是廉价的服务器上使用的是Framework的v2.0.50727。再加上自己开发的算是产品,所以就需要降低一些客户的前期成本,而自己同时也喜欢简单的代码。后来查了下,得知其实F
http://www.cnblogs.com/imfunny/archive/2011/08/11/2134639.html
因为许多的服务器特别是廉价的服务器上使用的是Framework的v2.0.50727。再加上自己开发的算是产品,所以就需要降低一些客户的前期成本,而自己同时也喜欢简单的代码。后来查了下,得知其实Framework3.5也是可以运行在2.0上的。引用System.Core.dll就可以直接的编写了。在2005下是不行的。因为2005默认的是2.0的编译器。即使引用了也没用。
引用后点击属性设置下。见截图啊。这样就可以在Vs2008上直接使用了。(这些都放到了附件里,需要的点击下载连接就行了。)
使用这个有什么好处呢。
首先就是方法的扩展了。
比如之前的MD5。
?
|
现在通过方法扩展可以写成这样
?
|
现在的代码越来越Query风格了。我喜欢。其实就不说了匿名函数,lamda表达式,linq了。
当完成这步的时候编译之后的Dll已经可以直接在2.0下运行了。
但是在WEB开发的时候。编译之后在2.0下可以运行的。总不能够每次修改都要把Dll给全部编译下。CodeFile在这样的情况下也是出错的。因为CodeFile在这个时候还是会出错的。默认的csc.exe是2.0的。这个时候就简单了。
把附件的包给解压出来,点击附件里的“取得权限.reg”,找到目录C:\Windows\Microsoft.NET\Framework\v2.0.50727,然后右键菜单上就有了“取得权限更改",点击它。然后把附件下v3.5.rar解压出来,把v3.5里的文件复制替换到v2.0.50727。于是编译器就更换了。然后点击“取得权限卸载.reg”。删除掉菜单里的取得权限的按钮。
有图有真相:
XP下应该同样。就不具体的去测试了。
OK。大工告成,现在一切都是浮云。剩下的就是去爽了。发布的时候生成DLL直接放到生产服务器上就行了。一切就那么简单啊。剩下的就是用3.5的风格去编写2.0的程序了。
那撒撒的,上面使用到的工具都整理了下,在附件里,想使用的直接点击附件下载吧。
附件下载

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Windows Recovery Environment (WinRE) is an environment used to repair Windows operating system errors. After entering WinRE, you can perform system restore, factory reset, uninstall updates, etc. If you are unable to boot into WinRE, this article will guide you through fixes to resolve the issue. Unable to boot into the Windows Recovery Environment If you cannot boot into the Windows Recovery Environment, use the fixes provided below: Check the status of the Windows Recovery Environment Use other methods to enter the Windows Recovery Environment Did you accidentally delete the Windows Recovery Partition? Perform an in-place upgrade or clean installation of Windows below, we have explained all these fixes in detail. 1] Check Wi

What to do with blue screen code 0x0000001? The blue screen error is a warning mechanism when there is a problem with the computer system or hardware. Code 0x0000001 usually indicates a hardware or driver failure. When users suddenly encounter a blue screen error while using their computer, they may feel panicked and at a loss. Fortunately, most blue screen errors can be troubleshooted and dealt with with a few simple steps. This article will introduce readers to some methods to solve the blue screen error code 0x0000001. First, when encountering a blue screen error, we can try to restart

How to execute .sh file in Linux system? In Linux systems, a .sh file is a file called a Shell script, which is used to execute a series of commands. Executing .sh files is a very common operation. This article will introduce how to execute .sh files in Linux systems and provide specific code examples. Method 1: Use an absolute path to execute a .sh file. To execute a .sh file in a Linux system, you can use an absolute path to specify the location of the file. The following are the specific steps: Open the terminal

PyCharm is a very popular Python integrated development environment (IDE). It provides a wealth of functions and tools to make Python development more efficient and convenient. This article will introduce you to the basic operation methods of PyCharm and provide specific code examples to help readers quickly get started and become proficient in operating the tool. 1. Download and install PyCharm First, we need to go to the PyCharm official website (https://www.jetbrains.com/pyc

If you need to program any device remotely, this article will help you. We will share the top GE universal remote codes for programming any device. What is a GE remote control? GEUniversalRemote is a remote control that can be used to control multiple devices such as smart TVs, LG, Vizio, Sony, Blu-ray, DVD, DVR, Roku, AppleTV, streaming media players and more. GEUniversal remote controls come in various models with different features and functions. GEUniversalRemote can control up to four devices. Top Universal Remote Codes to Program on Any Device GE remotes come with a set of codes that allow them to work with different devices. you may

Do you know how to run m files in matlab? Below, the editor will bring you a tutorial on how to run m files in matlab. I hope it will be helpful to you. Let’s learn with the editor! 1. First open the matlab software and select the upper left "Open" the corner, as shown in the picture below. 2. Then select the m file to be run and open it, as shown in the figure below. 3. Press F5 in the window to run the program, as shown in the figure below. 4. We can view the running results in the command line window and workspace, as shown in the figure below. 5. You can also run the file by clicking "Run" directly, as shown in the figure below. 6. Finally, you can view the running results of the m file in the command line window and workspace, as shown in the figure below. The above is the matlab method that the editor brought to you

There are three ways to open the Run dialog: using the Win + R shortcut, through the search function, or by typing "Run" directly in the Start screen.

Essential PHP programs: Install these to run smoothly! PHP is a popular server-side scripting language that is widely used to develop web applications. To successfully run a PHP program, you first need to install some necessary software and tools on the server. In this article, we will introduce the software and tools that must be installed, along with specific code examples to help you run PHP programs smoothly. 1. PHP interpreter The core of the PHP program is the PHP interpreter, which is responsible for parsing and executing PHP code. To install the PHP interpreter, you can follow
