简体   繁体   English

无法在VB.NET类库中引用C#类库

[英]Can't reference a C# class library within a VB.NET class library

I have 2 projects in a solution, one a vb.net class library project, another a C# class library project. 我在解决方案中有2个项目,一个是vb.net类库项目,另一个是C#类库项目。

As far as I was aware I was able to compile both and reference each from the other project, (one way at a time). 据我所知,我能够编译两个并从另一个项目中引用每个项目(一次一个)。

I can reference namespaces / classes found in the VB.NET project within the C# project. 我可以引用C#项目中VB.NET项目中的命名空间/类。 However I don't seem to be able to do the same in the opposite direction. 但是我似乎无法在相反的方向上做同样的事情。 I can't seem to use any namespaces / classes exposed in the C# library from within the VB.NET project, even though the library appears to be referenced correctly. 我似乎无法在VB.NET项目中使用C#库中公开的任何名称空间/类,即使该库似乎被正确引用。

Am I missing something here? 我在这里错过了什么吗?

EDIT: I am aware that cyclic references are not permitted and no I am not referencing each library from the other at the same time. 编辑:我知道不允许循环引用,我不会同时引用另一个库。 I don't have any compilation errors relating to cyclic referencing. 我没有任何与循环引用有关的编译错误。

This is because you cannot create circular references. 这是因为您无法创建循环引用。

If the ddl of your first project is referenced in the second one there is no way you can add the other project as a reference also. 如果在第二个项目中引用了第一个项目的ddl,则无法将其他项目添加为引用。

When building the solution both projects would depend on each other and this will fail. 在构建解决方案时,两个项目都将相互依赖,这将失败。

This was an error on my part. 这是我的错误。

The problematic C# types in question that I could not see within my vb project had been set to content rather than compile within Visual Studio. 我在vb项目中看不到的有问题的C#类型已被设置为内容而不是在Visual Studio中编译。 This possibly occurred due to some file movement between the projects. 这可能是由于项目之间的一些文件移动而发生的。

For me the reference error was due to difference in framework version. 对我来说,参考错误是由于框架版本的差异。 After I changed the version from project properties, the reference error got resolved. 从项目属性更改版本后,引用错误得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM