Adam kindly answered on the Warp Gitter chat room - but just so there's some reference to the answer here, here's what he said:

[<Query(...)>] declares a given sitelet endpoint argument to be a GET parameter which also means you need to name that argument, so you can pass it to [<Query(...)>]

So in your case:

... | [<EndPoint "GET /queries">][<Query("whatever")>] MultipleQuery of whatever: int

this will then match URLs like /queries?whatever=1

By on 7/19/2015 7:14 PM ()

I'm finding problems with these endpoints:

1
2
3
4
5
6
7
type Endpoints =
    | [<EndPoint "GET /plaintext">] Plaintext    
    | [<EndPoint "GET /json">]      Json    
    | [<EndPoint "GET /fortunes">]  Fortunes    
    | [<EndPoint "GET /db">]        SingleQuery    
    | [<EndPoint "GET /queries">][<Query("numQueries")>]  MultipleQuery of numQueries: int    
    | [<EndPoint "GET /updates">][<Query("numQueries")>]  DataUpdate of numQueries: int

I get what I believe is the same exception:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
System.Exception: Error starting website:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Cannot cast from source type to destination type.
  at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
  at WebSharper.Compiler.ReflectionLayer+Reflection+-ctor@686-10.Invoke (System.Object x) [0x00000] in <filename unknown>:0 
  at WebSharper.Compiler.ReflectionLayer+Reflection+ConvertAttributes@696-1.GenerateNext (IEnumerable`1& next) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1[WebSharper.Compiler.ReflectionLayer+CustomAttributeArgument].MoveNextImpl () [0x00018] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/fsharp-fsharp-1f79c04/src/fsharp/FSharp.Core/seq.fs:764 
  at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1[WebSharper.Compiler.ReflectionLayer+CustomAttributeArgument].System-Collections-IEnumerator-MoveNext () [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/fsharp-fsharp-1f79c04/src/fsharp/FSharp.Core/seq.fs:793 
  at Microsoft.FSharp.Collections.SeqModule.ToList[CustomAttributeArgument] (IEnumerable`1 source) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/fsharp-fsharp-1f79c04/src/fsharp/FSharp.Core/seq.fs:221 
  at WebSharper.Compiler.ReflectionLayer+Reflection+ConvertAttributes@692.GenerateNext (IEnumerable`1& next) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1[WebSharper.Compiler.ReflectionLayer+CustomAttribute].MoveNextImpl () [0x00018] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/fsharp-fsharp-1f79c04/src/fsharp/FSharp.Core/seq.fs:764 
  at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1[WebSharper.Compiler.ReflectionLayer+CustomAttribute].System-Collections-IEnumerator-MoveNext () [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/fsharp-fsharp-1f79c04/src/fsharp/FSharp.Core/seq.fs:793 
  at Microsoft.FSharp.Collections.SeqModule.ToList[CustomAttribute] (IEnumerable`1 source) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/fsharp-fsharp-1f79c04/src/fsharp/FSharp.Core/seq.fs:221 
  at WebSharper.Compiler.ReflectionLayer+Reflection+Converter.ConvertAttributes (IList`1 attrs) [0x00000] in <filename unknown>:0 
  at WebSharper.Compiler.ReflectionLayer+Reflection+-ctor@753-15.Invoke (Microsoft.FSharp.Core.Unit unitVar) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Control.LazyExtensions+Create@5771[Microsoft.FSharp.Collections.FSharpList`1[WebSharper.Compiler.ReflectionLayer+CustomAttribute]].Invoke () [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/fsharp-fsharp-1f79c04/src/fsharp/FSharp.Core/prim-types.fs:5771 
  at System.Lazy`1[Microsoft.FSharp.Collections.FSharpList`1[WebSharper.Compiler.ReflectionLayer+CustomAttribute]].CreateValue () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00069] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.2/mcs/class/corlib/System.Reflection/MonoMethod.cs:238 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.2/mcs/class/corlib/System.Reflection/MethodBase.cs:114 
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00107] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.2/mcs/class/corlib/System/Delegate.cs:462 
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00018] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.2/mcs/class/corlib/System/MulticastDelegate.cs:70 
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.2/mcs/class/corlib/System/Delegate.cs:407 
  at Microsoft.Owin.Builder.AppBuilder.BuildInternal (System.Type signature) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Builder.AppBuilder.Build (System.Type returnType) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create (IAppBuilder builder) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer (Microsoft.Owin.Hosting.Engine.StartContext context) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Hosting.Engine.HostingEngine.Start (Microsoft.Owin.Hosting.Engine.StartContext context) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Hosting.WebApp.StartImplementation (IServiceProvider services, Microsoft.Owin.Hosting.StartOptions options, System.Action`1 startup) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Hosting.WebApp.Start (Microsoft.Owin.Hosting.StartOptions options, System.Action`1 startup) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Hosting.WebApp.Start (System.String url, System.Action`1 startup) [0x00000] in <filename unknown>:0 
  at WebSharper.Warp.Run[Endpoints] (WebSharper.Sitelets.Sitelet`1 sitelet, Microsoft.FSharp.Core.FSharpOption`1 debug, Microsoft.FSharp.Core.FSharpOption`1 url, Microsoft.FSharp.Core.FSharpOption`1 rootDir, Microsoft.FSharp.Core.FSharpOption`1 scripted, Microsoft.FSharp.Core.FSharpOption`1 assembly) [0x00000] in <filename unknown>:0 
  at <StartupCode$WebSharper-Warp>.$Warp+Run@239-1.Invoke (System.String message) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.PrintfImpl+StringPrintfEnv`1[WebSharper.Warp].Finalize () [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/fsharp-fsharp-1f79c04/src/fsharp/FSharp.Core/printf.fs:1291 
  at Microsoft.FSharp.Core.PrintfImpl+Final1@224[Microsoft.FSharp.Core.Unit,System.String,WebSharper.Warp,System.String].Invoke (Microsoft.FSharp.Core.FSharpFunc`2 env, System.String a) [0x00038] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/fsharp-fsharp-1f79c04/src/fsharp/FSharp.Core/printf.fs:228 
  at Microsoft.FSharp.Core.OptimizedClosures+Invoke@3028[System.String,WebSharper.Warp,Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Core.PrintfImpl+PrintfEnv`3[Microsoft.FSharp.Core.Unit,System.String,WebSharper.Warp]]].Invoke (System.String u) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr2/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/fsharp-fsharp-1f79c04/src/fsharp/FSharp.Core/prim-types.fs:3028 
  at WebSharper.Warp.Run[Endpoints] (WebSharper.Sitelets.Sitelet`1 sitelet, Microsoft.FSharp.Core.FSharpOption`1 debug, Microsoft.FSharp.Core.FSharpOption`1 url, Microsoft.FSharp.Core.FSharpOption`1 rootDir, Microsoft.FSharp.Core.FSharpOption`1 scripted, Microsoft.FSharp.Core.FSharpOption`1 assembly) [0x00000] in <filename unknown>:0 
  at WebSharper.Warp.RunAndWaitForInput[Endpoints] (WebSharper.Sitelets.Sitelet`1 app, Microsoft.FSharp.Core.FSharpOption`1 debug, Microsoft.FSharp.Core.FSharpOption`1 url, Microsoft.FSharp.Core.FSharpOption`1 rootDir, Microsoft.FSharp.Core.FSharpOption`1 scripted, Microsoft.FSharp.Core.FSharpOption`1 assembly) [0x00000] in <filename unknown>:0 
By on 7/20/2015 6:37 AM ()

Works fine on Windows. Seems like a mono issue but I cannot confirm this atm.

By on 7/20/2015 7:13 AM ()

Is this something I can/should report as an issue?

By on 7/25/2015 7:50 PM ()

Yes, please open an issue with detailed information on your OS and mono versions in the Warp repository if the above code doesn't run on latest version of Warp.

By on 7/27/2015 1:42 AM ()

This appears to be working properly with the latest WebSharper (3.3.1.177) and Warp (3.3.1.24) -- I thought I was up-to-date but apparently I wasn't.

By on 7/28/2015 8:55 PM ()

I'm trying this suggestion, with a clean build. Still getting the same exception...?

By on 7/20/2015 6:06 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper