2

I have a class which I need to use my container to resolve a concrete class from an interface. this class can't take a constructor, so I am trying to resolve the class using the container.Resolve method.

In my UnityHelper, I have setup all my container items, and the one in question is defined as:

container.RegisterType<OAuthAuthorizationServerProvider, AuthorisationServerProvider>();

And then in my startup.cs file, I am attempting to resolve the class based on the interface:

public class Startup { private OAuthAuthorizationServerProvider _authorisationServiceProvider;

public Startup()
{
    var _container = UnityConfig.GetConfiguredContainer();
    _authorisationServiceProvider = _container.Resolve<OAuthAuthorizationServerProvider>();
}

However, I'm getting a design time error on the 'Resolve'saying that the non-generic method cannot be used with typed arguments.

I've seen places where it seems I am doing it right. Eg: Unity Container Resolve

What am I doing wrong?

1 Answer 1

3

The issue was that you have to manually add the reference to Unity. For those who get this, ensure you have:

using Microsoft.Practices.Unity;
Sign up to request clarification or add additional context in comments.

2 Comments

I just searched and at very first scroll the answer! why don't you mark it as answer
Because I am a fool and forgot. Thanks for the reminder. Done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.