KernelContainer.Kernel is null

May 24, 2010 at 7:59 AM
Edited May 24, 2010 at 8:24 AM

It seems to be pretty strange, so I think it's beeing me dumb, but nonetheless I hope you can help me with this problem.

I am trying to load texture:

MainPage.xaml:

<UserControl x:Class="SilverlightApplication2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Execution="clr-namespace:Balder.Core.Execution;assembly=Balder.Core"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <Execution:Game Width="400" Height="300"/>
    </Grid>
</UserControl>

 

 

 MainPage.xaml.cs:

 

using System.Windows.Controls;
using Balder.Core.Assets;
using Balder.Core.Execution;

namespace SilverlightApplication2
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            var assetLoaderService = KernelContainer.Kernel.Get<IAssetLoaderService>();
            var loader = assetLoaderService.GetLoader<Balder.Core.Imaging.Image>("pic.png");
            var images = loader.Load("pic.png");

        }
    }
}

And here I've got a problem. It seems that KernelContainer.Kernel is null, so it can't execute Get() method.

I wonder whether I'm dooing something wrong or maybe there's a better way to load a texture?
May 24, 2010 at 9:40 AM

Disregard that.

Problem's been solved by putting texture loading code inside the Loaded event handler.

Coordinator
May 24, 2010 at 4:05 PM

Good you figured it out - and using the Loaded event would be the appropriate place.