views:

800

answers:

4

F# declared namespace is not available in the c# project or visible through the object browser.

I have built a normal F# library project, but even after i build the project and reference it to my C# project, I am unable to access the desired namespace.

I am also unable to see it in the object browser, i get an error telling me that it has not been built. I am running on the september release can someone point out my error ?

F# Version 1.9.6.0

(6) Edit : Referencing the dll directly has fixed my problem, referencing the project allows me to compile but the intellisence does not work. When the dll is directly referenced the intellisence works perfectly.


This is the code found in the .fs file

#light

namespace Soilsiu.Core 

module public Process =
    open System.Xml.Linq

    let private xname (tag:string) = XName.Get(tag)
    let private tagUrl (tag:XElement) = let attribute = tag.Attribute(xname "href")
                                        attribute.Value
    let Bookmarks(xmlFile:string) = 
        let xml = XDocument.Load(xmlFile)
        xml.Elements <| xname "A" |> Seq.map(tagUrl)

    let PrintBookmarks (xmlFile:string) =     
        let list = Bookmarks(xmlFile)
        list |> Seq.iter(fun u -> printfn "%s" u)


(5) Edit : Could ReSharper 4.0 be the problem?

(4) Edit : When i say the Object browser is unable to read the resulting assembly, i mean that when I try to open the assembly in the object browser i get an error telling me the project has not yet been built. yet again i can read the assembly using reflector.

(3) Edit : Reflector can Disassemble the dll but the Object Browser is unable to read it.

(2) Edit : I have Upgraded my F# version to 1.9.6.2 and still the same consequence

(1) Edit : I was able to Disassemble the dll to C# I get : (Everything seems to be fine here)

namespace Soilsiu.Core
{
    [CompilationMapping(7)]
    public static class Crawler

    [CompilationMapping(7)]
    public static class Process
}


[CompilationMapping(7)]
public static class Process
{
    // Methods
    static Process();
    public static IEnumerable<string> Bookmarks(string xmlFile);
    public static void PrintBookmarks(string xmlFile);
    internal static string tagUrl(XElement tag);
    internal static XName xname(string tag);

    // Nested Types
    [Serializable]
    internal class clo@13 : FastFunc<XElement, string>
    {
        // Methods
        public clo@13();
        public override string Invoke(XElement tag@9);
    }

    [Serializable]
    internal class clo@17 : FastFunc<string, Unit>
    {
        // Methods
        public clo@17();
        public override Unit Invoke(string u);
    }
}
A: 

I suggest you use Reflector or ildasm to see what's actually in the library that you've built. It has managed to create a DLL for you, right? (If not, that's the first thing to fix!)

Jon Skeet
+2  A: 

What if you reference the produced DLL directly (i.e., not via a project reference, but via a file reference)?

A: 

Maybe IntelliSense is just messed up? What compiler error do you get when you try to use it in C#? When you say "the object browser is unable to read it" what does that mean?

For what it's worth, I added this to a F# library project, referenced it (project) from a C# console app, and was able to use it. IntelliSense did not work at first though. (Had to rebuild.)

If you can make a solid repro, I'd suggest emailing it to F# bugs alias (fsbugs).

MichaelGG
did you rebuild the f# project of the C# project ?
Alexandre Brisebois
Rebuilt all. Did a file reference fix it (was the marked answer)? That'd still be a bug, and you should report it.
MichaelGG
A: 

I tried the same thing. It looks as if Visual Studio and Resharper 4.0 doesn't understand F# for some reason. If you ignore the sea of red text and the lack of intellisense, it will compile fine.

Mike Hadlow