C ++无法看到c#public static functions [英] C++ unable to see c# public static functions

查看:62
本文介绍了C ++无法看到c#public static functions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C ++项目(CLR)中调用公共静态函数时遇到问题。 C#项目没问题,它可以访问所有静态函数。

I'm having problems to call public static functions in my C++ project (CLR). The C# project is ok, it can access all static functions.

示例代码:

C#

命名空间WK.Mfa

namespace WK.Mfa

{

公共类客户

{

public Client();

public Client();

public IAuthenticate Authenticate {get; }

public IAuthenticate Authenticate{ get; }

}

}

命名空间WK.Mfa

namespace WK.Mfa

{

public interface IAuthenticate

public interface IAuthenticate

{

int TestA();

int TestA();

int TestB();

int TestB();

}

}

namespace WK.Mfa

namespace WK.Mfa

{

公共静态类AuthenticateExt

public static class AuthenticateExt

{

public static int SendAA();

public static int SendAA();

}

}

在C#代码中,我能够这样做:

In C# code, I was able to do this:

客户端cl =新客户端();

Client cl = new Client();

cl.Authenticate.SendAA() ;

cl.Authenticate.SendAA();

但是,在C ++代码中,我无法做到

But, in C++ code, I can't do

Client ^ cl = gcnew客户端();

Client ^cl=gcnew Client();

cl->验证 - > SendAA();

cl->Authenticate->SendAA();

所有我能看到的是TestA()和TestB()仅限函数,而不是公共静态功能。

all I can see is TestA() and TestB() functions only, not the public static funtions.

有人有任何想法吗?

谢谢,

Steve

推荐答案

你试过吗? :

Did you try:

cl->Authenticate.SendAA();

请注意,当您输入" - >"时,Intellisense不会向您显示SendAA如果你应该使用"。"。参见"cl"。是一个引用,Authenticate是一个成员实例。 C ++ / CLR中的引用使用与指针相同的语法。在
C#中,我们使用"。"对于成员和引用,但在C ++指针和引用中使用" =>"但成员使用"。"。$

Note that Intellisense won't show you SendAA when you type "->" if you should be using ".". See "cl" is a reference and Authenticate is a member instance. References in C++/CLR use the same syntax as pointers. In C# we use "." for both members and references but in C++ pointers and references use "=>" but members use ".".


这篇关于C ++无法看到c#public static functions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆