gpt4 book ai didi

wcf - 如何修复 SvcUtil 为 C++/CLI WCF 客户端生成错误的代码?

转载 作者:行者123 更新时间:2023-12-02 00:37:18 25 4
gpt4 key购买 nike

在 C++/CLI 中生成 WCF 客户端时,我遇到了由 SvcUtil 生成的代码的问题。

当我运行“SvcUtil.exe/t:code/l:cpp http://localhost:2772/mex/”时,它会生成一个包含以下客户端类的头文件。

[System::Diagnostics::DebuggerStepThroughAttribute, 
System::CodeDom::Compiler::GeneratedCodeAttribute(L"System.ServiceModel", L"3.0.0.0")]
public ref class DemoClient : public System::ServiceModel::ClientBase<IDemo^ >, public IDemo
{

public: DemoClient();
public: DemoClient(System::String^ endpointConfigurationName);
public: DemoClient(System::String^ endpointConfigurationName, System::String^ remoteAddress);
public: DemoClient(System::String^ endpointConfigurationName, System::ServiceModel::EndpointAddress^ remoteAddress);
public: DemoClient(System::ServiceModel::Channels::Binding^ binding, System::ServiceModel::EndpointAddress^ remoteAddress);
public: virtual System::String^ GetDemoString() sealed;
};

这会导致很多错误,考虑到它是生成的代码,我不会想到这些错误。
Demo.h(41): error C3766: 'DemoClient' must provide an implementation for the interface method 'void System::ServiceModel::ICommunicationObject::Closed::add(System::EventHandler ^)' : see declaration of 'System::ServiceModel::ICommunicationObject::Closed::add'
Demo.h(41): error C3766: 'DemoClient' must provide an implementation for the interface method 'void System::ServiceModel::ICommunicationObject::Closed::remove(System::EventHandler ^)' : see declaration of 'System::ServiceModel::ICommunicationObject::Closed::remove'
Demo.h(41): error C3766: 'DemoClient' must provide an implementation for the interface method 'void System::ServiceModel::ICommunicationObject::Closing::add(System::EventHandler ^)' : see declaration of 'System::ServiceModel::ICommunicationObject::Closing::add'
Demo.h(41): error C3766: 'DemoClient' must provide an implementation for the interface method 'void System::ServiceModel::ICommunicationObject::Closing::remove(System::EventHandler ^)' : see declaration of 'System::ServiceModel::ICommunicationObject::Closing::remove'
Demo.h(41): error C3766: 'DemoClient' must provide an implementation for the interface method 'void System::ServiceModel::ICommunicationObject::Faulted::add(System::EventHandler ^)' : see declaration of 'System::ServiceModel::ICommunicationObject::Faulted::add'
Demo.h(41): error C3766: 'DemoClient' must provide an implementation for the interface method 'void System::ServiceModel::ICommunicationObject::Faulted::remove(System::EventHandler ^)' : see declaration of 'System::ServiceModel::ICommunicationObject::Faulted::remove'
Demo.h(41): error C3766: 'DemoClient' must provide an implementation for the interface method 'void System::ServiceModel::ICommunicationObject::Opened::add(System::EventHandler ^)' : see declaration of 'System::ServiceModel::ICommunicationObject::Opened::add'
Demo.h(41): error C3766: 'DemoClient' must provide an implementation for the interface method 'void System::ServiceModel::ICommunicationObject::Opened::remove(System::EventHandler ^)' : see declaration of 'System::ServiceModel::ICommunicationObject::Opened::remove'
Demo.h(41): error C3766: 'DemoClient' must provide an implementation for the interface method 'void System::ServiceModel::ICommunicationObject::Opening::add(System::EventHandler ^)' : see declaration of 'System::ServiceModel::ICommunicationObject::Opening::add'
Demo.h(41): error C3766: 'DemoClient' must provide an implementation for the interface method 'void System::ServiceModel::ICommunicationObject::Opening::remove(System::EventHandler ^)' : see declaration of 'System::ServiceModel::ICommunicationObject::Opening::remove'

关于我需要更改或添加以纠正此问题的任何建议?我应该只为列出的接口(interface)方法添加一个实现吗?

最佳答案

由于链接已损坏,您可以使用 Wayback Machine查看页面

帖子的相关部分是

You should use the following workaround to get a successful compile: Locate the full runtime assembly in: %SysRoot%\Microsoft.NET\Framework\v4.0.30319\System.ServiceModel.dll

Copy this dll.

Replace the Reference Assembly in: %ProgramFiles(x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.ServiceModel.dll

Recompiling your project should now succeed.

关于wcf - 如何修复 SvcUtil 为 C++/CLI WCF 客户端生成错误的代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4102764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com