Closed smarteez17 closed 1 year ago
Can you please share the implementation of WS_COMPITEMS.ContextProvider.CreateInstance
using WS_COMPITEMS.DAL; using Ninject.Activation; using System.Web;
namespace WS_COMPITEMS
{
public class ContextProvider : Provider
switch (dc.ToUpper()) { case "KZN": connStr = "KZN_PromoItemDb"; break; case "EST": connStr = "EST_PromoItemDb"; break; case "CPT": connStr = "CPT_PromoItemDb"; break; case "LVD": connStr = "LVD_PromoItemDb"; break; case "NTH": connStr = "NTH_PromoItemDb"; break; case "STH": connStr = "STH_PromoItemDb"; break; default: connStr = "CO_PromoItemDb"; break; }
PromotionItemsContext promoDbContext = new PromotionItemsContext(connStr);
return promoDbContext; } } }
What if dc is Null?
Hi @scott-xu DC is never null as the user dc come from AD and a dropdown . This app has been working for years and as of this monring we getting this error
Hi there. Please can I get some help. I have version 3.2.0.0 in a prod env and as of this morning it stopped working.
{"message":"An error has occurred.","exceptionMessage":"An error occurred when trying to create a controller of type 'CompositeItemsController'. Make sure that the controller has a parameterless public constructor.","exceptionType":"System.InvalidOperationException","stackTrace":" at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)\r\n at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()","innerException":{"message":"An error has occurred.","exceptionMessage":"Object reference not set to an instance of an object.","exceptionType":"System.NullReferenceException","stackTrace":" at WS_COMPITEMS.ContextProvider.CreateInstance(IContext context)\r\n at Ninject.Activation.Provider
1.Create(IContext context)\r\n at Ninject.Activation.Context.ResolveInternal(Object scope)\r\n at Ninject.Activation.Context.Resolve()\r\n at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext()\r\n at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source)\r\n at System.Linq.Enumerable.WhereSelectArrayIterator
2.MoveNext()\r\n at System.Linq.Buffer1..ctor(IEnumerable
1 source)\r\n at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)\r\n at Ninject.Activation.Providers.StandardProvider.Create(IContext context)\r\n at Ninject.Activation.Context.ResolveInternal(Object scope)\r\n at Ninject.Activation.Context.Resolve()\r\n at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext()\r\n at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source)\r\n at System.Linq.Enumerable.WhereSelectArrayIterator
2.MoveNext()\r\n at System.Linq.Buffer1..ctor(IEnumerable
1 source)\r\n at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)\r\n at Ninject.Activation.Providers.StandardProvider.Create(IContext context)\r\n at Ninject.Activation.Context.ResolveInternal(Object scope)\r\n at Ninject.Activation.Context.Resolve()\r\n at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext()\r\n at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source)\r\n at Ninject.ResolutionExtensions.TryGet[T](IEnumerable
1 iterator)\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator)\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)"}}