Strange Behavior of Hello World Example

18 views
Skip to first unread message

mlJakov

unread,
Sep 13, 2015, 9:56:51 AM9/13/15
to WebSharper
Dear forum community,

I have been trying to run the basic Hello World example as described on the page:
http://websharper.com/docs/running-snippets

The source code compiles error-free on my platform MonoDevelop 5.9.5 on Centos 7. The HelloWorld page runs without errors reported by MonoDevelop and is accessible by the browser on 127.0.0.1:8080. However, the result is just an empty page with the title set to "HelloWorld".

Here is my source code in Client.fs from the tutorial:

namespace HelloWorld

open WebSharper
open WebSharper.JavaScript
open WebSharper.Html
open WebSharper.Html.Client

[<JavaScript>]
module HelloWorld =

    let Main () =
        let welcome = P [Text "Welcome"]
        Div [
            welcome
            Button [Text "ClickMe!"]
            |>! OnClick (fun e args ->
                welcome.Text <- "Bonjour Monsigneur!")
        ]

    let _ = Main () |> fun res -> res.AppendTo "entrypoint"


The index.html file looks like this:


<!DOCTYPE html>
<html lang="en">
<head>
    <title>HelloWorld</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="Content/HelloWorld.css" />
    <script type="text/javascript" src="Content/HelloWorld.head.js"></script>
</head>
<body>
    <div id="entrypoint" />
    <script type="text/javascript" src="Content/HelloWorld.min.js"></script>
</body>
</html>


Browser output from 127.0.0.1:8080 is this:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>HelloWorld</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="Content/HelloWorld.css" />
    <script type="text/javascript" src="Content/HelloWorld.head.js"></script>
</head>
<body>
    <div id="entrypoint" />
    <script type="text/javascript" src="Content/HelloWorld.min.js"></script>
</body>
</html>

Apparently, nothing from the Client.fs source code is appended to the div element in the web page.
What could be the cause of this? I have installed the websharper package by using nuget. There is one clue in monodevelop, however;
it reports: "Assembly
not found for framework Mono/.NET 4.0" under FSharp.Core in the References section of the HelloWorld
project tree. As I am new to this framework, I am somewhat puzzled by this message, since I have the FSharp compiler and interpreter packages installed.

Thank you in advance!

Adam Granicz

unread,
Sep 14, 2015, 8:28:24 AM9/14/15
to websh...@googlegroups.com
The docs were written to accommodate the least amount of code changes required to run the current samples off the website, so they have some funkiness (and they also use the old Html.Client syntax not the upcoming UI.Next one).

This line in particular:

let _ = Main () |> fun res -> res.AppendTo "entrypoint" 

... doesn't work without a giving an actual name for the binding.  Once you give one, it should work fine.

Cheers,
Adam.

--
You received this message because you are subscribed to the Google Groups "WebSharper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to websharper+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Adam Granicz, IntelliFactory
www.intellifactory.com

mlYakov

unread,
Sep 14, 2015, 11:28:30 AM9/14/15
to WebSharper
Thanks for the reply!

After removing redundant repositories and reinstalling the packages, monodevelop now shows no library errors internally. However the Hello World example still does not work. I have tried the WebSharper HTML Application in monodevelop. Building it causes no errors to be reported. When I try to run the application in the browser I get the following message:


System.IO.FileNotFoundException

Could not load file or assembly or one of its dependencies.

Description: HTTP 500.Error processing request.

Details: Non-web exception. Exception origin (name of application or object): mscorlib.

Exception stack trace:
at (wrapper managed-to-native) System.Reflection.Module:InternalGetTypes (System.Reflection.Module) at System.Reflection.MonoModule.GetTypes () [0x00000] in /builddir/build/BUILD/mono-4.0.4/mcs/class/corlib/System.Reflection/MonoModule.cs:296 at WebSharper.Sitelets.Si...@51-2.Invoke (System.Reflection.Module m) [0x00000] in <filename unknown>:0

I have version 4.0.0.0 of mscorlib installed in monodevelop. Any ideas why this error comes?


Reply all
Reply to author
Forward
0 new messages