Object is currently in use elsewhere

B

Boni

Hi,
I got this problem. I'm implementing a pluggable winform program. My plugins
are usercontrol and I load them in my program through a interface.
Now if I close my application an error occurs: "Object is currently in use
elsewhere". If I comment the line where a I use the Activator.CreateInstance
it doesn't happen.
I tried to disposed the object created but nothing but If I do a simple
new of my object without using reflection it doesn't give me an error.

can someone help me?
thank's

Here my code,
System.Reflection.Assembly asm =
System.Reflection.Assembly.LoadFrom(fileName);
foreach (Type Ty in asm.GetTypes())
{
if (Ty.GetInterface("IPreviewControls") != null)
{
Plugins.Preview.IPreviewControls plugin =
(Plugins.Preview.IPreviewControls)Activator.CreateInstance(Ty);

}
}
 
S

Simon Tamman

Sounds to me like a custom exception, someone is throwing from the
constructor of one of the plugins.
Perhaps they are trying to make their plugin act like a singleton?
 
B

Boni

Hi Simon,
they work good until I close my application. It seems like something with
the activator function remains appended. I can explain that because if I make
a new for each one instead using the activator I don't have errors. But I
need to load them as plugins, scanning the assembly.

regards
 
B

Boni

I updated my framework 3.5 with the SP1 and now it works!
I guess it was really a bug too.

thank you for your help
 

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