Open nadeem1990 opened 4 years ago
tagging @devtrends for help.
Did you try the latest Unity?
Did you try the latest Unity?
I have used Unity 5.11.7 and Unity.WebAPI 5.4.0 versions, Those were the latest available version on the NuGet.
Unfortunately I know very little about Web API and cant't really help. Try looking into history of this project for one of the examples. If this doesn't help perhaps this could give some clues.
Unfortunately I know very little about Web API and cant't really help. Try looking into history of this project for one of the examples. If this doesn't help perhaps this could give some clues.
Unable to get any help with web API in the given examples.
If you want to integrate Unity with ASP.NET Web API, you have at least 3 choices:
1) Do it manually - this is what your links explain how to do by writing your own IDependencyResolver implementation.
2) Use my Unity.WebAPI library. It sounds as though you are already using this, in which case, you might want to look here. Judging by the error, it seems as though the dependency resolver has not been registered so I am wondering if you have missed out adding UnityConfig.RegisterComponents();
to Application_Start()?
3) Use Unity.AspNet.WebApi. I don't know much about this but someone here may be able to help.
If you want to integrate Unity with ASP.NET Web API, you have at least 3 choices:
- Do it manually - this is what your links explain how to do by writing your own IDependencyResolver implementation.
- Use my Unity.WebAPI library. It sounds as though you are already using this, in which case, you might want to look here. Judging by the error, it seems as though the dependency resolver has not been registered so I am wondering if you have missed out adding
UnityConfig.RegisterComponents();
to Application_Start()?- Use Unity.AspNet.WebApi. I don't know much about this but someone here may be able to help.
@devtrends I have done some minor changes in the code and I dont think those are making problem but now I am getting stackoverflow exception and my code is breaking, I have added my entire code base along with error here
@nadeem1990 is this an issue that is happening for every request or is it infrequent?
I am trying to implement the dependency injection in ASP.Net web API with unity container and have implemented the exactly with below 2 articles:
1) https://stackoverflow.com/a/38770689/3698716 2) https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/dependency-injection
Both are related to each other with some minor change but implementation for both are the same.
After implementing I am getting an error in the method GetService in UnityResolver.cs class:
"Resolution failed with error: No public constructor is available for type System.Web.Http.Dispatcher.IHttpControllerActivator."