当前位置: 代码迷 >> VC >> error C2059: syntax error : 'public'该怎么解决
  详细解决方案

error C2059: syntax error : 'public'该怎么解决

热度:9166   发布时间:2013-02-25 00:00:00.0
error C2059: syntax error : 'public'
我使用VS2010 Pro。

我添加web引用到VC项目,使用/CLR建立时,报错:

error C2059: syntax error : 'public' d:\visual studio 2008

\projects\myproject\myproject\Service1.h 29 MyProject

错误指向代码:

    [System::CodeDom::Compiler::GeneratedCodeAttribute(L"wsdl", 

L"2.0.50727.1432")]
public delegate System::Void HelloWorldCompletedEventHandler

(System::Object^  sender, Service1::HelloWorldCompletedEventArgs^  e);

Service1.h是我添加web引用后自动生成的。

------解决方案--------------------------------------------------------
public delegate System::Void HelloWorldCompletedEventHandler
是否应该为
public delegate Void System::HelloWorldCompletedEventHandler

------解决方案--------------------------------------------------------
c++哪来的public void somemethod(){}  定义

c++ 应该 
ref class{
public: 
  void method(){}
}
------解决方案--------------------------------------------------------
我这里没有2010 
2005生成的是
 public ref class Service : public System::Web::Services::Protocols::SoapHttpClientProtocol {
        
        private: System::Threading::SendOrPostCallback^  HelloWorldOperationCompleted;
        
        /// <remarks/>
        public: event localhost::HelloWorldCompletedEventHandler^  HelloWorldCompleted;
        
        /// <remarks/>
        public: Service();
        /// <remarks/>
        public: [System::Web::Services::Protocols::SoapDocumentMethodAttribute(L"http://tempuri.org/HelloWorld", RequestNamespace=L"http://tempuri.org/", 
            ResponseNamespace=L"http://tempuri.org/", Use=System::Web::Services::Description::SoapBindingUse::Literal, ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)]
        System::String^  HelloWorld();
        
        /// <remarks/>
        public: System::IAsyncResult^  BeginHelloWorld(System::AsyncCallback^  callback, System::Object^  asyncState);
        
        /// <remarks/>
        public: System::String^  EndHelloWorld(System::IAsyncResult^  asyncResult);
        
        /// <remarks/>
  相关解决方案