回答済み open System.Windows.Forms

  • Saturday, July 14, 2012 4:59 PM
     
     

    Why does

    open System.Windows.Forms

    work in the immediate F# window but gives an error in the edit window

All Replies

  • Saturday, July 14, 2012 7:56 PM
     
     
    Could you please clarify a litle bit more what error do you get? Does your project refer to System.Windows.Form.dll. Do you have #r "System.Windows.Forms.dll" directive in your immediate window?

    Petr

  • Sunday, July 15, 2012 11:10 AM
     
     

    Type

    open System.Windows.Forms

    in the Edit window. The wavy red line appears under Windows.

    Hover the mouse pointer over Windows.

    The error message "The namespace 'Windows' is not defined" appears

  • Sunday, July 15, 2012 12:30 PM
     
     Answered
    You probably need to add reference to System.Windows.Forms to your project

    Petr

  • Sunday, July 15, 2012 2:57 PM
     
     

    Thank you, that has solved the problem.

    THe book Programming F# by O'Reilly doesnt mention setting up references, so thank you very much

    Henry

  • Monday, July 16, 2012 1:27 PM
     
     

    I don't have the book here right now but I think it was mentioned somewhere.

    Anyhow: those books tend to be written for people already familiar with .NET and references, namespaces. etc. is the same in any core-language (C#/VB.net/F#) so it might be missing.

    But if you read the online-documentation for open (Import Decleratiopns: The open Keyword) you will find all this wonderful explained - so the first thing you should look for is msdn or a simple google search ;)

    Right from the MSDN:

    "The module or namespace provided must be in the same project or in a referenced project or assembly. If it is not, you can add a reference to the project, or use the -reference command-line option (or its abbreviation, -r). For more information, see Compiler Options (F#)."