Search code examples
wpfxamlf#esri

F# WPF Esri Developer License


I have gone to License your app and there is only code for C#. I am wondering where to place the license information in my F# WPF application. Does it go in the app.fs file or a different one.

Thanks


Solution

  • I'm not familiar with this SDK but it should go into the assembly (so exe or dll) file that uses it. It would've been helpful to show the C# code, and not just the link:

    Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.ClientId = "mYcLieNTid";
    
    try
    {
        Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.Initialize();
    }
    catch (Exception ex)
    {
        Console.WriteLine("Unable to initialize the ArcGIS Runtime with the client ID provided: " + ex.Message);
    

    }

    From the recently much improved F# docs Try/With is the equivalent exception handling mechanism in F#:

    Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.ClientId <- "mYcLieNTid";
    
    try
        Esri.ArcGISRuntime.ArcGISRuntimeEnvironment.Initialize()
    with
        | ex -> printfn "Unable to initialize the ArcGIS Runtime with the client ID provided: %A" ex.Message 
    

    Additional Info: If you have time please take a look at F# for fun and also Modules and Classes, you can also search these topics on SO. Here are some comments:

    1. F# is sensitive to the file order in the project, please make sure that you put your module above the file that is open-ing it
    2. you generally #load *.fsx scripts, you can but you don't need to do this for *.fs files, as those assumed to be built into an assembly. You can just say open File1 assuming you have a File1.fs and inside it a module File1, then if inside the File1 module you have let let x = 5, you can say File1.x to access it
    3. You don't need to put a module into a separate file. You can just place it ino the namespace you have your SDK in (maybe App.fs).
    4. Easiest would be to actually put this code inside your main function, in the [<EntryPoint>]