[Mono-bugs] [Bug 697674] New: System.Resources.MissingManifestResourceException is thrown in MEF

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Jun 2 07:32:40 EDT 2011


https://bugzilla.novell.com/show_bug.cgi?id=697674

https://bugzilla.novell.com/show_bug.cgi?id=697674#c0


           Summary: System.Resources.MissingManifestResourceException is
                    thrown in MEF
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.10.x
          Platform: x86-64
        OS/Version: openSUSE 11.4
            Status: NEW
          Severity: Minor
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: mitko.duerr at googlemail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Opera/9.80 (Macintosh; Intel Mac OS X 10.6.7; U; de)
Presto/2.8.131 Version/11.11

When using the MEF shipping with Mono 2.10.2 and you are not using the MEF
right, instead of the actual exception from MEF mono fails to load a resource
file and always throws a System.Resources.MissingManifestResourceException. 

Although this only happens if you do something wrong with the MEF, it's not
helping in development as one has to examine the strack to get a hint about the
real error.

Reproducible: Always

Steps to Reproduce:
Using this code example I commented out the [Export] attribute to create an
exception on MEF on purpose:

using System;
using System.Reflection;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition;

namespace test
{
    //[Export]
    class Sample
    {
        public string Message = "Hello World";
    }

    class MainClass
    {
        [Import]
        public Sample sample;

        public static void Main (string[] args)
        {
            var p = new MainClass ();
            p.Run();
        }
        public void Run ()
        {
            var catalog = new AssemblyCatalog
(Assembly.GetExecutingAssembly());
            var container = new CompositionContainer (catalog);
            container.ComposeParts(this);
            Console.WriteLine(sample.Message);
        }
    }    
}
Actual Results:  
Exception is thrown, but its not the right one:

Unhandled Exception: System.Resources.MissingManifestResourceException: Could
not find any resources appropriate for the specified culture or the neutral
culture.  Make sure "Microsoft.Internal.Strings.resources" was correctly
embedded or linked into assembly "System.ComponentModel.Composition" at compile
time, or that all the satellite assemblies required are loadable and fully
signed.
  at System.Resources.ResourceManager.AssemblyResourceMissing (System.String
fileName) [0x00000] in <filename unknown>:0 
  at System.Resources.ResourceManager.InternalGetResourceSet
(System.Globalization.CultureInfo culture, Boolean createIfNotExists, Boolean
tryParents) [0x00000] in <filename unknown>:0 
  at System.Resources.ResourceManager.InternalGetResourceSet
(System.Globalization.CultureInfo culture, Boolean createIfNotExists, Boolean
tryParents) [0x00000] in <filename unknown>:0 
  at System.Resources.ResourceManager.InternalGetResourceSet
(System.Globalization.CultureInfo culture, Boolean createIfNotExists, Boolean
tryParents) [0x00000] in <filename unknown>:0 
  at System.Resources.ResourceManager.GetString (System.String name,
System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at Microsoft.Internal.Strings.get_CardinalityMismatch_NoExports () [0x00000]
in <filename unknown>:0 
  at System.ComponentModel.Composition.Hosting.ExportProvider.GetExports
(System.ComponentModel.Composition.Primitives.ImportDefinition definition,
System.ComponentModel.Composition.Hosting.AtomicComposition atomicComposition)
[0x00000] in <filename unknown>:0 
  at System.ComponentModel.Composition.Hosting.ImportEngine.TryGetExports
(System.ComponentModel.Composition.Hosting.ExportProvider provider,
System.ComponentModel.Composition.Primitives.ComposablePart part,
System.ComponentModel.Composition.Primitives.ImportDefinition definition,
System.ComponentModel.Composition.Hosting.AtomicComposition atomicComposition)
[0x00000] in <filename unknown>:0 
  at
System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset
(System.ComponentModel.Composition.Hosting.PartManager partManager,
IEnumerable`1 imports,
System.ComponentModel.Composition.Hosting.AtomicComposition atomicComposition)
[0x00000] in <filename unknown>:0 
  at
System.ComponentModel.Composition.Hosting.ImportEngine.TryPreviewImportsStateMachine
(System.ComponentModel.Composition.Hosting.PartManager partManager,
System.ComponentModel.Composition.Primitives.ComposablePart part,
System.ComponentModel.Composition.Hosting.AtomicComposition atomicComposition)
[0x00000] in <filename unknown>:0 
  at System.ComponentModel.Composition.Hosting.ImportEngine.PreviewImports
(System.ComponentModel.Composition.Primitives.ComposablePart part,
System.ComponentModel.Composition.Hosting.AtomicComposition atomicComposition)
[0x00000] in <filename unknown>:0 
  at
System.ComponentModel.Composition.Hosting.ComposablePartExportProvider.Compose
(System.ComponentModel.Composition.Hosting.CompositionBatch batch) [0x00000] in
<filename unknown>:0 
  at System.ComponentModel.Composition.Hosting.CompositionContainer.Compose
(System.ComponentModel.Composition.Hosting.CompositionBatch batch) [0x00000] in
<filename unknown>:0 
  at System.ComponentModel.Composition.AttributedModelServices.ComposeParts
(System.ComponentModel.Composition.Hosting.CompositionContainer container,
System.Object[] attributedParts) [0x00000] in <filename unknown>:0 
  at test.MainClass.Run () [0x00000] in <filename unknown>:0 
  at test.MainClass.Main (System.String[] args) [0x00000] in <filename
unknown>:0 


Expected Results:  
>From the stracktrace you can get a hint about what exception should have been
actually thrown:

at Microsoft.Internal.Strings.get_CardinalityMismatch_NoExports () [0x00000] in
<filename unknown>:0

Expected behaviour: Throw the "CardinalityMismatch_NoExports" exception.

The same happens if you provoke other exceptions within MEF, so its not
specific to the posted code snippet.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list