F # Asp.Net CodeDom ProviderOptions Issue

I am creating an ASP.NET MVC application using F # on IIS 7.

When I try to launch it from a browser, I am greeted by an YSOD containing the following:

[ArgumentNullException: value cannot be null. Parameter name: Dictionary]
System.Collections.Generic.Dictionary 2..ctor(IDictionary2 Dictionary, IEqualityComparer`1 comparative) +12700827
System.Web.Compilation.CompilationUtil.CreateCodeDomProviderWithPropertyOptions (Type codeDomProviderType) +84
System.Web.Compilation.CompilationUtil.CreateCodeDomProviderNonPublic (codeDomProviderType type) +16
System.Web.Compilation.AssemblyBuilder..ctor (CompilationSection compConfig, ICollection referencedAssemblies, CompilerType compilerType, String outputAssemblyName) +469
System.Web.Compilation.CompilerType.CreateAssemblyBuilder (CompilationSectionFileComposition, Compilation ICectionFileConfile, Compilation, Section, Compilation, Compilation 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 was looking for a method using Reflector to find out if it can give me more context and found that it does not work on the first line

private static CodeDomProvider CreateCodeDomProviderWithPropertyOptions(Type codeDomProviderType)
{
IDictionary<string, string> providerOptions = new Dictionary<string, string>(GetProviderOptions(codeDomProviderType));
//Snip
}

This leads me to believe that the Property properties that I specified in my Web.config for F # CodeDom are incorrect. However, if I delete them, I get 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 for fixing this error?

+3
3

.

Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider.FileExtension "fs".

System.CodeDom.Compiler.CodeDomCompilationConfiguration..ctor() CompilerInfos . Info FSharp .

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 _compilerExtensions System.CodeDom.Compiler.CodeDomProvider.GetCompilerInfoForExtensionNoThrow, ( "fs" ) null System.CodeDom.Compiler.CodeDomProvider.IsDefinedExtension, false System.Web.Compilation.CompilationUtil.GetProviderOptions, null, ArgumentNullException.

, , @Brian

+3

ASP.NET VS2010 Beta2 ( , ). CodeDOM, , - .

+4

Perhaps the error noted by Brian can be resolved by providing additional information in web.config:

type="Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider, 
      FSharp.Compiler.CodeDom,
      Version=1.9.7.8, 
      Culture=neutral, 
      PublicKeyToken=a19089b1c74d0809"
0
source

Source: https://habr.com/ru/post/1722812/


All Articles