I know there are some questions already on this topic but I am still missing something that is causing this error. I installed ninject.mvc3 package which installs ninject and ninject.web.common packages. No modification was made in global.asax (as suggested in official documentation).
App_Start/NinjectWebCommon.cs's RegisterServices method has the Bind statement after loading the Kernel. I am getting this error with this stack trace when I try to run the site.
[InvalidOperationException: Sequence contains no elements]
System.Linq.Enumerable.Single(IEnumerable`1 source) +379
Ninject.Web.Mvc.NinjectMvcHttpApplicationPlugin.Start() in c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectMvcHttpApplicationPlugin.cs:53
Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map(IEnumerable`1 series, Action`1 action) in c:\Projects\Ninject\ninject\src\Ninject\Infrastructure\Language\ExtensionsForIEnumerableOfT.cs:32
Ninject.Web.Common.Bootstrapper.Initialize(Func`1 createKernelCallback) in c:\Projects\Ninject\Ninject.Web.Common\src\Ninject.Web.Common\Bootstrapper.cs:53
Ninject.Web.Common.NinjectHttpApplication.Application_Start() in c:\Projects\Ninject\Ninject.Web.Common\src\Ninject.Web.Common\NinjectHttpApplication.cs:81
[HttpException (0x80004005): Sequence contains no elements]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12864673
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): Sequence contains no elements]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601
What step am I still missing?
The source says on line 53:
ModelValidatorProviders.Providers.Remove(
ModelValidatorProviders.Providers.OfType<DataAnnotationsModelValidatorProvider>)
.Single());
Have you in some way inhibited the addition of the DataAnnotationsModelValidatorProvider ? Probably not - therefore I suggest you've got two copies of the same logic in your system - do you have >1 NinjectWebCommon.cs ?
Another thing worth trying (in general - I have no specif reason why it should fix this case for you) is see if the same thing still happens when you use the Include Prerelease NuGet packages.
Related
After installing the latest version of Sensenet, the following error is displayed when application is started with debugging:
SenseNet.ExclusiveLock.MsSql component is missing.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: SenseNet.ExclusiveLock.MsSql component is missing.
Source Error:
Line 13: protected override void Application_Start(object sender, EventArgs e, HttpApplication application)
Line 14: {
Line 15: base.Application_Start(sender, e, application);
Line 16:
Line 17: AreaRegistration.RegisterAllAreas();
Source File: c:\users\administrator\source\repos\WebApplication4\WebApplication4\Global.asax.cs Line: 15
[InvalidOperationException: SenseNet.ExclusiveLock.MsSql component is missing.]
SenseNet.ContentRepository.RepositoryVersionInfo.IsComponentAllowed(SnComponentInfo component, Version installedComponentVersion) +217
SenseNet.ContentRepository.RepositoryVersionInfo.CheckComponentVersions(SnComponentInfo[] components, Boolean release) +237
SenseNet.Services.SenseNetGlobal.Application_Start(Object sender, EventArgs e, HttpApplication application) in C:\agent-02\_work\2\s\src\Services\SenseNetGlobal.cs:166
WebApplication4.MvcApplication.Application_Start(Object sender, EventArgs e, HttpApplication application) in c:\users\administrator\source\repos\WebApplication4\WebApplication4\Global.asax.cs:15
SenseNet.Portal.Global.Application_Start(Object sender, EventArgs e) in C:\agent-02\_work\2\s\src\Services\Global.cs:15
[HttpException (0x80004005): SenseNet.ExclusiveLock.MsSql component is missing.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +10107111
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +123
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +181
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +228
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +314
[HttpException (0x80004005): SenseNet.ExclusiveLock.MsSql component is missing.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10087352
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +99
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +263
I followed installation instructions closely and no build errors were reported.
you have a previous version of sensenet and you upgraded the NuGet packages, am I correct? It seems that this combination does not work, because the component above is installed automatically by the new infrastructure - which is not compatible with your version. The only solution I see here is to downgrade the packages to their older versions (at least last August, maybe older). SenseNet has changed a lot since we moved to .Net Core, and there are some incompatibilities with the .Net Framework libraries. Please consider taking a look at the new "sensenet as a service" solution that will free you from the upgrade hassle.
Here's the stack trace.
[ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length]
System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +10699039
System.Web.HttpApplication.HookupEventHandlersForApplicationAndModules(MethodInfo[] handlers) +312
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +107
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): Index and length must refer to a location within the string.
Parameter name: length]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9874568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Is there any way to find out where this exception is coming from other than throwing random breakpoints everywhere? Thanks!
I ran into the same issue and was able to resolve it.
It turns out that at some point I fat-fingered something while in Global.asax.cs. I ended up changing the method Application_Error to Application_ (with a new line after it, stupid wide fingers...). This is what was causing the error to appear for me. Rewriting it as Application_Error resolved the issue.
This error occurs only in our production enviromnent, not locally or on the test server. I´ve narrowed it down to the preset-node in the configuration. The exception is thrown when I have presets defined and start the web site. If I comment the preset-element the site starts and images can be scaled manually through the query params.
The call stack:
Exception Details: System.Web.HttpException: Response is not available in this context.
[HttpException (0x80004005): Response is not available in this context.]
System.Web.HttpUtility.UrlDecode(String str, Encoding e) +4841588
ImageResizer.Util.PathUtils.ParseQueryOnly(String query, Boolean allowSemicolons, Boolean urlDecode) +307
ImageResizer.ResizeSettings..ctor(String queryString) +224
ImageResizer.Plugins.Basic.Presets.ParseXml(Node n, Config conf) +870
ImageResizer.Plugins.Basic.Presets.Install(Config c) +98
ImageResizer.Configuration.PluginConfig.loadPluginsInternal() +303
ImageResizer.Configuration.PluginConfig.LoadPlugins() +61
ImageResizer.Configuration.Config.get_Current() +109
[HttpException (0x80004005): Response is not available in this context.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +3985477
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +325
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375
[HttpException (0x80004005): Response is not available in this context.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11524352
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4782309
This regression in the ASP.NET framework was introduced in .NET 4.0 RTM, and has been patched in a later updates to the framework.
It made HttpUtility.UrlEncode dependent upon having a valid HttpContext.
More details about the bug can be found here.
I'm using Castle Windsor 3.1.0 in an ASP .NET 4 MVC application, which is giving me an exception in the Application_Start event when container.Register is called.
The exception is "The invoked member is not supported in a dynamic assembly.". Here's the stack trace:
[NotSupportedException: The invoked member is not supported in a dynamic assembly.]
System.Reflection.Emit.InternalAssemblyBuilder.GetExportedTypes() +56
Castle.Core.Internal.ReflectionUtil.GetAvailableTypes(Assembly assembly, Boolean includeNonExported) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\Core\Internal\ReflectionUtil.cs:165
Castle.MicroKernel.Registration.FromAssemblyDescriptor.<SelectedTypes>b__0(Assembly a) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\MicroKernel\Registration\FromAssemblyDescriptor.cs:56
System.Linq.<SelectManyIterator>d__14`2.MoveNext() +238
Castle.MicroKernel.Registration.FromDescriptor.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\MicroKernel\Registration\FromDescriptor.cs:160
Castle.MicroKernel.Registration.BasedOnDescriptor.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\MicroKernel\Registration\BasedOnDescriptor.cs:530
Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\MicroKernel\DefaultKernel.cs:506
Castle.Windsor.WindsorContainer.Register(IRegistration[] registrations) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\Windsor\WindsorContainer.cs:483
ProductX.Web.Windsor.Installers.ControllerInstaller.Install(IWindsorContainer container, IConfigurationStore store) in C:\TeamProjects\CompanyX.ProductX\Mainline\Admin\ProductX.Web\Windsor\Installers\ControllerInstaller.cs:24
Castle.Windsor.Installer.AssemblyInstaller.Install(IWindsorContainer container, IConfigurationStore store) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\Windsor\Installer\AssemblyInstaller.cs:56
Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers, DefaultComponentInstaller scope) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\Windsor\WindsorContainer.cs:319
Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers) in c:\BuildAgent\work\5b096cace0fecb1f\src\Castle.Windsor\Windsor\WindsorContainer.cs:452
ProductX.Web.MvcApplication.InitializeWindsor() in C:\TeamProjects\CompanyX.ProductX\Mainline\Admin\ProductX.Web\Global.asax.cs:41
ProductX.Web.MvcApplication.Application_Start() in C:\TeamProjects\CompanyX.ProductX\Mainline\Admin\ProductX.Web\Global.asax.cs:25
[HttpException (0x80004005): The invoked member is not supported in a dynamic assembly.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9171773
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +131
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253
[HttpException (0x80004005): The invoked member is not supported in a dynamic assembly.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090876
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
Here's how I'm calling Register:
container.Register(Classes.FromThisAssembly().BasedOn<IController>().LifestyleTransient());
When I build the application in Debug mode, it's fine. When I build in Release mode, the exception above occurrs. I can't find anything about this error through Google. My suspicion is that some .NET 4 restrictions were introduced with how reflection is done on dynamic assemblies, which is being introduced in this situation as a Release build optimisation.
Any idea anyone?
Looks like you're getting a dynamic assembly being emitted (somehow). Try adding a filter to ignore dynamic assemblies. This should work:
container.Register(Classes.FromThisAssembly().Where(t => !t.Assembly.IsDynamic).BasedOn<IController>().LifestyleTransient());
I have upgraded SharpArchitecture from 1.5 to 1.9.
I have followed the guide here http://blog.sharparchitecture.net/post/Sharp-Architecture-19-released.aspx, and ensured that I have set "copy local = true" for the various DLLs,
but I still receive the following error when running the site:
Exception Details: System.ArrayTypeMismatchException: Attempted to
access an element as a type incompatible with the array.
Source Error:
Line 35: log4net.Config.XmlConfigurator.Configure();
Line 36: ViewEngines.Engines.Clear();
Line 37: ViewEngines.Engines.Add(new AreaViewEngine());
Line 38:
Line 39: ModelBinders.Binders.DefaultBinder = new
SharpModelBinder();
Source File: xxx.Web
\Global.asax.cs Line: 37
Stack Trace:
[ArrayTypeMismatchException: Attempted to access an element as a type
incompatible with the array.]
System.Collections.Generic.List`1.Insert(Int32 index, T item) +62
xxx.Web.MvcApplication.Application_Start() in
[HttpException (0x80004005): Attempted to access an element as a type
incompatible with the array.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context, HttpApplication app) +3988565
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context, MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
MethodInfo[] handlers, IntPtr appContext, HttpContext context) +325
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +375
[HttpException (0x80004005): Attempted to access an element as a type
incompatible with the array.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context)
+11529072
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
+141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +4784373
Does anyone knwo what I might have forgotten?
I have been looking at the versions of SharpArchitecture in the different project several times, but apparently I had missed one project which didn't have the SharpArch DLL set to Specific Version.