简体   繁体   English

.NET编程-我可以从我的VB.NET项目访问C-Sharp项目的成员吗?

[英].NET Programming - Can I access members of a C-Sharp project from my VB.NET Project?

I have a multi-project .NET 3.5 solution. 我有一个多项目的.NET 3.5解决方案。

It's ASP.NET based with c# code-behind in all projects except one. 它是基于ASP.NET的,除了一个项目外,所有项目均带有c#代码。

I'm attempting to access members from a C# project called "Core" from a VB.NET project. 我正在尝试从VB.NET项目中名为“ Core”的C#项目中访问成员。

I set a dependency to the Core solution in my solution properties. 我在解决方案属性中设置了对Core解决方案的依赖关系。

However, Core. 但是,核心。 brings up nothing. 什么都不会带来。

Furthermore, my other C# projects that have Core-Project as a dependency (in the solution settings), are able to declare Core objects. 此外,我的其他以Core-Project作为依赖项的C#项目(在解决方案设置中)都可以声明Core对象。 Example: Private Core.ObjectName InstanceName; 示例:私有Core.ObjectName InstanceName; Also, Intellisense brings up plenty of info in the C# projects. 另外,Intellisense会在C#项目中带来大量信息。

Any idea on how I can hook into these members from my VB project? 关于如何从VB项目中加入这些成员的想法吗?

Thanks! 谢谢!

Add the C# project as a reference, not a dependency. 将C#项目添加为参考,而不是依赖关系。 This is done through the solution explorer by right-clicking on References underneath the VB project. 这是通过解决方案资源管理器通过右键单击VB项目下方的“引用”来完成的。 You'll see a window pop up; 您会看到一个弹出窗口; select the Projects tab and find your C# project there. 选择“项目”选项卡,然后在此处找到您的C#项目。

Dependencies, by contrast, only influence the build order. 相反,依赖关系仅影响构建顺序。 You can set a project to depend on another (ie ensuring the other is built first), but that doesn't allow the first project to use the other project's code. 您可以将一个项目设置为依赖于另一个项目(即确保首先构建另一个项目),但这不允许第一个项目使用另一个项目的代码。

Finally, setting a reference also automatically sets a dependency, so you don't need to do both. 最后,设置引用还会自动设置一个依赖项,因此您无需同时执行这两项操作。

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

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