I have WCF service and inside this service using MEF i am calling runtime class library.
I have implemented DI(castle Windsor) in this class library and it work ok in all request but instantly some time it return error like below
"HttpContext.Current is null. PerWebRequestLifestyle can only be used in ASP.Net"
We have apply all internet solution like install Asp.net feature, change DI Lifecycle from LifestylePerWebRequest to scope , hibridgeLifeStyle etc But not found proper result below is my code
Can any one plese help me solve this issue. As i am new in DI and don't this is Life cycle issue or MEF issue or threading issue because i am calling this class libreary in to thread
Thanks in advance

You need to run WCF in ASP.Net compat mode to get access to HttpContext. Not sure why you need it though because then you can only run the WCF services on IIS in asp.net compat mode and not within a different hosting environment like a windows service.
more information here: https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/wcf-services-and-aspnet which also tells you about contexts you should be using instead of HttpContext