如何将.Net3.5 dll添加到.Net2.0项目中? [英] How to add .Net3.5 dll into .Net2.0 project?

查看:50
本文介绍了如何将.Net3.5 dll添加到.Net2.0项目中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于.net 3.5的dll-例如在内部使用Linq,但是公开的API很简单,没有花哨的东西.由于C#泛型是在编译时解析的,所以我假设对于调用方而言,它计算的只有API(所有公共部分).

I have a dll which is based on .net 3.5 -- it uses internally for example Linq, but the exposed API is straightforward, no fancy stuff. Since C# generics are resolved at compile time I assume that for calling party all it counts is API (all public parts).

但是,当我尝试从net2.0项目中使用此dll时,我得到信息,该dll无法引用,因为该dll或其依赖项之一需要更高版本的.net框架.

However when I try to use this dll from net2.0 project I get info, that the dll cannot be referenced because the dll or one of its dependencies requires a later version of .net framework.

我可以在目标计算机上安装想要的任何.net版本(安装整个应用程序时),但是我不能为项目本身更改.net版本.

I can install any .net version I want on target computer (when entire app is installed), but I cannot change .net version for the project itself.

所以:如何解决这个问题?向该项目添加C dll时我没有此类问题,所以C#dll是否自包含?

So: how to solve this? When adding a C dll to this project I had no such problems, so are C# dlls self-contained or not?

推荐答案

C#dll必须具有.Net运行时才能运行,因为它们没有被编译为机器代码.在这种情况下,dll表示需要Net 3.5,因此您的所有项目都必须使用3.5或更高版本.

C# dlls need to have the .Net runtime to run as they are not compiled down to machine code. In this case the dll says it requires Net 3.5 so all your project will have to use 3.5 or higher.

要使您的项目保持为Net 2.0,您需要构建另一个可执行文件以包含3.5 DLL并在单独的进程之间进行通信.

To keep your project as Net 2.0 you would need to build another executable to contain the 3.5 DLL and communicate across separate processes.

C DLL可以正常工作,因为它被编译为本机代码,并且不需要.Net框架.(或至少不高于2.0版)

The C DLL worked as it is compiled down to native code and does not require the .Net framework. (or at least not version higher than 2.0)

这篇关于如何将.Net3.5 dll添加到.Net2.0项目中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆