I am facing an issue currently using Web API for a website using Autofac which i need to connect to the cross platform app.
The code breaks when i call the API(only on multiple instances).
I have done enough of search on documentation, forums and on Stack Overflow. but there was no solution to my issue.
the code produces an exception at
var scope = EngineContext.Current.ContainerManager.Scope() --Null reference exception
I have tried debugging the code but the exception is not generated regularly.
but i found some points where it breaks.
var sis = EngineContext.Current.Resolve<StoreInformationSettings>()
I have tried loading it once again, inside while statement as
var sis = EngineContext.Current.Resolve<StoreInformationSettings>()`
while(sis == null)
{
sis = EngineContext.Current.Resolve<StoreInformationSettings>()
}
var webHelper = EngineContext.Current.Resolve<IWebHelper>();
even in here, i did the same thing which worked again
var webHelper = EngineContext.Current.Resolve<IWebHelper>();
while(webHelper == null)
{
webHelper = EngineContext.Current.Resolve<IWebHelper>();
}
and similarly, a few more instances. this suggests, it's loading but after a delay!
I have tried updating the Autofac Nuget package as instructed in some forum which failed again(i rolled back the version afterwards).
I am using MVC 4
Visual Studio 2015
Autofac Version 3.5.2
this would be of great help, because I am currently stuck here. I cannot carry on further development because its breaking every now and then.
Thank you so much in advance for your help.