Create a dll library in several frameworks

I have seen many libraries released in several frames. In any structure you choose, the namespaces of the library are the same, but the dll is compiled into .net 2.0, 3.5, or 4.0.

What is the standard or best practice for using the same code in different frameworks? I am curious if there is code duplication or is there a better way.

+4
source share
2 answers

a viable way would be to have a solution with several projects or even with several solutions that you open one by one in Visual Studio, but project files (C # or VB.NET) always point to the same file in the file system.

for example, several projects in the same solution, one project contains the file normally, and other projects have a link to the file, are added by right-clicking on the project, adding an existing item, selecting a file, and then click the down arrow Add button and select Add as Link .

of course, if the file contains code that belongs to certain frameworks, you should put an if or #ifdef and so on ...

+4
source

Make two copies of the project file in one folder and edit the Target Framework in one of them.

Each time you add a new source file, you must include it in the second project.

+1
source

All Articles