Skip to content
This repository has been archived by the owner on Dec 14, 2017. It is now read-only.

Referencing the library from a custom build causes DI issues #12

Closed
cristian-eriomenco opened this issue Jan 19, 2015 · 4 comments
Closed
Labels

Comments

@cristian-eriomenco
Copy link

If I install the package from Nuget the DI Container gets setup as it should, and every plugin's dependency is registered.

But If I:

  1. Download the source from Github
  2. Build the assembly
  3. Reference the Thinktecture.IdentityServer.WsFederation.dll for IdentityServer.

It causes an DI exception for the WsFederationController:

<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
An error occurred when trying to create a controller of type 'WsFederationController'. Make sure that the controller has a parameterless public constructor.
</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace>
at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
</StackTrace>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Type 'Thinktecture.IdentityServer.WsFederation.WsFederationController' does not have a default constructor
</ExceptionMessage>
<ExceptionType>System.ArgumentException</ExceptionType>
<StackTrace>
at System.Linq.Expressions.Expression.New(Type type) at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator) at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
</StackTrace>
</InnerException>
</Error>

If more details needed please ask.

@brockallen
Copy link
Member

The code is designed to be referenced via NuGet. If you must reference it directly then you must setup the right environment (such as the correct dependencies in the DI system).

@cristian-eriomenco
Copy link
Author

Hmm, I understand.. I'm trying to debug the code for a better understanding of the WS Federation signout functionality. I've tryied in various ways but couldn't yet handle it the right way.

var configuration = new HttpConfiguration();
            var builder = new ContainerBuilder();
            var container = builder.Build();

            configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            app.UseAutofacMiddleware(container);
            app.UseAutofacMvc();
            app.UseAutofacWebApi(configuration);

Can you please show the bare minimum in order to make it work. Or at least point to the right direction. Thank you.

@cristian-eriomenco
Copy link
Author

@brockallen Is this somehow related to this issue IdentityServer/IdentityServer3#611

@brockallen
Copy link
Member

Yea, not sure. Perhaps the best way to debug into the ws-fed code would be to run the sample host that's in the ws-fed repo. It's referencing the code at the project level (and not via nuget).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants