使用“Out”调用 C# 操作来自托管 C++代码
你好 我有一个 WCF Web 服务器,它有一个我需要从本机 C++ 应用程序调用的操作。我有一个可以工作的桥接管理 DLL,但我在调用具有 OUT 对象的 WCF 操作时遇到了麻烦。
C# 操作:
void DoWork(string indxNum, out ErrorWarningsData objerrc)
这里 ErrorWarningsData 是 C# Web 服务中的一个类。
这就是我的托管 C++ 代码的样子:
gcroot
gcroot
gcroot
gcroot
但是,当我尝试从 WCF 服务调用 DoWork 方法时,出现错误。
这就是我尝试过的:
client->DoWork("4278779",[Out] objEWData );
也尝试过, client->DoWork("4278779",[Out] ^% objEWData );
和, client->DoWork("4278779",[Out] % objEWData );
有人可以告诉我如何使用“OUT”访问对象吗? 我可以找到一些示例来访问 int 和 string 的 [Out],但没有访问对象
PS:我按照以下链接将 WCF 服务连接到本机应用程序 [链接]http://stackoverflow.com/questions/686452/create-wcf-service-for-unmanagement-c-clients
Hi
I have a WCF web serive which has an opeartion i need to call from a native C++ apllication. I have a bridge managed DLL which works, but I am having truoble with calling a WCF operation which has an OUT object.
The C# opearation:
void DoWork(string indxNum, out ErrorWarningsData objerrc)
Here ErrorWarningsData is a class in the C# Web Service.
This is how my Managed C++ code looks like :
gcroot<Binding^> binding1 = gcnew WSHttpBinding();
gcroot<EndpointAddress^> address1 = gcnew EndpointAddress(gcnew String("http://usatondevlas1.na.praxair.com/Build15/ResourceCenterSVC/ResourceCenter.svc"));
gcroot<HelloServiceClient::ServiceReference2::ResourceCenterServiceContractClient^> client = gcnew HelloServiceClient::ServiceReference2::ResourceCenterServiceContractClient(binding1,address1);
gcroot<HelloServiceClient::ServiceReference2::ErrorWarningsData^> objEWData = gcnew HelloServiceClient::ServiceReference2::ErrorWarningsData;
But when I try to call the DoWork Method from the WCF Service I get an error .
This is what I tried :
client->DoWork("4278779",[Out] objEWData );
Also tried,client->DoWork("4278779",[Out] ^% objEWData );
And,client->DoWork("4278779",[Out] % objEWData );
Could some one please tell me how to access the oject with 'OUT'.
I could find some examples to access [Out] for int and string but none for objects
PS: I followed the following to link to connect the WCF service to the native appliaction
[link]http://stackoverflow.com/questions/686452/create-wcf-service-for-unmanaged-c-clients
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定你为什么在这些情况下使用 gcroot 。你可以这样做:
I'm not sure why you are using gcroot in these cases. You can just do:
您不需要任何额外的标记即可在 C++/CLI 中将某些内容作为输出参数传递。语义类似于本机 C++ 中的引用传递。
You shouldn't need any extra markup in order to pass something as an out parameter in C++/CLI. The semantics are similar to passing by reference in native C++.