3

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(IDictionary2 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?

4

3 回答 3

4

这是 VS2010 Beta2 中的 ASP.NET 中的一个错误(它已被修复,因此将在下一个版本中使用)。它会影响任何 3rd 方 CodeDOM 提供程序,我认为没有任何解决方法。

于 2009-11-13T20:51:56.177 回答
3

我找到了问题的原因。

Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider.FileExtension 被硬编码为“fs”。

CompilerInfos内部System.CodeDom.Compiler.CodeDomCompilationConfiguration..ctor()为每种允许的语言创建。在此创建过程中找不到 FSharp 的 CompilerInfo。

internal CodeDomCompilationConfiguration()
{
this._compilerLanguages = new Hashtable(StringComparer.OrdinalIgnoreCase);
this._compilerExtensions = new Hashtable(StringComparer.OrdinalIgnoreCase);
this._allCompilerInfo = new ArrayList();
CompilerParameters compilerParams = new CompilerParameters();
compilerParams.WarningLevel = 4;
string codeDomProviderTypeName = "Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
CompilerInfo compilerInfo = new CompilerInfo(compilerParams, codeDomProviderTypeName);
compilerInfo._compilerLanguages = new string[] { "c#", "cs", "csharp" };
compilerInfo._compilerExtensions = new string[] { ".cs", "cs" };
compilerInfo._providerOptions = new Dictionary<string, string>();
compilerInfo._providerOptions["CompilerVersion"] = "v4.0";
this.AddCompilerInfo(compilerInfo);
compilerParams = new CompilerParameters();
compilerParams.WarningLevel = 4;
codeDomProviderTypeName = "Microsoft.VisualBasic.VBCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
compilerInfo = new CompilerInfo(compilerParams, codeDomProviderTypeName);
compilerInfo._compilerLanguages = new string[] { "vb", "vbs", "visualbasic", "vbscript" };
compilerInfo._compilerExtensions = new string[] { ".vb", "vb" };
compilerInfo._providerOptions = new Dictionary<string, string>();
compilerInfo._providerOptions["CompilerVersion"] = "v4.0";
this.AddCompilerInfo(compilerInfo);
//Snip
}

将 FileExtension 与哪个(_compilerExtensionsSystem.CodeDom.Compiler.CodeDomProvider.GetCompilerInfoForExtensionNoThrow“fs”的情况下)返回 null 进行比较System.CodeDom.Compiler.CodeDomProvider.IsDefinedExtension,然后将返回 false 以System.Web.Compilation.CompilationUtil.GetProviderOptions返回导致 ArgumentNullException 的 null。

感谢您为我指明正确的方向,@Brian

于 2009-11-13T21:47:10.140 回答
0

也许布赖恩注意到的错误可以通过在 web.config 中指定更多信息来解决:

type="Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider, 
      FSharp.Compiler.CodeDom,
      Version=1.9.7.8, 
      Culture=neutral, 
      PublicKeyToken=a19089b1c74d0809"
于 2009-11-13T21:01:28.730 回答