4

So I have been looking at developing RIA or MVC applications using F# and I saw that there were two options :

  1. FunScript
  2. WebSharper

I have a Visual Studio 2012 version and it's a student edition. So I just followed the getting started link here

Now after following the instructions, I am not able to get the test page. So I would need some directions/help to proceed. So this is what happens :

  1. After creating a Web Application Sitelets using the New Project, I get an error in the Site.fs page. It gives the same "module or namespace not defined". So what I try to do is use Manage NuGet References to load the references for WebSharper and it removes the error. Now I have already installed WebSharper in my machine. Shouldn't there be an easy way to link the WebSharper libraries. If so how can I do it? What is it that I am doing wrong here.

  2. After resolving the issue I follow the getting started code to the last line in that page, I get an error in this code sample :

let HomePage = Template "HomePage" <| fun ctx -> [ Div [Text "HOME"] Links ctx Div [new Controls.HelloControl()] ]

Essentially the page does not like the new Div [ new Controls.HelloControl()] added and so it throws an error.

I am a beginner to Microsoft technologies and even the Visual Studio IDE. I am used to Eclipse and figuring out how it works has never been a problem. But I am completely clueless here on how to make this work.

At the end of it I also have a query on where I can find updated documentation on a decent introduction to both FunScript and WebSharper.

N00bsie
  • 469
  • 3
  • 19
  • Alright I have found a way to work around with the issue, Now all that I am stuck with is this problem. When I click on F5 to run the application I get an error "A Project with an Output Type of Class Library cannot be started directly". Now I have fiddled with the properties to try and change it to both Windows Application and a Console application, I don't think that's the right way either. I just need to figure out how to run this now. – N00bsie Jul 17 '13 at 03:48
  • If you have figured out how to get around this problem, post an answer to help anyone who has the same problem in the future. You can also edit your question with updates. – John Palmer Jul 17 '13 at 03:59
  • What I meant is that I don't have errors anymore, but I have no clue on how to run it. Perhaps you could guide me on how to run this application now. I am a bit clueless there. I'll just post what I did. I guess it's just me being a novice and trying to figure this out. – N00bsie Jul 17 '13 at 04:09
  • My reputation is also pretty low, so it doesn't allow me to post the answer. However I still haven't figured out how to run the example. So I am still stuck there. – N00bsie Jul 17 '13 at 04:19
  • That doesn't sound right, you should always be able to post answers - although there might be a rate limit – John Palmer Jul 17 '13 at 06:36
  • @N00bsie F# is indentation sensitive. When you pull down a code sample in F# be very careful to insure that whitespace is preserved. – Onorio Catenacci Jul 17 '13 at 18:42

1 Answers1

5

For the original issue, the problem is with the sample on the website -- somehow the whitespace has been munched, the code should be:

let HomePage =
    Template "HomePage" <| fun ctx ->
        [
            Div [Text "HOME"]
            Links ctx
            Div [new Controls.HelloControl()]
        ]

Now for "A Project with an Output Type of Class Library cannot be started directly":

The solution consists of two projects: a C# Web project, which hosts the web application, and an F# library project, which contains the actual code. All you have to do is right-click on the C# project in the solution explorer and select "Set as Startup Project". This way, when you press "F5", instead of trying to run the F# library project, it will start the web project.

Tarmil
  • 11,177
  • 30
  • 35
  • Thanks a lot @Tarmil. I figured out the code part, but was still looking at how to run the code. This has solved a lot of issues. Thanks! – N00bsie Jul 17 '13 at 13:15