[英]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.