F# Asp.Net CodeDom ProviderOptions 问题
我正在 IIS 7 上使用 F# 创建 ASP.NET MVC 应用程序。
当我尝试从浏览器运行它时,我遇到了包含以下内容的 YSOD:
[ArgumentNullException:值不能 为空。参数名称:字典]
System.Collections.Generic.Dictionary2..ctor(IDictionary
2 字典,IEqualityComparer`1 比较器)+12700827
System.Web.Compilation.CompilationUtil.CreateCodeDomProviderWithPropertyOptions(类型 codeDomProviderType) +84
System.Web.Compilation.CompilationUtil.CreateCodeDomProviderNonPublic(类型 codeDomProviderType) +16
System.Web.Compilation.AssemblyBuilder..ctor(CompilationSection compConfig、ICollection 引用的程序集,编译器类型 编译器类型,字符串 输出程序集名称)+469
System.Web.Compilation.CompilerType.CreateAssemblyBuilder(CompilationSection compConfig、ICollection 引用的程序集、字符串 生成的文件目录,字符串 输出程序集名称)+127
System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() +675 System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +46 System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(布尔值 isPrecompiledApp) +11321455
System.Web.Compilation.BuildManager.CompileGlobalAsax() +50 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +872
我使用 Reflector 查找了该方法,看看它是否可以为我提供更多上下文,发现它在第一行失败。
private static CodeDomProvider CreateCodeDomProviderWithPropertyOptions(Type codeDomProviderType)
{
IDictionary<string, string> providerOptions = new Dictionary<string, string>(GetProviderOptions(codeDomProviderType));
//Snip
}
这让我相信我在 Web.config 中为 F# CodeDom 指定的 propertyOptions是不正确的。但是,如果我删除它们,我会收到相同的错误。
<system.codedom>
<compilers>
<compiler language="F#;f#;fs;fsharp" extension=".fs" warningLevel="4"
type="Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider,
FSharp.Compiler.CodeDom">
<providerOption name="CompilerVersion" value="v4.0"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
关于纠正这个错误有什么想法吗?
I'm creating an ASP.NET MVC application using F# on IIS 7.
When I attempt to run it from the browser, I'm met with a YSOD containing the following:
[ArgumentNullException: Value cannot
be null. Parameter name: dictionary]
System.Collections.Generic.Dictionary2..ctor(IDictionary
2
dictionary, IEqualityComparer`1
comparer) +12700827
System.Web.Compilation.CompilationUtil.CreateCodeDomProviderWithPropertyOptions(Type
codeDomProviderType) +84
System.Web.Compilation.CompilationUtil.CreateCodeDomProviderNonPublic(Type
codeDomProviderType) +16
System.Web.Compilation.AssemblyBuilder..ctor(CompilationSection
compConfig, ICollection
referencedAssemblies, CompilerType
compilerType, String
outputAssemblyName) +469
System.Web.Compilation.CompilerType.CreateAssemblyBuilder(CompilationSection
compConfig, ICollection
referencedAssemblies, String
generatedFilesDir, String
outputAssemblyName) +127
System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
+675 System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
+46 System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean
isPrecompiledApp) +11321455
System.Web.Compilation.BuildManager.CompileGlobalAsax()
+50 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
+872
I looked up the method using Reflector to see if it could give me any more context and found that it was failing on the first line
private static CodeDomProvider CreateCodeDomProviderWithPropertyOptions(Type codeDomProviderType)
{
IDictionary<string, string> providerOptions = new Dictionary<string, string>(GetProviderOptions(codeDomProviderType));
//Snip
}
It leads me to believe that the propertyOptions I've specified in my Web.config for the F# CodeDom are incorrect. However, if I remove them I receive the same error.
<system.codedom>
<compilers>
<compiler language="F#;f#;fs;fsharp" extension=".fs" warningLevel="4"
type="Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider,
FSharp.Compiler.CodeDom">
<providerOption name="CompilerVersion" value="v4.0"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
Any ideas on correcting this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是 VS2010 Beta2 中 ASP.NET 的一个错误(现已修复,因此将在下一个版本中起作用)。它会影响任何第 3 方 CodeDOM 提供商,并且我不认为有任何解决方法。
It’s a bug in ASP.NET in VS2010 Beta2 (it has since been fixed, so will work in next release). It affects any 3rd party CodeDOM provider, and I don’t believe there is any workaround.
我找到了问题的原因。
Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider.FileExtension 被硬编码为“fs”。
在
System.CodeDom.Compiler.CodeDomCompilationConfiguration..ctor()
内部,为每种允许的语言创建了 CompilerInfo。在创建此文件时找不到 FSharp 的 CompilerInfo。FileExtension 与 System.CodeDom.Compiler.CodeDomProvider.GetCompilerInfoForExtensionNoThrow 中的
_compilerExtensions
进行比较,后者(在“fs”的情况下)向 System.CodeDom 返回 null。 Compiler.CodeDomProvider.IsDefinedExtension 然后将向System.Web.Compilation.CompilationUtil.GetProviderOptions
返回 false,后者返回导致 ArgumentNullException 的 null。感谢您为我指明了正确的方向,@Brian
I found the cause to the problem.
The Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider.FileExtension is hardcoded to "fs".
Inside of
System.CodeDom.Compiler.CodeDomCompilationConfiguration..ctor()
CompilerInfos are created for each of the allowed languages. A CompilerInfo for FSharp is not found within the creation of this.The FileExtension is compared against
_compilerExtensions
inSystem.CodeDom.Compiler.CodeDomProvider.GetCompilerInfoForExtensionNoThrow
which (in the case of "fs") returns null toSystem.CodeDom.Compiler.CodeDomProvider.IsDefinedExtension
which will then return false toSystem.Web.Compilation.CompilationUtil.GetProviderOptions
that returns the null that was causing the ArgumentNullException.Thanks for pointing me in the right direction, @Brian
也许 Brian 指出的错误可以通过在 web.config 中指定更多信息来解决:
Perhaps the bug Brian noted can be worked around by specifying some more info in web.config: