XML Extension and Weak Event Message Broker Extension

May 10, 2012 at 3:47 PM

Hello,
I am newbie in Ninject and IoC and I want to understand how to use it
properly.
I need to use XML configuration for creating my objects (this is a
requirement) and I done that. But I need to use WeakEventMessageBrorker
too. So when create objects by the code (not with XML config file) the
events are wired together and everything works perfect. When create
objects and load XML file the events are not wired.
My xml file looks like basic.xml from the Ninject.Extension.Xml.Test
project:

<module name="basicTest">
    <bind name="myObject"
                service="MyNamespace.IService, MyProjectName"
                to="MyNamespace.MyService, MyProjectName" />
</module>

, and class form code behind

public override void Load()
{
Bind<IService>().To<MyService>();

}

So what is the difference from both object created by xml config file
and from code behind?
I know that Ninject`s goal is to restrict using of xml, but is there
any chance to use  Ninject.Extension.Xml and WeakEventMessageBrorker
together?
Thanks in advance

May 11, 2012 at 1:59 PM
Edited May 11, 2012 at 2:00 PM

Hello all,

I figure out what was the problem. The few examples with XML Extensions are very shorts and they are saying:

 var settings = new NinjectSettings { LoadExtensions = false };
 kernel = new StandardKernel(settings, new XmlExtensionModule());
 kernel.Load("MyConfigFile.xml");
But LoadExtensions = false exclude auto loading of available modules.
So I changed it to:
 kernel = new StandardKernel();
 kernel.Load("MyConfigFile.xml");
And it works perfect - it loads WeakEventMessageBroker Extension, and XML extension too and events are wired up.