简体   繁体   English

如何使代码库目标.Net 4与.Net 3.5应用程序一起工作

[英]How to get code library targetting .Net 4 to work with .Net 3.5 application

I'm building a new code library and would like to use .Net 4 as my target framework as all my new apps will use .net 4. My legacy web apps use .Net 3.5. 我正在构建一个新的代码库,并希望使用.Net 4作为我的目标框架,因为我的所有新应用程序都将使用.net 4.我的旧版Web应用程序使用.Net 3.5。 I want to use this code library for all of my apps. 我想将这个代码库用于我的所有应用程序。

At this point, I see only 2 options 此时,我只看到2个选项

  1. Compile the dll for each framework I need, changing the target framework each time 为我需要的每个框架编译dll,每次都改变目标框架
  2. Create separate projects with differing target frameworks. 使用不同的目标框架创建单独的项目。

Is there any way around this so my code library is a single compile? 有没有办法绕过这个,所以我的代码库是一个单独的编译? Didn't know if there was something built into 4 to allow something like this. 不知道4中是否有东西允许这样的东西。

Why not just build your libraries against .NET 3.5? 为什么不直接针对.NET 3.5构建库?

  • If they're trying to use .NET 4 features then obviously they won't work against your .NET 3.5 webapps anyway 如果他们试图使用.NET 4功能,那么显然他们无论如何都不会对你的.NET 3.5 webapps起作用
  • If they're not, then using .NET 3.5 should be fine 如果他们不是,那么使用.NET 3.5应该没问题

There are some caveats around interop and mixed-mode assemblies, but for pure-C# assemblies it shouldn't be a problem. 互操作和混合模式程序集有一些警告,但对于纯C#程序集,它应该不是问题。

It's possible to have different build configurations targeting different versions of the framework, but a bit of a pain - you'll need to mess with the project files manually. 可以针对不同版本的框架使用不同的构建配置,但有点痛苦 - 您需要手动处理项目文件。 See the project files for MiscUtil as an example. MiscUtil的项目文件为例。

I don't see why you were happy with the .NET 2 / .NET 3.5 situation before - it's not very significantly different to that. 我不明白为什么你对之前的.NET 2 / .NET 3.5情况感到满意 - 这与它没有太大的不同。

Of course, updating your webapps to run on .NET 4 would probably be the best solution, going forward. 当然,更新您的webapps以在.NET 4上运行可能是最好的解决方案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将针对.NET 3.5的MEF部件与针对.NET 4.0的应用程序混合使用 - Mixing MEF parts targetting .NET 3.5 with an application targetting .NET 4.0 ASP.NET 3.5 Facebook iframe应用程序库或示例有效吗? 专门标记照片 - ASP.NET 3.5 Facebook iframe application Library or Samples that work? Specifically tagging photos 如何在VS 2017 RC中创建针对.NET Framework 4.5.1和.NET Standard 1.3的库? - How should I create a library targetting .NET Framework 4.5.1 and .NET Standard 1.3 in VS 2017 RC? 如何使用.net 3.5在Visual Studio 2008,asp.net Web应用程序中生成QR码? - How to generate QR code in visual studio 2008,asp.net web application using .net 3.5? 如何强制应用程序使用.NET 3.5或更高版本? - How to force an application to use .NET 3.5 or above? 如何部署现在正在使用任务并行库反向移植的.net 3.5应用程序 - How to deploy .net 3.5 application that is now using the task parallel library backport 如何编写一个可以在.NET 3.5紧凑框架和常规框架上工作的类库? - How to write a class library that will work on .NET 3.5 compact framework AND regular framework? Library Targetting .NET 4.5.1和Windows 8.1 / WP8.1中的套接字 - Sockets in Library Targetting .NET 4.5.1 and Windows 8.1/WP8.1 如何在.NET 3.0计算机上部署ClickOnce .NET 3.5应用程序? - How to deploy a ClickOnce .NET 3.5 application on a .NET 3.0 machine? 如何强制.NET 3.5应用程序在.NET 4.5运行时运行? - How to force .NET 3.5 application run on .NET 4.5 runtime?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM