2

I have Set Form, inside this form I inject some another set form

  public partial class ServicePriceBlockSetForm : RibbonForm
   {

    [Inject]
    private OtherServiceSetForm OtherServiceSetForm { get; set; }

    public ServicePriceBlockSetForm()
    {
        InitializeComponent();
    }
   ...
   }

When I call this form by button click, first time form opened and everything is OK. When I close and try open this form again I get:

An unhandled exception of type 'System.ObjectDisposedException' occurred in
System.Windows.Forms.dll

Additional information: Cannot access a disposed object.

Form registred in Ninject container like this.

_kernel.Bind<ServicePriceBlockSetForm>().ToSelf();
_kernel.Bind<OtherServiceSetForm>().ToSelf();

What can I do with this error?

  • You first will need to find out which object is disposed. To do that you'll have to use the exception stacktrace and navigate in the code. – BatteryBackupUnit Aug 08 '14 at 05:32
  • see http://stackoverflow.com/questions/6886198/program-crash-with-system-objectdisposedexception – BatteryBackupUnit Aug 08 '14 at 05:34
  • Disposed object are this injected form OtherServiceSetForm. When I close this form, then this form dispose. – Andrey Klochaniy Aug 08 '14 at 07:03
  • With the code you've posted, i can tan tell with a 100% guarantee, that Ninject is not disposing the form. But i believe what you've posted here may digress from what you've actually have. So you'll have to look for the issue somewhere else or post a http://stackoverflow.com/help/mcve – BatteryBackupUnit Aug 08 '14 at 09:07

0 Answers0