[英]F# declared namespace is not available in the c# project or visible through the object browser
F# declared namespace is not available in the c# project or visible through the object browser. F#声明的命名空间在c#项目中不可用或通过对象浏览器可见。
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. 我已经构建了一个普通的F#库项目,但即使在我构建项目并将其引用到我的C#项目之后,我也无法访问所需的命名空间。
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 ?
我在9月发布的版本上运行有人可以指出我的错误吗?
F# Version 1.9.6.0 F#版本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. (6)编辑:直接引用dll修复了我的问题,引用项目允许我编译,但是intellisence不起作用。 When the dll is directly referenced the intellisence works perfectly.
直接引用dll时,intellisence可以完美地工作。
This is the code found in the .fs file 这是.fs文件中的代码
#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? (5)编辑:ReSharper 4.0可能是问题吗?
(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. (4)编辑:当我说对象浏览器无法读取生成的程序集时,我的意思是当我尝试在对象浏览器中打开程序集时,我得到一个错误,告诉我项目尚未构建。 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. (3)编辑:反射器可以反汇编dll但对象浏览器无法读取它。
(2) Edit : I have Upgraded my F# version to 1.9.6.2 and still the same consequence (2)编辑:我已将我的F#版本升级到1.9.6.2,但结果仍然相同
(1) Edit : I was able to Disassemble the dll to C# I get : (Everything seems to be fine here) (1)编辑:我能够将dll反汇编为C#我得到:(这里似乎一切都很好)
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);
}
}
如果您直接引用生成的DLL(即,不是通过项目引用,而是通过文件引用),该怎么办?
Maybe IntelliSense is just messed up? 也许IntelliSense搞砸了? What compiler error do you get when you try to use it in C#?
当您尝试在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. 为了它的价值,我将其添加到F#库项目中,从C#控制台应用程序引用它(项目),并且能够使用它。 IntelliSense did not work at first though.
虽然IntelliSense最初没有工作。 (Had to rebuild.)
(不得不重建。)
If you can make a solid repro, I'd suggest emailing it to F# bugs alias (fsbugs). 如果您可以制作一个可靠的复制品,我建议通过电子邮件将其发送给F#bugs alias(fsbugs)。
I tried the same thing. 我尝试过同样的事情。 It looks as if Visual Studio and Resharper 4.0 doesn't understand F# for some reason.
看起来好像Visual Studio和Resharper 4.0由于某种原因不理解F#。 If you ignore the sea of red text and the lack of intellisense, it will compile fine.
如果你忽略了红色文字的海洋和缺乏intellisense,它将编译好。
Try 尝试
Make sure that C# project is targeted FULL .NET (NOT Client Profile). 确保C#项目的目标是FULL .NET(非客户端配置文件)。
Add references to assemblies into C# project which are used by F# project. 将对程序集的引用添加到F#项目使用的C#项目中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.