Xander
Xander

Reputation: 9171

How to troubleshoot a double loaded object in mef

I have an issue where my object is loaded twice in MEF. So MEF returns two of my object, which causes my entire program to crash because I am expecting only one.

How can I trace through/step through my program to figure out where the objects are being double registered?

I have an Export tag on the class. I assume this accounts for one of the instances.

I am using prism and the object that appears twice is the Shell view.

TDL having trouble figuring out how to debug mef

Upvotes: 1

Views: 247

Answers (2)

myermian
myermian

Reputation: 32525

I'd venture to say you loaded the Assembly twice into the AggregateCatalog somehow.

Upvotes: 0

Reed Copsey
Reed Copsey

Reputation: 564891

When you compose the object, MEF will raise a CompositionException when it tries to compose the [Import] matching the type. The exception details of the CompositionException are very detailed, and will give you the potential matches.

Look at the full text of the CompositionException - it should provide you with all of the "matches" that are occurring for a given import, allowing you to debug the issue.

Upvotes: 1

Related Questions