开发者

RegisterType<> Not visible on Silverlight

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>()开发者_JAVA技巧;
        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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜