简体   繁体   English

当我从源文件编译应用程序时,默认的目标.NET Framework版本是什么?

[英]What is the default targeted .NET Framework version when i compile an application from Source File?

In the builder application the targeted framework was set to version 4, then i changed it to version 2.0 and suddently i got an error saying : 在构建器应用程序中,目标框架设置为版本4,然后我将其更改为版本2.0,突然我收到错误说:

Error   1   No overload for method 'CreateProvider' takes 2 arguments

which was occuring on this line of code : 这行代码出现了:

provider = CodeDomProvider.CreateProvider("CSharp", providerOptions);

then i simply changed the line above to be : 然后我只是将上面的行改为:

provider = CodeDomProvider.CreateProvider("CSharp");

Now everything goes OK. 现在一切顺利。 But the question is when i don't add the ProviderOptions ( The Dictionary item which holds the compilerversion) Which net framework will be targeted ? 但问题是当我不添加ProviderOptions(包含编译器版本的字典项)时,将针对哪个网络框架? v2 or v4 ? v2还是v4?

Any help would be highly appreciated ! 任何帮助将非常感谢!

in the 2.0 version of the framework CreateProvider wasn't overloaded to accept providerOptions as you can see in the 2.0 version of the MSDN documentation 在2.0版本的框架中,CreateProvider没有重载以接受providerOptions,正如您在2.0版本的MSDN文档中看到的那样

2.0 CreateProvider 2.0 CreateProvider

whereas from the 4.0 version onwards the method is overloaded 而从4.0版开始,该方法被重载

4.0 CreateProvider 4.0 CreateProvider

I think in this case the 2.0 framework will be the one used. 我认为在这种情况下,2.0框架将是使用的框架。

Given you are running in v2.0 of the framework, I can't imagine you can target any other version of the runtime. 鉴于您在框架的v2.0中运行,我无法想象您可以针对任何其他版本的运行时。 It's a bit tricky to find confirmation of this, but you can target old frameworks from newer versions of a framework, but you can't do it the other way around. 找到这方面的确认有点棘手,但你可以从较新版本的框架中瞄准旧框架,但你不能反过来做。 It would destroy the space time continuum i'm sure. 它肯定会摧毁时空连续体。

Anyhow, here's the link to the microsoft documentation for CodeDomProvider in 2.0 http://msdn.microsoft.com/en-us/library/6yzxs14d.aspx 无论如何,这里是2.0版CodeDomProvider的microsoft文档的链接http://msdn.microsoft.com/en-us/library/6yzxs14d.aspx

and another to the referenced GetAllCompilerInfo method, that you might be able to utilise to check out compiler settings. 另一个引用的GetAllCompilerInfo方法,您可以利用它来检查编译器设置。

http://msdn.microsoft.com/en-us/library/system.codedom.compiler.codedomprovider.getallcompilerinfo.aspx http://msdn.microsoft.com/en-us/library/system.codedom.compiler.codedomprovider.getallcompilerinfo.aspx

暂无
暂无

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

相关问题 当我将源代码编译到.net框架中的exe文件时会发生什么 - what happens when i compile source code to exe file in .net framework 什么版本的 .Net 框架应该针对最终用户应用程序 - What version of .Net framework should be targeted for end user apps 我可以在版本4.6.2的Visual Studio项目中使用针对4.5.1 .net框架的库吗? - Can I use a library which is targeted to 4.5.1 .net framework in a visual studio project of version 4.6.2 如何使 .net5 C#9 默认目标框架 VS2019 - how can i make .net5 C#9 default targeted framework VS2019 如何询问运行时编译目标是哪个.NET Framework? - How to ask runtime which .NET Framework was targeted by compile? 项目的目标 .NET 框架取决于 Visual Studio 版本? - Targeted .NET framework for the project depends on Visual Studio version? 是否可以有条件地编译为 .NET Framework 版本? - Is it possible to conditionally compile to .NET Framework version? 在库中使用.Net Standard 1.4并在应用程序中使用.Net Framework 4.6.1时,无法加载文件System.IO.FileSystem,版本= 4.0.1.0 - When using .Net Standard 1.4 in a library and .Net framework 4.6.1 in and application, unable to load file System.IO.FileSystem, Version=4.0.1.0 为什么安装.NET Framework 4.51会导致针对框架第4版的应用程序中出现'Microsoft.SqlServer.Types错误 - Why does installation of .NET Framework 4.51 causes 'Microsoft.SqlServer.Types error in application targeted to ver 4 of framework 以Framework 4.0为目标的应用程序可以在Framework 2.0上运行吗? - Application Targeted for Framework 4.0 works on Framework 2.0?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM