C# Problem, please help

  • Thread starter Thread starter Rudolf Ball
  • Start date Start date
R

Rudolf Ball

Hi NG,

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

Assembly.LoadFrom(...

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

public Globalizator(Object obj)
{
this.obj = obj;
}

public void Translate(string 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.Instance |
BindingFlags.Public);

foreach (PropertyInfo p in pi)
{
try
{
string resName = t.FullName + '.' + p.Name;
Object resObj = rm.GetObject(resName);
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
 
What exception are you getting? Could you please clarify your problem?

Greetz,
-- Rob.
 
Thanx,

i get following exception:

System.Reflection.TargetInvocationException

and

Exception has been thrown by the target of an invocation


Rob Tillie said:
What exception are you getting? Could you please clarify your problem?

Greetz,
-- Rob.

Rudolf said:
Hi NG,

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

Assembly.LoadFrom(...

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

public Globalizator(Object obj)
{
this.obj = obj;
}

public void Translate(string 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.Instance |
BindingFlags.Public);

foreach (PropertyInfo p in pi)
{
try
{
string resName = t.FullName + '.' + p.Name;
Object resObj = rm.GetObject(resName);
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
 
Back
Top