views:

33

answers:

1

I was following an example found here on StackOverflow, and everything went well until I need to register my types.

My web application is running on Silverlight 4, with Prism and MVVM.

The example is using "Microsoft.Practices.Unity" (it's a windows form application)

Bootstrapper.cs

    protected override void ConfigureContainer()
    {
        base.ConfigureContainer();
        Container.RegisterType<IApplicationMenuRegistry, MenuRegistry>();
        Container.RegisterType<IApplicationCommands, ApplicationCommands>();
        Container.RegisterType<ShellViewModel, ShellViewModel>(new Microsoft.Practices.Unity.ContainerControlledLifetimeManager());
    }

Mine is using: Microsoft.Practices.Unity.Silverlight (web) and throws the following error:

The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.RegisterType(...) cannot be used with type arguments.

And the RegisterType<> constructor is not visible for me. Which alternatives do I have to register my types?

+1  A: 

I am using Unity for Silverlight and have not had this issue.

According to this post, http://unity.codeplex.com/workitem/8205, you need to add "using Microsoft.Practices.Unity;" to the file. The generic versions of Resolve are extension methods and you need to pull in the namespace to use them.

Apparently ReSharper may think the using statement is not needed and may remove it.

Hope that helps.

Joe McBride
Yes, this is what happened. The extension method were located at Microsoft.Practices.Unity. Well, thank you Joe!
Dorival

related questions