By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,022 Members | 1,401 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,022 IT Pros & Developers. It's quick & easy.

Object is currently in use elsewhere

P: n/a
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.Create Instance(Ty);

}
}
Aug 13 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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?

"Boni" wrote:
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.Create Instance(Ty);

}
}

Aug 13 '08 #2

P: n/a

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

"Simon Tamman" wrote:
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?

"Boni" wrote:
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.Create Instance(Ty);

}
}
Aug 13 '08 #3

P: n/a
Try looking at this:

http://msmvps.com/blogs/peterritchie...uot-error.aspx

Sounds like a GDI bug somewhere between your plugins.

"Boni" wrote:
>
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

"Simon Tamman" wrote:
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?

"Boni" wrote:
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.Create Instance(Ty);
>
}
}
>
>
Aug 13 '08 #4

P: n/a
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

"Boni" wrote:
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.Create Instance(Ty);

}
}

Aug 14 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.