Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7868975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:09:57+00:00 2026-06-03T01:09:57+00:00

I use the following code lines to initialize MEF container _mefContainer = new CompositionContainer(

  • 0

I use the following code lines to initialize MEF container

       _mefContainer = new CompositionContainer(
                     new AggregateCatalog(
                     AssemblySource.Instance
                    .Select(x => new AssemblyCatalog(x))
                    .Where(AssemblyFilter)
                    .OfType<System.ComponentModel.Composition.Primitives.ComposablePartCatalog()));

        var batch = new CompositionBatch();
        batch.AddExportedValue<IWindowManager>(new WindowManager());
        batch.AddExportedValue<IEventAggregator>(new EventAggregator());
        batch.AddExportedValue(_mefContainer);

        OnConfigure(batch);

        _mefContainer.Compose(batch);

All the Parts belongs to one Assembly – no dependecies!

When I run the app in Debug mode everything goes wall,

But, when I switch to Release mode, I get CompositionException in that lines of code

string contract = string.IsNullOrEmpty(key) ?  AttributedModelServices.GetContractName(serviceType) : key;
var exports = _mefContainer.GetExportedValues<object>(contract);

I realized when I try to do a double call for this lines, for the first time I Call the method (from Watch window) I get CompositionException but second time it works out…

EDIT:

Here is how the AssemblySource.Instance looks like:

AssemblySource.Instance
Count = 24
[0]: {PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35}
[1]: {System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}
[2]: {MOCH.Infrastrcture.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}
[3]: {Caliburn.Micro.Contrib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}
[4]: {Caliburn.Micro, Version=1.3.1.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f}
[5]: {System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}
[6]: {MOCH.Bama.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}
[7]: {mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}
[8]: {PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35}
[9]: {System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}
[10]: {MOCH.Bama.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}
[11]: {WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35}
[12]: {MOCH.Infrastrcture.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}
[13]: {WPFToolkit.Extended, Version=1.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4}
[14]: {GIS.Bama, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}
[15]: {MOCH.Infrastrcture.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}
[16]: {System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}
[17]: {MOCH.Bama.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}
[18]: {System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}
[19]: {System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089}
[20]: {MOCH.Bama.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}
[21]: {System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35}
[22]: {Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a}
[23]: {MOCH.Bama.UI.Shell, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null}

Would love to have your assistance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:09:58+00:00Added an answer on June 3, 2026 at 1:09 am

    So, I found the problem. it is totaly wierd..

    The app is using NLog as logging framework.

    I have sepearate nlog configs for each environment (using XML Transformation from http://sedodream.com/)

    In the app.config.realese I set nlog attribute throwExceptions=false and that the cause of the bug!

    I have said totaly wierd..?

    Thanks

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following code: Calendar calendar = new GregorianCalendar(0,0,0); calendar.set(Calendar.YEAR, 1942); calendar.set(Calendar.MONTH, 3);
I use select queries as by following code: $params = array( 'username' => 'root',
I use following code: Create a retry policy, when error, retry after 1 second,
I use VS2010, C# to develop Silverlight 4 app, I use following code in
I have an array of objects, and i use following code to get in
I use the following code try to create an array of string vectors, I
I use the following code to layout network drives on a system. I want
I use the following code to allocate a Console for a WinForm application. The
I use the following code: - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSHTTPURLResponse *)response {
I Use the following code to load png image: UIImage *imageBack1 = [UIImage imageNamed:@Bar1.png];

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.