upupupupupup!!!!!!!
急急急急急急急急急!!!
没人知道吗?
谢谢谢谢

解决方案 »

  1.   

    你可以试试非托管的属性编程[DLLIMPORT]。
    查查相关MSDN,希望有效。
    我很久没用过C#了,没这个环境,帮不了多少
      

  2.   

    自定义工具箱,添加COM组件试试
      

  3.   

    》objType.InvokeMember ("NameString",BindingFlags.GetProperty , null, ComObject, new object [] {});// 返回com中的属性值WDNameString这样:
    objType.InvokeMember ("NameString",BindingFlags.GetProperty|BindingFlags.Instance, null, ComObject, new object [] {});// 返回com中的属性值WDNameString
      

  4.   

    以下是msdn中的sample:
    using System;
    using System.IO;
    using System.Reflection;public class Sample
    {
     public void Method()
     {//Call a static method
     Type t = typeof (TestClass);
     t.InvokeMember ("SayHello", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, new object [] {});
             
     //Call an instance method
     TestClass c = new TestClass ();
     c.GetType().InvokeMember ("AddUp", BindingFlags.Public | BindingFlags.InvokeMethod, null, c, new object [] {});
     c.GetType().InvokeMember ("AddUp", BindingFlags.Public | BindingFlags.InvokeMethod, null, c, new object [] {});
             
     //Call a method with arguments
     object [] args = new object [] {100.09, 184.45};
     object result;
     result = t.InvokeMember ("ComputeSum", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, args);
     Console.WriteLine ("{0} + {1} = {2}", args[0], args[1], result);
             
     //Get a field value
     result = t.InvokeMember ("Name", BindingFlags.Public | BindingFlags.GetField, null, c, new object [] {});
     Console.WriteLine ("Name == {0}", result);
             
     //Set a field
     t.InvokeMember ("Name", BindingFlags.Public |BindingFlags.SetField, null, c, new object [] {"NewName"});
     result = t.InvokeMember ("Name", BindingFlags.Public |BindingFlags.GetField, null, c, new object [] {});
     Console.WriteLine ("Name == {0}", result);
             
     //Get an indexed property value
     int  index = 3;
     result = t.InvokeMember ("Item", BindingFlags.Public |BindingFlags.GetProperty , null, c, new object [] {index});
     Console.WriteLine ("Item[{0}] == {1}", index, result);
             
     //Set an indexed property value
     index = 3;
     t.InvokeMember ("Item", BindingFlags.Public |BindingFlags.SetProperty, null, c, new object [] {index, "NewValue"});
     result = t.InvokeMember ("Item", BindingFlags.Public |BindingFlags.GetProperty , null, c, new object [] {index});
     Console.WriteLine ("Item[{0}] == {1}", index, result);
             
     //Get a field or property
     result = t.InvokeMember ("Name", BindingFlags.Public |BindingFlags.GetField | BindingFlags.GetProperty, null, c, new object [] {});
     Console.WriteLine ("Name == {0}", result);
     result = t.InvokeMember ("Value", BindingFlags.Public |BindingFlags.GetField | BindingFlags.GetProperty, null, c, new object [] {});
     Console.WriteLine ("Value == {0}", result);
             
     //Call a method using named arguments
     object[] argValues = new object [] {"Mouse", "Micky"};
     String [] argNames = new String [] {"lastName", "firstName"};
     t.InvokeMember ("PrintName", BindingFlags.Public |BindingFlags.InvokeMethod, null, null, argValues, null, null, argNames);
             
     //Call the default member of a type
     Type t3 = typeof (TestClass2);
     t3.InvokeMember ("", BindingFlags.Public |BindingFlags.InvokeMethod, null, new TestClass2(), new object [] {});
             
     //Invoking a ByRef member
     MethodInfo m = t.GetMethod("Swap");
     args = new object[2];
     args[0] = 1;
     args[1] = 2;
     m.Invoke(new TestClass(),args);
     Console.WriteLine ("{0}, {1}", args[0], args[1]);
     Console.WriteLine ("\r\nPress Return to exit.");
     Console.Read(); }
    }// Class added so sample will compile
    public class TestClass {}// Class added so sample will compile
    public class TestClass2 {}
    [JScript] 
    //Call a static method
     var t : Type = TestClass;
     t.InvokeMember ("SayHello", BindingFlags.Default | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, new Object [0]);
             
     //Call an instance method
     var c : TestClass = new TestClass ();
     c.GetType().InvokeMember ("AddUp", BindingFlags.Default | BindingFlags.InvokeMethod, null, c, new Object [0]);
     c.GetType().InvokeMember ("AddUp", BindingFlags.Default | BindingFlags.InvokeMethod, null, c, new Object [0]);
             
     //Call a method with arguments
     var args : Object[] = [100.09, 184.45];
     var result;
     result = t.InvokeMember ("ComputeSum", BindingFlags.Default | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, args);
     Console.WriteLine ("{0} + {1} = {2}", args[0], args[1], result);
             
     //Get a field value
     result = t.InvokeMember ("Name", BindingFlags.Default | BindingFlags.GetField, null, c, new Object [0]);
     Console.WriteLine ("Name == {0}", result);
             
     //Set a field
     t.InvokeMember ("Name", BindingFlags.Default |BindingFlags.SetField, null, c, ["NewName"]);
     result = t.InvokeMember ("Name", BindingFlags.Default |BindingFlags.GetField, null, c, new Object [0]);
     Console.WriteLine ("Name == {0}", result);
             
     //Get an indexed property value
     var index : int = 3;
     result = t.InvokeMember ("Item", BindingFlags.Default |BindingFlags.GetProperty , null, c, [index]);
     Console.WriteLine ("Item[{0}] == {1}", index, result);
             
     //Set an indexed property value
     index = 3;
     t.InvokeMember ("Item", BindingFlags.Default |BindingFlags.SetProperty, null, c, [index, "NewValue"]);
     result = t.InvokeMember ("Item", BindingFlags.Default |BindingFlags.GetProperty , null, c, [index]);
     Console.WriteLine ("Item[{0}] == {1}", index, result);
             
     //Get a field or property
     result = t.InvokeMember ("Name", BindingFlags.Default |BindingFlags.GetField | BindingFlags.GetProperty, null, c, new Object [0]);
     Console.WriteLine ("Name == {0}", result);
     result = t.InvokeMember ("Value", BindingFlags.Default |BindingFlags.GetField | BindingFlags.GetProperty, null, c, new Object [0]);
     Console.WriteLine ("Value == {0}", result);
             
     //Call a method using named arguments
     var argValues : Object[] = ["Mouse", "Micky"];
     var argNames : String [] = ["lastName", "firstName"];
     t.InvokeMember ("PrintName", BindingFlags.Default |BindingFlags.InvokeMethod, null, null, argValues, null, null, argNames);
             
     //Call the default member of a type
     TestClass2.InvokeMember ("", BindingFlags.Default |BindingFlags.InvokeMethod, null, new TestClass2(), new Object [0]);
             
     //Invoking a ByRef member
     var m : MethodInfo = t.GetMethod("Swap");
     args = new Object[2];
     args[0] = 1;
     args[1] = 2;
     m.Invoke(new TestClass(),args);
     Console.WriteLine ("{0}, {1}", args[0], args[1]);
     Console.WriteLine ("\r\nPress Return to exit.");
     Console.Read();
      

  5.   

    MSDN上的这个烂例子,很多的错误,后面的两个类也没有实现,误人。看看语法还可以。
      

  6.   

    谢谢大家!msdn的例子确实太烂了,错误多。马上结帖。