hubFS: THE place for F#

. . . are you on The Hub?
Welcome to hubFS: THE place for F# Sign in | Join | Help
in Search

Reference a C# project in F#

Last post 06-06-2008, 16:56 by fwoolz. 3 replies.
Sort Posts: Previous Next
  •  06-05-2008, 9:13 6072

    Reference a C# project in F#

    I have a VS Solution with 2 projects - 1 C# and 1 F# project. I want a F#-class to implement a C#-class.
    I figured that it should be like this:

    open Cs

    type FsClass =
      class
        interface Cs.IMyList


    But it says: The namespace or module 'Cs' is not defined. What to do, what to do?
  •  06-05-2008, 17:09 6074 in reply to 6072

    Re: Reference a C# project in F#

    It sounds like you need to add the C# dll corresponding to "Cs" and its directory to the  F# project property page. Click Project->Properties while in the F# project and add the path of the directory containing the dll and the name of the dll to the field labeled "DLL references, paths, and other flags", as follows (assuming it is on drive C; replace "Path to dll" with the actual path [in quotes] and the dll name with the actual name of the Dll [no quotes]):

    -I "C:\PathToCsDll" -r Cs.dll

    You will need to do this for all assemblies referenced by the F# project (if they haven't already been added automatically by VS).

    Hope this helps!

    Fred
  •  06-06-2008, 15:55 6090 in reply to 6074

    Re: Reference a C# project in F#

    Thank you very much, this helps. But now I have a syntax erro on the 'type' keyword:

    #light

    open Cs;

    module Fs

    type Fs<'a> =

    class

    interface Cs.IMyList

    ...

    end

     

    Please help!!!

  •  06-06-2008, 16:56 6091 in reply to 6090

    Re: Reference a C# project in F#

    A few points:

    - No semicolons!

    - the "module" statement needs an equals sign ("="), or there is an indentation problem. Try this (I hope the indentation comes through correctly...)

    module FS =
        type Fs...
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems