This project has moved and is read-only. For the latest updates, please go here.

ChangeRejectedException occuring

Jul 27, 2009 at 5:50 PM

I'm having difficulties with this incarnation of MEF and I'm getting an exception now where before I was not.
The exception is System.ComponentModel.Composition.ChangeRejectedException.  What is this exception and why is it being thrown?

Here's my code:

            if (Directory.Exists(PluginDirectory)) {
                AggregateCatalog catalog = new AggregateCatalog();
                catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
                catalog.Catalogs.Add(new DirectoryCatalog(PluginDirectory));
                var directories = Directory.GetDirectories(PluginDirectory, "*.*", SearchOption.AllDirectories);
                foreach (var directory in directories) {
                    catalog.Catalogs.Add(new DirectoryCatalog(directory));
                CompositionBatch batch = new CompositionBatch();
                CompositionContainer container = new CompositionContainer(catalog);
The exception is occuring on the container.Compose(batch) and I don't understand why.
The PluginDirectory is a network drive so perhaps that has something to do that.
Any suggestions?
Jul 27, 2009 at 5:56 PM

The answer is that I hadn't changed my code to the ImportManyAttribute attribute instead of the ImportAttribute attribute.