Any chance of getting this to work with Windows Phone 7 Series?

112 views
Skip to first unread message

aemami

unread,
Mar 18, 2010, 1:26:01 AM3/18/10
to ninject
So far it doesn't seem to work - I keep getting a

"Error loading Ninject component IEnumerable{IActivationStrategy}
No such component has been registered in the kernel's component
container."

exception.

This is with the new Ninject 2.0 official release, using the
Silverlight 3 binaries.

Ian Davis

unread,
Mar 18, 2010, 1:28:12 AM3/18/10
to nin...@googlegroups.com
Can you post the full exception please?


--
You received this message because you are subscribed to the Google Groups "ninject" group.
To post to this group, send email to nin...@googlegroups.com.
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ninject?hl=en.


aemami

unread,
Mar 18, 2010, 1:50:34 AM3/18/10
to ninject
System.InvalidOperationException was unhandled
Message=Error loading Ninject component

IEnumerable{IActivationStrategy}
No such component has been registered in the kernel's component
container.

Suggestions:
1) If you have created a custom subclass for KernelBase, ensure that
you have properly
implemented the AddComponents() method.
2) Ensure that you have not removed the component from the container
via a call to RemoveAll().
3) Ensure you have not accidentally created more than one kernel.

StackTrace:
at Ninject.Components.ComponentContainer.Get(Type component)
at
Ninject.Components.ComponentContainer.<CreateNewInstance>b__6(ParameterInfo
parameter)
at System.Linq.Enumerable.<SelectIterator>d__d`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1
source)
at Ninject.Components.ComponentContainer.CreateNewInstance(Type
component, Type implementation)
at Ninject.Components.ComponentContainer.ResolveInstance(Type
component, Type implementation)
at Ninject.Components.ComponentContainer.Get(Type component)
at
Ninject.Components.ComponentContainer.<CreateNewInstance>b__6(ParameterInfo
parameter)
at System.Linq.Enumerable.<SelectIterator>d__d`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1
source)
at Ninject.Components.ComponentContainer.CreateNewInstance(Type
component, Type implementation)
at Ninject.Components.ComponentContainer.ResolveInstance(Type
component, Type implementation)
at Ninject.Components.ComponentContainer.Get(Type component)
at Ninject.Components.ComponentContainer.Get[T]()
at Ninject.KernelBase.CreateContext(IRequest request, IBinding
binding)
at Ninject.KernelBase.<>c__DisplayClass7.<Resolve>b__3(IBinding
binding)
at System.Linq.Enumerable.<SelectIterator>d__d`2.MoveNext()
at System.Linq.Enumerable.<SelectIterator>d__d`2.MoveNext()
at System.Linq.Enumerable.<CastIterator>d__b0`1.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1
source)
at Ninject.ResolutionExtensions.Get[T](IResolutionRoot root,
IParameter[] parameters)
at
InputEmulator.WindowsPhone7Series.InputHandlers.BindMouseControlsScreen(IKernel
kernel)
at
InputEmulator.WindowsPhone7Series.InputHandlers.BindInputHandlers(IKernel
kernel)
at
InputEmulator.WindowsPhone7Series.KernelFactory.get_Current()
at
InputEmulator.WindowsPhone7Series.App.Application_Startup(Object
sender, StartupEventArgs e)
at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32
typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr
unmanagedObjArgs, Int32 argsTypeIndex, String eventName)


On Mar 17, 10:28 pm, Ian Davis <ida...@innovatian.com> wrote:
> Can you post the full exception please?
>
>
>
> On Wed, Mar 17, 2010 at 10:26 PM, aemami <aemam...@gmail.com> wrote:
> > So far it doesn't seem to work - I keep getting a
>
> > "Error loading Ninject component IEnumerable{IActivationStrategy}
> > No such component has been registered in the kernel's component
> > container."
>
> > exception.
>
> > This is with the new Ninject 2.0 official release, using the
> > Silverlight 3 binaries.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ninject" group.
> > To post to this group, send email to nin...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > ninject+u...@googlegroups.com<ninject%2Bunsu...@googlegroups.com >

aemami

unread,
Mar 18, 2010, 1:52:11 AM3/18/10
to ninject
I'm using StandardKernel btw, with no modules or anything.

Ian Davis

unread,
Mar 18, 2010, 2:14:26 AM3/18/10
to nin...@googlegroups.com
Are you using a static kernel accessor? If so, are you assigning its instance before using it? Are you changing any kernel component bindings? Are you creating your own kernel components?

Thanks,

Ian

To unsubscribe from this group, send email to ninject+u...@googlegroups.com.

aemami

unread,
Mar 18, 2010, 2:31:00 AM3/18/10
to ninject
Hi Ian,

1. Yes.
2. Yes.
3. Not sure what you mean by changing the binding... if you mean am
I calling kernel.Bind<ISomething>().To<Something>() then yes.
4. No.

> > <ninject%2Bunsu...@googlegroups.com<ninject%252Bunsubscribe@googlegroup s.com>>

aemami

unread,
Mar 18, 2010, 2:31:40 AM3/18/10
to ninject
The exact same code works in a Silverlight app I wrote. Its just when
I ported it to the new WP7 beta that it broke.

> > <ninject%2Bunsu...@googlegroups.com<ninject%252Bunsubscribe@googlegroup s.com>>

Ian Davis

unread,
Mar 18, 2010, 9:09:21 AM3/18/10
to nin...@googlegroups.com
Are you using kernel.Components.Add<T,U>() anywhere? or kernel.Components.RemoveAll()?

The line that seems to be failing is : return new Context(this, request, binding, Components.Get<ICache>(), Components.Get<IPlanner>(), Components.Get<IPipeline>());

It is trying to resolve either ICache, IPlanner, or IPipeline. These are configured in StandardKernel.AddComponents - there is no conditional logic, it is seems to be indicating that they are missing.  

This shouldn't be an issue, but are you using Ninject 2.0 RTM?

-Ian

On Wed, Mar 17, 2010 at 11:31 PM, aemami <aema...@gmail.com> wrote:
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.

aemami

unread,
Mar 19, 2010, 5:10:06 AM3/19/10
to ninject
Yes, I am using the official 2.0 release.

I am not doing any of those things you mentioned.

It must be that Ninject is relying on something that is part of the
normal .NET frameworks but that does not exist on the WP7 framework
(which so far is a stripped-down version of Silverlight 3).

> > > > <ninject%2Bunsu...@googlegroups.com<ninject%252Bunsubscribe@googlegroup s.com>

Ian Davis

unread,
Mar 19, 2010, 8:28:39 AM3/19/10
to nin...@googlegroups.com
Does WP7 have its own compiler then that should be used?

To unsubscribe from this group, send email to ninject+u...@googlegroups.com.

oliverw

unread,
Mar 26, 2010, 7:12:17 PM3/26/10
to ninject
I'm observing exactly the same problem here. Application code taken
straight without modifications from a working Silverlight 3 project
and I'm getting the same exception on the first attempt to get an
object from the (configured) kernel.

I'd say you should be able to reproduce the problem pretty quickly
using the Windows Phone SDK available here:
http://developer.windowsphone.com/windows-phone-7-series/

Ian Davis

unread,
Mar 26, 2010, 8:33:05 PM3/26/10
to nin...@googlegroups.com
It is having an issue resolving the activation strategy components. I am trying to debug, but I am stuck at the moment:

---------------------------
Microsoft Visual Studio 2010 Express for Windows Phone
---------------------------
Object reference not set to an instance of an object.
---------------------------
OK   
---------------------------


It won't let me start debugging....

-Ian


--

oliverw

unread,
Mar 27, 2010, 5:12:49 AM3/27/10
to ninject
Hey Ian

Thanks for taking the time to investigate. One remark: the current WP7
SDK - actually the emulator - won't run in a virtualized environment -
if you tried that.

> > ninject+u...@googlegroups.com<ninject%2Bunsu...@googlegroups.com >

Ian Davis

unread,
Mar 27, 2010, 8:51:39 AM3/27/10
to nin...@googlegroups.com
No, I am running it on Windows 7 x64. I am not happy that it installed 2010 express on my machine, I just wanted an sdk.

-Ian

To unsubscribe from this group, send email to ninject+u...@googlegroups.com.

oliverw

unread,
Mar 27, 2010, 9:54:49 AM3/27/10
to ninject
None of us is. The SDK integrates with a pre-installed VS2010 RC (must
be the RC) just fine but will install 2010 Express in any case. I
assume that the next release of the SDK will integrate with VS 2010
RTM.

> > <ninject%2Bunsu...@googlegroups.com<ninject%252Bunsubscribe@googlegroup s.com>>

oliverw

unread,
Mar 28, 2010, 2:35:59 PM3/28/10
to ninject
Btw is there anything I can do to help with fixing the problem?

Ian Davis

unread,
Mar 28, 2010, 3:44:51 PM3/28/10
to nin...@googlegroups.com
Can you figure out what is causing the bug ;)


On Sun, Mar 28, 2010 at 11:35 AM, oliverw <mmo...@googlemail.com> wrote:
Btw is there anything I can do to help with fixing the problem?
--
You received this message because you are subscribed to the Google Groups "ninject" group.
To post to this group, send email to nin...@googlegroups.com.
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.

oliverw

unread,
Mar 29, 2010, 2:48:50 AM3/29/10
to ninject
Do you have only a problem debugging the code or won't run the code at
all? If it runs at least perhaps you could use some old school trace
statements to figure out the area of the problem :)

On Mar 28, 9:44 pm, Ian Davis <ida...@innovatian.com> wrote:
> Can you figure out what is causing the bug ;)
>
>
>
> On Sun, Mar 28, 2010 at 11:35 AM, oliverw <mmo...@googlemail.com> wrote:
> > Btw is there anything I can do to help with fixing the problem?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ninject" group.
> > To post to this group, send email to nin...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > ninject+u...@googlegroups.com<ninject%2Bunsu...@googlegroups.com >

Ian Davis

unread,
Mar 29, 2010, 8:25:30 AM3/29/10
to nin...@googlegroups.com
It won't run at all on my machine.

To unsubscribe from this group, send email to ninject+u...@googlegroups.com.

aemami

unread,
Apr 10, 2010, 10:01:06 PM4/10/10
to ninject
Any luck?


On Mar 29, 5:25 am, Ian Davis <ida...@innovatian.com> wrote:
> It won't run at all on my machine.
>
>
>
> On Sun, Mar 28, 2010 at 11:48 PM, oliverw <mmo...@googlemail.com> wrote:
> > Do you have only a problem debugging the code or won't run the code at
> > all? If it runs at least perhaps you could use some old school trace
> > statements to figure out the area of the problem :)
>
> > On Mar 28, 9:44 pm, Ian Davis <ida...@innovatian.com> wrote:
> > > Can you figure out what is causing the bug ;)
>
> > > On Sun, Mar 28, 2010 at 11:35 AM, oliverw <mmo...@googlemail.com> wrote:
> > > > Btw is there anything I can do to help with fixing the problem?
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "ninject" group.
> > > > To post to this group, send email to nin...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > ninject+u...@googlegroups.com<ninject%2Bunsu...@googlegroups.com >

> > <ninject%2Bunsu...@googlegroups.com<ninject%252Bunsubscribe@googlegroup s.com>>

oliverw

unread,
Apr 12, 2010, 6:08:49 PM4/12/10
to ninject
Allright I've investigated a bit and this is what I've found out:

1. I've verified that all Ninject internal components get added
correctly to the ComponentContainer
2. At some point during the initialization Ninject tries to resolve
IEnumerable<IActivationStrategy> in the Pipeline class
3. This crashes in ComponentContainer.cs:142 when it throws the
InvalidOperationException(ExceptionFormatter.NoSuchComponentRegistered(component));
4. The true cause for this lies in ComponentContainer.cs:135 where sub
expression "typeof(IEnumerable<>).IsAssignableFrom(gtd)"
returns False

I've created a new Windows Phone Class Library project. Included all
source files from a freshly fetched Ninject Github cloned repository
and defined the following constants to get it to build: SILVERLIGHT,
NO_PARTIAL_TRUST, NO_LCG, NO_WEB, NO_ASSEMBLY_SCANNING,
NO_EXCEPTION_SERIALIZATION

On Mar 28, 9:44 pm, Ian Davis <ida...@innovatian.com> wrote:
> Can you figure out what is causing the bug ;)
>
>
>
> On Sun, Mar 28, 2010 at 11:35 AM, oliverw <mmo...@googlemail.com> wrote:
> > Btw is there anything I can do to help with fixing the problem?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ninject" group.
> > To post to this group, send email to nin...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > ninject+u...@googlegroups.com<ninject%2Bunsu...@googlegroups.com >

oliverw

unread,
Apr 12, 2010, 6:12:41 PM4/12/10
to ninject
Perhaps this page provides some insight: http://msdn.microsoft.com/en-us/library/ff426930(VS.96).aspx

oliverw

unread,
Apr 13, 2010, 4:11:04 AM4/13/10
to ninject
Quote: "Open generics are not supported in Silverlight for Windows
Phone."
Source: http://msdn.microsoft.com/en-us/library/ff426930(VS.96).aspx

So we would need a workaround.

oliverw

unread,
Apr 13, 2010, 7:30:33 AM4/13/10
to ninject
Ninject 2.0 seems to run on the Phone with this version of
ComponentContainer.Get:

/// <summary>
/// Gets one instance of the specified component.
/// </summary>
/// <param name="component">The component type.</param>
/// <returns>The instance of the component.</returns>
public object Get(Type component)
{
Ensure.ArgumentNotNull(component, "component");

if (component == typeof(IKernel))
return Kernel;

if (component.IsGenericType)
{
Type gtd = component.GetGenericTypeDefinition();
Type argument = component.GetGenericArguments()[0];

#if !WPHONE
if (gtd.IsInterface && typeof(IEnumerable<>).IsAssignableFrom(gtd))
return GetAll(argument).CastSlow(argument);
#else
Type discreteGenericType =
typeof(IEnumerable<>).MakeGenericType(argument); // TODO: we should
probably cache this
if (gtd.IsInterface &&
discreteGenericType.IsAssignableFrom(component))
return GetAll(argument).CastSlow(argument);
#endif
}

Type implementation = _mappings[component].FirstOrDefault();

if (implementation == null)
throw new
InvalidOperationException(ExceptionFormatter.NoSuchComponentRegistered(component));

return ResolveInstance(component, implementation);
}

Miguel Madero

unread,
Apr 19, 2010, 9:33:53 PM4/19/10
to nin...@googlegroups.com
To use Ninject I had to do some changes to the DynamicMethodInjectorFactory and removed the usages of Reflection.Emit.

}

--
You received this message because you are subscribed to the Google Groups "ninject" group.
To post to this group, send email to nin...@googlegroups.com.
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/ninject?hl=en.




--
Miguel A. Madero Reyes
www.miguelmadero.com (blog)
m...@miguelmadero.com

--
You received this message because you are subscribed to the Google Groups "ninject" group.
To post to this group, send email to nin...@googlegroups.com.
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.

Jonas Follesø

unread,
May 16, 2010, 7:31:39 PM5/16/10
to nin...@googlegroups.com
Anyone who have worked on fixing a WP7 build happen to use GitHub?

I'm currently preparing a WP7 talk, and want to use my favorite IoC container for the demo.

I would be happy to help out getting Ninject 2 running on WP7, but before starting off the master branch on Ninject I want to check if any of you got a branch where WP7 is working.

- Jonas

Ian Davis

unread,
May 17, 2010, 10:37:44 AM5/17/10
to nin...@googlegroups.com
Oliverw has done it with a couple changes in his fork. I have tried twice, but every time I install WP7 it messes up all of my silverlight building capabilities. From his response:

"Allright I've investigated a bit and this is what I've found out: 

1. I've verified that all Ninject internal components get added 
correctly to the ComponentContainer 
2. At some point during the initialization Ninject tries to resolve 
IEnumerable<IActivationStrategy> in the Pipeline class 
3. This crashes in ComponentContainer.cs:142 when it throws the 
InvalidOperationException(ExceptionFormatter.NoSuchComponentRegistered(comp onent)); 
4. The true cause for this lies in ComponentContainer.cs:135 where sub 
expression "typeof(IEnumerable<>).IsAssignableFrom(gtd)" 
returns False 

I've created a new Windows Phone Class Library project. Included all 
source files from a freshly fetched Ninject Github cloned repository 
and defined the following constants to get it to build: SILVERLIGHT, 
NO_PARTIAL_TRUST, NO_LCG, NO_WEB, NO_ASSEMBLY_SCANNING, NO_EXCEPTION_SERIALIZATION "


I am trying to get a VM running to build it, just need to get the time to do so.

-Ian

Jonas Follesø

unread,
May 18, 2010, 2:31:01 AM5/18/10
to nin...@googlegroups.com
Cool.

Just remember that the WP7 emulator itself is a VM, and in general doesn't work well inside another VM. I do my WP7 dev using a "boot to VHS" image. I also think the WP7 emulator will run inside WMVare, but no VPC or Parallels.

- Jonas :)

Ian Davis

unread,
May 26, 2010, 5:33:49 PM5/26/10
to nin...@googlegroups.com
Does anyone have a unified diff that shows what they changed to get Ninject working on WP7?

Thanks,

-Ian

On Wed, Mar 17, 2010 at 10:26 PM, aemami <aema...@gmail.com> wrote:
So far it doesn't seem to work - I keep getting a

"Error loading Ninject component IEnumerable{IActivationStrategy}
No such component has been registered in the kernel's component
container."

exception.

This is with the new Ninject 2.0 official release, using the
Silverlight 3 binaries.

Ian Davis

unread,
May 27, 2010, 10:16:09 AM5/27/10
to nin...@googlegroups.com
I have a WP7 in the builds scripts for Ninject. I tried out the code below but it doesn't work - I get the same exception as before. There is a definition for WP7 that is used instead of the WPHONE constant.

Can someone who has gotten ninject working on WP7 give their changes that are currently working with the latest sdk release?

It is in the build-release.cmd file, but it is now possible to use this to build the wp7 version of ninject

tools\nant\nant.exe -buildfile:Ninject.build clean %1 %2 %3 %4 %5 %6 %7 %8
tools\nant\nant.exe -buildfile:Ninject.build "-D:build.config=debug" "-D:build.platform=silverlight-4.0-wp7" package-bin %1 %2 %3 %4 %5 %6 %7 %8

Thanks,

Ian

}

--
You received this message because you are subscribed to the Google Groups "ninject" group.
To post to this group, send email to nin...@googlegroups.com.
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.

Ian Davis

unread,
May 31, 2010, 11:49:01 AM5/31/10
to nin...@googlegroups.com
OK, so here is what I have. The code from Oliver works when compiled in a windows phone library from VS. When built from the command line with NAnt, it fails. I looked at the disassembly and it has the code needed. So there is some difference between the two builds, but I don't see it right off. I pushed the changes needed.

If you want to use Ninject for the WP7 platform at the moment, grab the code and put it into a windows phone library with the following constants:

SILVERLIGHT,SILVERLIGHT_40,WINDOWS_PHONE,NO_LCG,NO_ASSEMBLY_SCANNING,NO_WEB,NO_PARTIAL_TRUST,NO_SKIP_VISIBILITY,NO_EXCEPTION_SERIALIZATION,NO_DEBUG_SYMBOLS

-Ian

Ian Davis

unread,
May 31, 2010, 8:48:29 PM5/31/10
to nin...@googlegroups.com
Anyone looking for a Ninject build for WP7? Enjoy: http://github.com/downloads/ninject/ninject/Ninject.Silverlight-4.0-WP7_Beta.zip  - there are signed and unsigned versions of Ninject. Be aware that this is from the 2.1.0.0 code which I am hoping to release this week - thus it has the enhanced resolution code you may not have seen yet.

Please let me know if you run into anything.

-Ian
Reply all
Reply to author
Forward
0 new messages