This documentation is archived and is not being maintained.
LogicalMethodInfo::Invoke Method
Visual Studio 2010
Invokes the method represented by the current LogicalMethodInfo.
Assembly: System.Web.Services (in System.Web.Services.dll)
[PermissionSetAttribute(SecurityAction::LinkDemand, Name = L"FullTrust")] public: array<Object^>^ Invoke( Object^ target, array<Object^>^ values )
Parameters
- target
- Type: System::Object
The instance of the Object to invoke the method.
- values
- Type: array<System::Object>
An argument list for the invoked method. This is an array of objects with the same number, order, and type as the parameters of the method. If the method does not require any parameters, the values parameter should be nullptr.
Return Value
Type: array<System::Object>An array of type Object representing the return value and out parameters of the invoked method.
| Exception | Condition |
|---|---|
| TargetException | The target parameter is nullptr. |
| ArgumentException | The number, type, and order of parameters in the values parameter do not match the signature of the invoked method. |
| MemberAccessException | The caller does not have permission to invoke the method. |
| TargetInvocationException | The invoked method throws an exception. |
#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 ) ); }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: