Type.GetType() -- which is what the COM code eventually ends up
calling -- requires an assembly-qualified type name if the type is not
in the system assembly.  Try passing "MyAssembly,ClassLibrary2.Class1"
as the type name.

Hope this helps,

--
Ivan Towlson
White Carbon


-----Original Message-----
From: Unmoderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] Behalf Of Tom Hyland
Sent: 14 July 2004 13:04
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Invoke .NET static methods in COM



When using the invoke code on a system type such as "System.AppDomain"
and
its static member function "GetCurrentThreadId" everything works fine.
If I
try and invoke "Test" on "ClassLibrary2.Class1" then I fail to generate
the
Type object for ClassLibrary2.Class1 (see line marked with a *** in [2])

   // Invoke the static Type.GetType method using reflection on the

   // type for System.Type in order to get the desired type

   nullObject.vt = VT_EMPTY;

   hresult = pTypeOfType->InvokeMember_3(getTypeName,

    (mscorlib::BindingFlags)(mscorlib::BindingFlags_InvokeMethod |
mscorlib::BindingFlags_Public |

    mscorlib::BindingFlags_Static |
mscorlib::BindingFlags_FlattenHierarchy), NULL,

    nullObject, psa, &getTypeRetVal);

    // *** the above line returns S_OK, but getTypeRetval is VT_EMPTY
instead of VT_DISPATCH.

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to