How to return system type .__ COMObject to System.Type in C #

I am making a program and I want to do Reflection, but for this I need an object of type Type, right? to use the .GetProperties () method ... So I tried the following:

Type typeName = simObjects.getType();

But .GetType () returns "System .__ COMObject". And it is not useful. The same thing happens with .typeof (). I search and find another code:

Type typeName = (Type)Microsoft.VisualBasic.Information.TypeName(simObjects);

But this method returns a string, and I need it in System.Type, can any of the ingenious help me?

+4
source share
2 answers

Well, I know his lateness, I solve my problem a while ago, I will answer, I hope this can help someone.

reflextion, , .

foreach(PropertyDescriptor descrip in TypeDescriptor.GetProperties(COMObject))
{
    if(descrip.Name == "Attribute Name")
    {
        foreach(PropertyDescriptor descrip2 in TypeDescriptor.GetProperties(descrip))
        {
           if(descrip2.Name == "sub attribute Name")
           {
           }
        } 
    }
}

, , , COMObject :

int age;
string name;
Son Phill;

:

int age;
string name;

descrip.Name "age", "name" "Phill", (, condiiton true "Son" ), "age" "name",.

, -.

+2

. , :

http://support.microsoft.com/kb/320523

. SO COM :

fooobar.com/questions/402897/...

, , ? , ( COM) Dynamics .

dynamic d = simObjects;
string myVariable = d.SomeProperty;

EDIT: COM

http://msdn.microsoft.com/en-us/magazine/ff714583.aspx

:

public static class WordDocument
{
    public const String TemplateName = @"Sample.dotx";
    public const String CurrentDateBookmark = "CurrentDate";
    public const String SignatureBookmark = "Signature";

    public static void Create(string file, DateTime now, String author)
    {
         // Run Word and make it visible for demo purposes
         dynamic wordApp = new Application { Visible = true };

        // Create a new document
        var doc = wordApp.Documents.Add(TemplateName);
        templatedDocument.Activate();

        // Fill the bookmarks in the document
        doc.Bookmarks[CurrentDateBookmark].Range.Select();
        wordApp.Selection.TypeText(current.ToString());
        doc.Bookmarks[SignatureBookmark].Range.Select();
        wordApp.Selection.TypeText(author);
0

All Articles