Bin DLL 的目标可能是不同的 .NET 框架吗?
我有一个当前在 .NET 3.5 下运行的网站。我正在考虑让它在4.0下运行,但是我使用许多第三方DLL来压缩,Bit.ly,Twitter,XML等。如果这些DLL是为.NET 3.5(在VS2008中)创建的,它们会继续运行吗3.5以下?或者 4.0 是否以某种方式向后兼容旧库?
I have a website that is currently running under .NET 3.5. I am thinking of making it run under 4.0, but I use many 3rd-party DLL's for compressing, Bit.ly, Twitter, XML, etc. If these DLL's were created for .NET 3.5 (in VS2008), will they continue to run under 3.5? Or is 4.0 somehow backwards compatible for old libraries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不存在在 3.5 以下运行的情况。 .NET 程序集针对 .NET 版本进行编译,然后由 CLR 加载和执行。 .NET 3.5 使用 CLR 2.0,.NET 4.0 使用 CLR 4.0。
因此,如果您的应用程序在 CLR 4.0 下运行,这些程序集将在 CLR 4.0 下运行,CLR 4.0 向后兼容针对 .NET 3.5 编译的程序集。如果这些程序集调用非托管函数,可能会出现一些警告,但否则它们应该可以正常工作。
继续尝试运行它们。
There's no such thing as running under 3.5. .NET assemblies are compiled against a .NET version and then loaded and executed by the CLR. .NET 3.5 uses CLR 2.0 and .NET 4.0 uses CLR 4.0.
So if your application is running under the CLR 4.0 those assemblies will run under the CLR 4.0 which is backwards compatible with assemblies compiled against .NET 3.5. There could be some caveats if those assemblies call unmanaged functions but otherwise they should work just fine.
Go ahead and try running them.
如果它们是纯粹的托管代码,我希望它们能够在 .NET 4 下正常工作。如果它们使用非托管 API,我相信可能会出现一些问题,您可能需要重建这些问题库 - 但如果它们是开源的,那应该不是问题。
(我知道有一个数据库提供商至少直到最近才提供 .NET 3.5 DLL,并且它们不能在 .NET 4 中工作,正是因为它们通过 P/Invoke 使用非托管 API。我不知道详细信息不幸的是,该领域发生了变化 - 我倾向于像瘟疫一样避免 P/Invoke :)
If they're purely managed code, I'd expect them to work just fine under .NET 4. If they use unmanaged APIs, I believe there can be some problems, and you may need to rebuild those libraries - but if they're open source, that shouldn't be a problem.
(I know that there's one database provider who at least until recently only provided .NET 3.5 DLLs, and they didn't work in .NET 4 precisely because they used unmanaged APIs via P/Invoke. I don't know the details of what's changed in that area, unfortunately - I tend to avoid P/Invoke like the plague :)