0

This line:

container.Register<IPrincipal>().UsingConstructor(() => HttpContext.Current.User);

throws the following exception:

Cannot register type System.Security.Principal.IPrincipal - abstract classes or interfaces are not valid implementation types for SingletonFactory.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Tss.Rhnncp.DietPlanner.Bootstap.TinyIoCRegistrationTypeException: Cannot register type System.Security.Principal.IPrincipal - abstract classes or interfaces are not valid implementation types for SingletonFactory.

Source Error:

Line 2663: throw new TinyIoCRegistrationTypeException(registerImplementation, "SingletonFactory");
Line 2664:
Line 2665:  if (!IsValidAssignment(registerType, registerImplementation))
Line 2666:      throw new TinyIoCRegistrationTypeException(registerImplementation, "SingletonFactory");
Line 2667:
tereško
  • 58,060
  • 25
  • 98
  • 150
tsage080667
  • 89
  • 1
  • 10

1 Answers1

0

I'm not familiar with TinyIoc, but I expect you need something like this:

container.Register<IPrincipal>(() => HttpContext.Current.User);
Steven
  • 166,672
  • 24
  • 332
  • 435
  • Hi Steven, Thanks for your reply. I've tried this and got an error indicating that 'Argument type "lambda expression" is not assignable to parameter type "IPrincipal"' – tsage080667 Aug 21 '14 at 19:51