0

I've got an ASPX page like this:

<%@ Page Language="F#" %>
<!DOCTYPE html>
<html>
<head>   
   <title></title>
</head>
<body>
   <%-- Try to output "This is a Test" 10 times --%>
   <% for i = 1 To 10 do  %>
      <p>This is a test</p>   
</body>
</html>

and a web.config that looks like this:

<?xml version="1.0"?>
<configuration>
   <system.codedom>
      <compilers>
         <compiler language="F#;f#;fs;fsharp"
            extension=".fs"
            warningLevel="4"
            type="Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider,
            FSharp.Compiler.CodeDom, Version=2.0.0.0,
            Culture=neutral,
            PublicKeyToken=a19089b1c74d0809">
            <providerOption name="CompilerVersion" value="v4.0" />
            <providerOption name="WarnAsError" value="false" />
         </compiler>
      </compilers>
   </system.codedom> 
   <system.web>
      <compilation debug="true" targetFramework="4.0" />
   </system.web>
</configuration>   

When I run my VS2010 WebApp, I get an error like this:
"The CodeDom provider type "Microsoft.FSharp.Compiler.CodeDom.FSharpAspNetCodeProvider,
FSharp.Compiler.CodeDom, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=a19089b1c74d0809" could not be located."

I've tried the settings mentioned by manojlds here, but they don't seem to be working for me either. I think it is because my copy of VS2010 Pro has a newer version of the F# compiler, but I don't know how to tell for sure.

Can someone help me understand the correct version settings that I should use in a VS2010 web.config for the "compiler" and "providerOption" elements?

Community
  • 1
  • 1
Shawn Eary
  • 684
  • 2
  • 7
  • 21
  • Sorry, I forgot to mention that the web.config code that manojlds cites seems to have originated from a Podwysocki post here: http://codebetter.com/matthewpodwysocki/2008/10/07/asp-net-mvc-with-nhaml-f-edition/ Manojlds cited the source correctly, but I think ->I<- got a bit sloppy last night. – Shawn Eary Feb 07 '13 at 12:57

1 Answers1

2

I have not tried this, but your configuration file looks correct to me - can you check what eversion of the FSharp.Compiler.CodeDom assembly is installed in your GAC (by looking at C:\windows\assembly)?

However, at the moment, I would not really recommend using F# for writing of the ASPX part of a web page. It works, but you won't get as smooth experience when mixing C# with ASPX or using the Razor templating engine (for ASP.NET MVC).

I think the best way to create server-side ASP.NET web applications in F# is to use F# for the code behind (in traditional WebForms) or for the model and controller parts (in MVC). There is also a number of templates and tutorials that describe how to do this:

Tomas Petricek
  • 240,744
  • 19
  • 378
  • 553
  • Petricek Said: "Can you check what version of the FSharp.Compiler.CodeDom assembly is installed in your GAC...?" - Funny, I just looked and I didn't see that file in my GAC. So I installed the FSharp PowerPack for VS2010 from CodePlex and this error went away. Now, I am getting some weird processor Architecture Mismatch errors but that is another story and I *think* it has something to do with the fact that I have VS2012 Express for Win8 and VS2010 Pro on the same Win8 PC: http://stackoverflow.com/questions/10113532/how-do-i-fix-the-net-c-c-error-mismatch-between-processor-architecture – Shawn Eary Feb 08 '13 at 04:49