托管 C++编译期间 C#.Net 中的命名空间不可访问
我的 Visual Studio 2010 解决方案中有 4 个项目。其中一个项目是托管C++ dll。我已将此托管 C++ 项目的项目引用添加到其余三个 C#.Net 项目中。当我尝试编译此代码时,我在使用 C# 代码中的命名空间语句时收到错误。
托管 C++ 代码
namespace A <---- Defined in managed C++ as well as C#
{
namespace B <---- Only defined in managed C++
{
public ref class MyClass
{
}
}
}
现在,我想在我的 C# 中使用 MyClass,所以 C#。 Net代码
using A.B; <-------- Here it gave error for B;
外部命名空间即A在C#以及托管C++项目中定义/使用。但内部命名空间(即 B)仅在托管 C++ 中定义。我无法访问 C# 应用程序中的内部命名空间。
有什么解决办法吗?
谢谢, 奥姆基
I have 4 projects in my Visual Studio 2010 solution. One of the project is managed C++ dll. I have added the project reference of this managed C++ project into remaining three C#.Net projects. When I tried to compile this I got the error at Using namespace statement in C# code.
Managed C++ Code
namespace A <---- Defined in managed C++ as well as C#
{
namespace B <---- Only defined in managed C++
{
public ref class MyClass
{
}
}
}
Now, I want to use MyClass in my C# so
C#. Net code
using A.B; <-------- Here it gave error for B;
The outer namespace i.e. A is defined/used in C# as well as managed C++ project. But the inner namespace i.e. B is defined solely in managed C++. I am not able to access inner namespace in C# application.
Any solution?
Thanks,
Omky
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
全局“::”运算符 帮忙?
Would the global "::" operator help?
在不引用确切错误消息的情况下提出有关错误的问题总是一个大错误。但你通常会看到其中有这样一句话:
Always a Big Mistake to ask a question about an error without quoting the exact error message. But the one you'd typically see has this phrase in it:
是的....我找到了。我了解到我需要确定构建配置和输出路径。意味着如果我想构建版本,则参考所有依赖二进制文件的发布配置,调试也相同。
抱歉...我明白我的错误。感谢大家的帮助。
Yes....I found it. I learnt that I need to be sure about the build configuration and output path.Means If I want to build release then have reference to release configuration for all dependent binaries and same for debug too.
Sorry.... I understood my mistake. Thanks to all for your help.