You are getting this because you need to add an [ImportingConstructor]
attribute. MEF will only take the default ctor unless you put the attribute.


On Mon, Jun 2, 2014 at 10:31 AM, Adam Ralph <notifications@github.com>
wrote:

> In src/ScriptCs.Engine.Mono/MonoModule.cs:
>
> > @@ -12,9 +12,15 @@ public void Initialize(IModuleConfiguration config)
> >          {
> >              Guard.AgainstNullArgument("config", config);
> >
> > -            Console.WriteLine("Mono Engine initialized!");
> > +            if (Type.GetType("Mono.Runtime") == null)
>
> I tried taking a dep on IConsole in the constructor but I got
>
> Unhandled Exception:
> System.ComponentModel.Composition.CompositionException: The composition
> produced a single composition error. The root cause is provided below.
> Review the CompositionException.Errors property for more detailed
> information.
>
> 1) Cannot create an instance of type 'ScriptCs.Engine.Mono.MonoModule'
> because a constructor could not be selected for construction. Ensure that
> the type either has a default constructor, or a single constructor marked
> with the 'System.ComponentModel.Composition.ImportingConstructorAttribute'.
>
> Resulting in: Cannot activate part 'ScriptCs.Engine.Mono.MonoModule'.
> Element: ScriptCs.Engine.Mono.MonoModule -->
> ScriptCs.Engine.Mono.MonoModule --> DirectoryCatalog
> (Path="C:\code\scriptcs\src\ScriptCs\bin\Release\")
>
> Resulting in: Cannot get export 'ScriptCs.Engine.Mono.MonoModule
> (ContractName="ScriptCs.Contracts.IModule")' from part
> 'ScriptCs.Engine.Mono.MonoModule'.
> Element: ScriptCs.Engine.Mono.MonoModule
> (ContractName="ScriptCs.Contracts.IModule") -->
> ScriptCs.Engine.Mono.MonoModule --> DirectoryCatalog
> (Path="C:\code\scriptcs\src\ScriptCs\bin\Release\")
>
> What do you think? Shall I take out the message altogether? Or shall we
> leave it as is for now and merge the PR until we figure it out properly? I
> think the PR is a step forward from now at least.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/scriptcs/scriptcs/pull/737/files#r13296424>.
>