我们在启动MVC 4应用程序时遇到问题。 您可以在图片中看到异常详细信息。此异常仅由内存分析器捕获。
服务注册码如下:
kernel.Bind<RepositoryFactories>().To<RepositoryFactories>().InSingletonScope();
kernel.Bind<IRepositoryProvider>().To<RepositoryProvider>();
kernel.Bind<IBlmsUow>().To<BlmsUow>();
kernel.Bind<IIdentity>().To<Blms.Web.Core.BlmsIdentity>();
//Default is FileService with IO Implementation. If missing in config, automatically use this
FileServiceFactory fileFactory = new FileServiceFactory();
string fileServiceType = ConfigurationManager.AppSettings["IFileService"];
fileServiceType = string.IsNullOrEmpty(fileServiceType) ? "FileService" : fileServiceType;
kernel.Bind<IFileService>().ToMethod(context => fileFactory.CreateInstance(fileServiceType));
kernel.Bind<IConfigurationService>().To<Blms.Service.ConfigurationService.ConfigurationService>();
// Start Register Caching
CachingFactory cachingFactory = new CachingFactory();
kernel.Bind<ICacheLayer>().ToMethod(context => cachingFactory.CreateInstance(ConfigurationManager.AppSettings["ICachelayer"])).InSingletonScope();
// End Register Caching
// Inject kernel in Providers
ServiceFactory serviceFactory = new ServiceFactory();
string emailServiceType = ConfigurationManager.AppSettings["IEmailService"];
emailServiceType = string.IsNullOrEmpty(emailServiceType) ? "MandrillService" : emailServiceType;
kernel.Bind<IEmailService>().ToMethod(context => serviceFactory.CreateInstance<IEmailService>("EmailService", emailServiceType));
serviceFactory = new ServiceFactory();
string smsServiceType = ConfigurationManager.AppSettings["ISmsService"];
smsServiceType = string.IsNullOrEmpty(smsServiceType) ? "TurkTelekomSMSService" : smsServiceType;
kernel.Bind<ISmsService>().ToMethod(context => serviceFactory.CreateInstance<ISmsService>("SmsService", smsServiceType));
serviceFactory = new ServiceFactory();
string notificationServiceType = ConfigurationManager.AppSettings["INotificationService"];
notificationServiceType = string.IsNullOrEmpty(notificationServiceType) ? "AzureNotificationService" : notificationServiceType;
kernel.Bind<INotificationService>().ToMethod(context => serviceFactory.CreateInstance<INotificationService>("NotificationService", notificationServiceType));