C# Problem, please help

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
 
R

Rob Tillie

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

Greetz,
-- Rob.
 
R

Rudolf Ball

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top