2

I'm having same issue described here with no answer, just using Unity.

I'm trying to register ISecureDataFormat<> in the lastest VS2013 (update 2) SPA/Web Api template.

I've tried

container.RegisterType(typeof(ISecureDataFormat<>), typeof(SecureDataFormat<>));
container.RegisterType<ISecureDataFormat<AuthenticationTicket>, SecureDataFormat<AuthenticationTicket>>();
container.RegisterType<ISecureDataFormat<AuthenticationTicket>, TicketDataFormat>();

It "works" but not really because then it complains about the next depenedency in that tree, IDataSerializer... and then the next IDataProtector, for which I found no implementation.

Community
  • 1
  • 1
parliament
  • 21,544
  • 38
  • 148
  • 238

1 Answers1

11

I solved the following error in SimpleInjector with the following mappings

container.Register<IDataSerializer<AuthenticationTicket>, TicketSerializer>();
container.Register<IDataProtector>(() => new DpapiDataProtectionProvider().Create("ASP.NET Identity"));

To figure out what serializer was used I noticed that the ISecureDataFormat generic parameter in the AccountsController was a AuthenticationTicket type. In checking the IDataSerializer namespace the TicketSerializer implements IDataSerializer.

To figure out IDataProtector I again looked in the IDataProtector namespace and found the implementation of the IDataProtectionProvider.

Bart Verkoeijen
  • 16,545
  • 7
  • 52
  • 56
Josh C
  • 7,461
  • 3
  • 24
  • 21