简体   繁体   English

是否可以在app.config中的“supportedRuntime”中指定.NET Service Pack?

[英]Is it possible to specify .NET service pack in “supportedRuntime” in app.config?

I have an application that runs fine on .Net 2.0 SP2, but fails to run properly on .NET 2.0 RTM. 我有一个在.Net 2.0 SP2上运行良好的应用程序,但无法在.NET 2.0 RTM上正常运行。 (FYI: It fails when calling a method a managed DLL that is a wrapper for a native DLL for USB programming). (仅供参考:当调用方法为托管DLL时,它会失败,该DLL是用于USB编程的本机DLL的包装器)。

I know you can give supported runtimes in the app.config of a C# .NET application 我知道你可以在C#.NET应用程序的app.config中提供支持的运行时

  <startup>
    <supportedRuntime version="v2.0.5727" />
    <supportedRuntime version="v4.0" />
  </startup>

However, is it also possible to specify a specific Service Pack version? 但是,是否也可以指定特定的Service Pack版本?

Thanks! 谢谢!

Edit: I did now find out which method fails between 2.0 and 2.0 SP2. 编辑:我现在确定哪个方法在2.0和2.0 SP2之间失败。 It is WaitHandle.WaitOne(int) which was added in 2.0 SP1. 它是在2.0 SP1中添加的WaitHandle.WaitOne(int)。

A tip for everyone else having the problem, the compiler doesn't say anything but if you ngen the executable with the problematic runtime, it does give you the exact error. 对于遇到问题的其他人来说,编译器没有说什么,但如果您使用有问题的运行时确定可执行文件,它确实会给您一个确切的错误。

Eg: 例如:

Warning: System.MissingMethodException: Method not found: 'Boolean System.Threading.WaitHandle.WaitOne(Int32)'. while resolving 0xa0000e1 - System.Threading.WaitHandle.WaitOne.
11/11/2010 01:54:07 [3620]: Method not found: 'Boolean System.Threading.WaitHandle.WaitOne(Int32)'. while compiling method XXX

Rogier 罗吉尔

Great explanation can be found here on why this is not possible. 这里可以找到很好的解释为什么这是不可能的。 You can locate a SO response here to address your needs. 您可以在此处找到SO响应以满足您的需求。

<supportedRuntime> doesn't actually work that way, because the 3.5 framework uses the 2.0 runtime. <supportedRuntime>实际上并不是这样工作的,因为3.5框架使用2.0运行时。 You can only specify runtimes that way, not frameworks , and the element only expresses preference, not demand. 您只能以这种方式指定运行时 ,而不能指定框架 ,并且元素仅表示首选项,而不是需求。

Try this (for .net 2.0 sp2): 试试这个(对于.net 2.0 sp2):

<supportedRuntime version="2.0.50727.1433" />

.NET Framework versions here. 这里是.NET Framework版本。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM