C# Problem, please help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rudolf Ball

    #1

    C# Problem, please help

    Hi NG,

    I have an interesting problem. I have written a simple AddIn-Framework where
    I load Assemblies in with

    Assembly.LoadFr om(...

    Now I want to globalize the Plugins, so I have written a routine like this:

    public Globalizator(Ob ject obj)
    {
    this.obj = obj;
    }

    public void Translate(strin g baseName)
    {
    if (null == obj)
    return ;

    Type t = obj.GetType();
    String str = t.FullName;
    ResourceManager rm = new ResourceManager (baseName, t.Assembly);
    // Instance properites.
    PropertyInfo [] pi = t.GetProperties (BindingFlags.I nstance |
    BindingFlags.Pu blic);

    foreach (PropertyInfo p in pi)
    {
    try
    {
    string resName = t.FullName + '.' + p.Name;
    Object resObj = rm.GetObject(re sName);
    if (resObj != null)
    if (p.CanWrite)
    t.GetProperty(p .Name).SetValue (obj, resObj, null);
    }
    catch (Exception e)
    ....

    So, loading in the Plugin does not work! Has anybody an idea why?

    Thank you

    Rudi


  • Rob Tillie

    #2
    Re: C# Problem, please help

    What exception are you getting? Could you please clarify your problem?

    Greetz,
    -- Rob.

    Rudolf Ball wrote:[color=blue]
    > Hi NG,
    >
    > I have an interesting problem. I have written a simple
    > AddIn-Framework where I load Assemblies in with
    >
    > Assembly.LoadFr om(...
    >
    > Now I want to globalize the Plugins, so I have written a routine like
    > this:
    >
    > public Globalizator(Ob ject obj)
    > {
    > this.obj = obj;
    > }
    >
    > public void Translate(strin g baseName)
    > {
    > if (null == obj)
    > return ;
    >
    > Type t = obj.GetType();
    > String str = t.FullName;
    > ResourceManager rm = new ResourceManager (baseName, t.Assembly);
    > // Instance properites.
    > PropertyInfo [] pi = t.GetProperties (BindingFlags.I nstance |
    > BindingFlags.Pu blic);
    >
    > foreach (PropertyInfo p in pi)
    > {
    > try
    > {
    > string resName = t.FullName + '.' + p.Name;
    > Object resObj = rm.GetObject(re sName);
    > if (resObj != null)
    > if (p.CanWrite)
    > t.GetProperty(p .Name).SetValue (obj, resObj, null);
    > }
    > catch (Exception e)
    > ...
    >
    > So, loading in the Plugin does not work! Has anybody an idea why?
    >
    > Thank you
    >
    > Rudi[/color]


    Comment

    • Rudolf Ball

      #3
      Re: C# Problem, please help

      Thanx,

      i get following exception:

      System.Reflecti on.TargetInvoca tionException

      and

      Exception has been thrown by the target of an invocation


      "Rob Tillie" <Rob.Tillie@stu dent.tul.edu> wrote in message
      news:urG8ytmYDH A.1872@TK2MSFTN GP12.phx.gbl...[color=blue]
      > What exception are you getting? Could you please clarify your problem?
      >
      > Greetz,
      > -- Rob.
      >
      > Rudolf Ball wrote:[color=green]
      > > Hi NG,
      > >
      > > I have an interesting problem. I have written a simple
      > > AddIn-Framework where I load Assemblies in with
      > >
      > > Assembly.LoadFr om(...
      > >
      > > Now I want to globalize the Plugins, so I have written a routine like
      > > this:
      > >
      > > public Globalizator(Ob ject obj)
      > > {
      > > this.obj = obj;
      > > }
      > >
      > > public void Translate(strin g baseName)
      > > {
      > > if (null == obj)
      > > return ;
      > >
      > > Type t = obj.GetType();
      > > String str = t.FullName;
      > > ResourceManager rm = new ResourceManager (baseName, t.Assembly);
      > > // Instance properites.
      > > PropertyInfo [] pi = t.GetProperties (BindingFlags.I nstance |
      > > BindingFlags.Pu blic);
      > >
      > > foreach (PropertyInfo p in pi)
      > > {
      > > try
      > > {
      > > string resName = t.FullName + '.' + p.Name;
      > > Object resObj = rm.GetObject(re sName);
      > > if (resObj != null)
      > > if (p.CanWrite)
      > > t.GetProperty(p .Name).SetValue (obj, resObj, null);
      > > }
      > > catch (Exception e)
      > > ...
      > >
      > > So, loading in the Plugin does not work! Has anybody an idea why?
      > >
      > > Thank you
      > >
      > > Rudi[/color]
      >
      >[/color]


      Comment

      Working...