This documentation is archived and is not being maintained.

LogicalMethodInfo Constructor

Initializes a new instance of the LogicalMethodInfo class with the MethodInfo passed in.

Namespace:  System.Web.Services.Protocols
Assembly:  System.Web.Services (in System.Web.Services.dll)

public:
LogicalMethodInfo(
	MethodInfo^ methodInfo
)

Parameters

methodInfo
Type: System.Reflection::MethodInfo

A MethodInfo to initialize the properties of LogicalMethodInfo common to the MethodInfo.

ExceptionCondition
InvalidOperationException

The MethodBase::IsStatic property of the methodInfo parameter is true.

-or-

The MethodBase::GetParameters method of the methodInfo parameter does not contain all the parameters required by the method represented by the instance of LogicalMethodInfo.

#using <System.Web.Services.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::Web::Services::Protocols;

public ref class MyService
{
public:
   int Add( int xValue, int yValue )
   {
      return (xValue + yValue);
   }

};

int main()
{
   Type^ myType = MyService::typeid;
   MethodInfo^ myMethodInfo = myType->GetMethod( "Add" );
   LogicalMethodInfo^ myLogicalMethodInfo = gcnew LogicalMethodInfo( myMethodInfo );
   Console::WriteLine( "\nPrinting properties of method : {0}\n", myLogicalMethodInfo );
   Console::WriteLine( "\nThe declaring type of the method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0}", myLogicalMethodInfo->DeclaringType );
   Console::WriteLine( "\nThe parameters of the method {0} are :\n", myLogicalMethodInfo->Name );
   array<ParameterInfo^>^myParameters = myLogicalMethodInfo->Parameters;
   for ( int i = 0; i < myParameters->Length; i++ )
   {
      Console::WriteLine( "\t {0}", String::Concat( myParameters[ i ]->Name, " : ", myParameters[ i ]->ParameterType ) );
   }
   Console::WriteLine( "\nThe return type of the method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0}", myLogicalMethodInfo->ReturnType );
   MyService^ service = gcnew MyService;
   Console::WriteLine( "\nInvoking the method {0}\n", myLogicalMethodInfo->Name );
   array<Object^>^values = gcnew array<Object^>(2);
   values[ 0 ] = 10;
   values[ 1 ] = 10;
   Console::WriteLine( "\tThe sum of 10 and 10 is : {0}", myLogicalMethodInfo->Invoke( service, values ) );
}
#using <mscorlib.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Web::Services::Protocols;

public __gc class MyService {
public:
   int Add(int xValue, int yValue) {
      return (xValue + yValue);
   }
};

int main() {
   Type*  myType = __typeof(MyService);
   MethodInfo*  myMethodInfo = myType->GetMethod(S"Add");
   LogicalMethodInfo* myLogicalMethodInfo =
      new LogicalMethodInfo(myMethodInfo);

   Console::WriteLine(S"\nPrinting properties of method : {0}\n",
      myLogicalMethodInfo);

   Console::WriteLine(S"\nThe declaring type of the method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0}", myLogicalMethodInfo->DeclaringType);

   Console::WriteLine(S"\nThe parameters of the method {0} are :\n",
      myLogicalMethodInfo->Name);
   ParameterInfo*  myParameters[] = myLogicalMethodInfo->Parameters;

   for (int i = 0; i < myParameters->Length; i++) {
      Console::WriteLine(S"\t {0}",String::Concat(myParameters[i]->Name,
         S" : ", myParameters[i]->ParameterType));
   }

   Console::WriteLine(S"\nThe return type of the method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0}", myLogicalMethodInfo->ReturnType);

   MyService* service = new MyService();
   Console::WriteLine(S"\nInvoking the method {0}\n",
      myLogicalMethodInfo->Name);
   Object * values __gc[] = new Object * [2];
   values[0] = __box(10);
   values[1] = __box(10);

   Console::WriteLine(S"\tThe sum of 10 and 10 is : {0}",
      myLogicalMethodInfo->Invoke(service,values));

}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
Show: