Getting MDA error when loading already used objects

Jun 26, 2009 at 2:45 PM

I am working on a project where I load up UI controls into and MMC property window.  Everything loads up good the first time I select a property on one of the objects.  When I go to select the property of another object, the application goes to compose the objects for the UI again and I get the following error:

Context 0xad9f0' is disconnected.  Releasing the interfaces from the current context (context 0xad938).This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the applicationis completely done with the RuntimeCallableWrappers that represent COM components that liveinside them.

I'm not sure what it could be doing or what I could be doing wrong.  I tried disposing of the container, catalog, and batch but when the control loads up for the second time all of these objects are already set to Nothing.  Any light that you guys could shed on this would be a great deal of help.  Thank you.

Jun 26, 2009 at 5:51 PM

Hi,

Unfortunately this sounds like a problem with some COM plumbing and not with MEF. Not too much we can suggest I’m afraid. Have you tried composing your parts by hand (i.e. with ‘new’, property setters etc.) to see if the behaviour changes?

Cheers,

Nick

From: dterry458 [mailto:notifications@codeplex.com]
Sent: Friday, June 26, 2009 6:46 AM
To: Nicholas Blumhardt
Subject: Getting MDA error when loading already used objects [MEF:60768]

From: dterry458

I am working on a project where I load up UI controls into and MMC property window. Everything loads up good the first time I select a property on one of the objects. When I go to select the property of another object, the application goes to compose the objects for the UI again and I get the following error:

Context 0xad9f0' is disconnected. Releasing the interfaces from the current context (context 0xad938).This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the applicationis completely done with the RuntimeCallableWrappers that represent COM components that liveinside them.

I'm not sure what it could be doing or what I could be doing wrong. I tried disposing of the container, catalog, and batch but when the control loads up for the second time all of these objects are already set to Nothing. Any light that you guys could shed on this would be a great deal of help. Thank you.

Read the full discussion online.

To add a post to this discussion, reply to this email (MEF@discussions.codeplex.com)

To start a new discussion for this project, email MEF@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Jun 26, 2009 at 6:54 PM

I knew it wasn't really an MEF issue but I figured I could get some help in figuring out where to destroy the objects so they aren't alive anymore without causing some other kind of issue.  Here is the code I am currently using the compose the object.

  <Import()> Public propertySheets As ExportCollection(Of PropertySheetControl)
    Dim oadhelper As ActiveDirectoryHelper                  'Active directory helper in c#
    Dim assemblyCatalog As AssemblyCatalog
    Dim directoryCatalog As DirectoryCatalog
    Dim container As CompositionContainer
    Dim batch As CompositionBatch

 I have the code above defined at the top of my class.

Try
            assemblyCatalog = New AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly())
            container = New CompositionContainer(New DirectoryCatalog("C:\plugins"))
            batch = New CompositionBatch()
            batch.AddPart(Me)
            batch.AddPart(assemblyCatalog)
            container.Compose(batch)
        Catch ex As CompositionException
            MsgBox(ex.Errors.ToString, MsgBoxStyle.Critical, "Error")
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error")
        End Try

I have the above code being called after Initialize().  The MEF objects are controls of inherited type UserControl.

<Export(GetType(PropertySheetControl))> _
<ExportMetadata("User", "")> _
Public Class ExchangeUserPropertySheet
    Inherits PropertySheetControl

The above code is at the top of the class for the controls that I am using MEF to self discover and load.  Hopefully this may help a little bit in working towards a solution.  Again, thanks for your help.  If you have any questions I am watching this forum pretty heavily so I'll be back to answer for sure.