Illegal characters in path. while bundles javascript files - asp.net-mvc

I am trying to bundlesup my javascrip files and css files to My MVC project. It is throwing exception while adding them.
Illegal characters in path.
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.ArgumentException: Illegal characters in path.
Source Error:
Line 9: public static void RegisterBundles(BundleCollection bundles)
Line 10: {
Line 11: bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js",
Line 12: "~/js/bootstrap.js",
Line 13: "~/js/jquery.flexslider-min.js",
"~/js/jquery.isotope.js",
"~/js/jquery.fancybox.pack.js?v=2.1.0",
"~/rs-plugin/js/jquery.themepunch.plugins.min.js",
"~/rs-plugin/js/jquery.themepunch.revolution.min.js",
"~/js/revolution.custom.js",
"~/js/custom.js"
));
Stack Trace:
[ArgumentException: Illegal characters in path.]
System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) +10631190
System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(String[] str) +30
System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) +97
System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path) +63
System.Web.InternalSecurityPermissions.PathDiscovery(String path) +29
System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping) +149
System.Web.HttpServerUtility.MapPath(String path) +104
System.Web.Optimization.BundleTable.<get_MapPathMethod>b__0(String virtualPath) +67
System.Web.Optimization.ItemRegistry.Include(String[] virtualPaths) +644
System.Web.Optimization.Bundle.Include(String[] virtualPaths) +64
IntensifyTech.IntensifyTechConfig.RegisterBundles(BundleCollection bundles) in c:\Users\sxxx\SkyDrive\Trunk\IntensifyTech\IntensifyTech\App_Start\IntensifyTechConfig.cs:11
IntensifyTech.MvcApplication.Application_Start() in c:\Users\sxxxx\SkyDrive\Trunk\IntensifyTech\IntensifyTech\Global.asax.cs:24
[HttpException (0x80004005): Illegal characters in path.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9859725
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
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): Illegal characters in path.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Yep, its definitely this item: "~/js/jquery.fancybox.pack.js?v=2.1.0". This is a virtual path, not a url, so '?' characters are illegal in this context.

Related

Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies

I have just tried to install Glimpse.MVC5 via Nuget.
After doing that I cannot run my application.
The error says that the assembly Glimpse.AspNet cannot be loaded, but I found that the dll at C:\Users\xxx\Documents\Visual Studio 2013\Projects\yyy\zzz\packages\Glimpse.AspNet.1.8.0\lib\net45\Glimpse.AspNet.dll does exist.
The error in full is;
Server Error in '/' Application.
Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies. The system cannot find the file specified.
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.IO.FileNotFoundException: Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies. The system cannot find the file specified.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Glimpse.AspNet' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = Glimpse.AspNet
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Glimpse.AspNet | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/xxx/Documents/Visual Studio 2013/Projects/yyy/zzz/zzz.yzyzyz/
LOG: Initial PrivatePath = C:\Users\xxx\Documents\Visual Studio 2013\Projects\yyy\zzz\zzz.yzyzyz\bin
Calling assembly : (Unknown).
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\xxx\Documents\Visual Studio 2013\Projects\yyy\zzz\zzz.yzyzyz\web.config
LOG: Using host configuration file: C:\Users\xxx\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/fec53fa6/71c52709/Glimpse.AspNet.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/fec53fa6/71c52709/Glimpse.AspNet/Glimpse.AspNet.DLL.
LOG: Attempting download of new URL file:///C:/Users/xxx/Documents/Visual Studio 2013/Projects/yyy/zzz/zzz.yzyzyz/bin/Glimpse.AspNet.DLL.
LOG: Attempting download of new URL file:///C:/Users/xxx/Documents/Visual Studio 2013/Projects/yyy/zzz/zzz.yzyzyz/bin/Glimpse.AspNet/Glimpse.AspNet.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/fec53fa6/71c52709/Glimpse.AspNet.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/fec53fa6/71c52709/Glimpse.AspNet/Glimpse.AspNet.EXE.
LOG: Attempting download of new URL file:///C:/Users/xxx/Documents/Visual Studio 2013/Projects/yyy/zzz/zzz.yzyzyz/bin/Glimpse.AspNet.EXE.
LOG: Attempting download of new URL file:///C:/Users/xxx/Documents/Visual Studio 2013/Projects/yyy/zzz/zzz.yzyzyz/bin/Glimpse.AspNet/Glimpse.AspNet.EXE.
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies. The system cannot find the file specified.]
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +70
System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +39
System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +37
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +65
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +38
[ConfigurationErrorsException: Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies. The system cannot find the file specified.]
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +348
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) +19
System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +39
System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +42
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +158
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +950
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +82
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): Could not load file or assembly 'Glimpse.AspNet' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9931916
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34248
I found what the problem was.
After I created a new project to my application, the project I loaded Glimpse into was not building, and that is why there was a problem. When I build the project individually it works. I need to sort out my builds

Server Error in '/' Application when publish to Azure

I have copied the source code from one of my previous NopCommerce websites, copied and renamed the database on Azure and updated the settings.txt file to point to the new database. The only other changes are to the css.
When I run the new site on localhost it works perfect without a hitch but, when i publish from VS to Azure and then browse to the URL i get an error - Server Error in '/' Application. For the life of me I cannot figure this one out and wondering if any one else has experienced this.
I'm using Nop 3.5
My intuition tells me there is something wrong with my connection string, however, why would is work on localhost but not when published?...
Below is the exception details and the stack trace
Thanks in advance for any help
Server Error in '/' Application.
The argument 'nameOrConnectionString' cannot be null, empty or contain only white space.
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.ArgumentException: The argument 'nameOrConnectionString' cannot be null, empty or contain only white space.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
Add a "Debug=true" directive at the top of the file that generated the error. Example:
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
[ArgumentException: The argument 'nameOrConnectionString' cannot be null, empty or contain only white space.]
System.Data.Entity.Utilities.Check.NotEmpty(String value, String parameterName) +61
System.Data.Entity.DbContext..ctor(String nameOrConnectionString) +22
Nop.Web.Framework.<>c__DisplayClass15.<Register>b__9(IComponentContext c) +42
Autofac.<>c__DisplayClass10`1.<Register>b__f(IComponentContext c, IEnumerable`1 p) +10
Autofac.Builder.<>c__DisplayClass1`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p) +14
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +32
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +31
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +185
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +31
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +185
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +31
Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +94
Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +185
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +74
Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) +54
Autofac.ResolutionExtensions.Resolve(IComponentContext context, IEnumerable`1 parameters) +118
Nop.Web.Framework.SettingsSource.<BuildRegistration>b__5(IComponentContext c, IEnumerable`1 p) +35
Autofac.Builder.<>c__DisplayClass1`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p) +14
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +32
Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
Autofac.Core.Resolving.InstanceLookup.Execute() +132
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +44
[DependencyResolutionException: An exception was thrown while executing a resolve operation. See the InnerException for details. ---> The argument 'nameOrConnectionString' cannot be null, empty or contain only white space. (See inner exception for details.)]
Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +112
Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +108
Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +74
Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) +54
Autofac.ResolutionExtensions.Resolve(IComponentContext context, IEnumerable`1 parameters) +118
Autofac.ResolutionExtensions.Resolve(IComponentContext context) +46
Nop.Core.Infrastructure.DependencyManagement.ContainerManager.Resolve(String key, ILifetimeScope scope) +89
Nop.Core.Infrastructure.NopEngine.Resolve() +55
FoxNetSoft.Plugin.Misc.RFQ2.UpdateStartUpTask.Execute() +34
Nop.Core.Infrastructure.NopEngine.RunStartupTasks() +477
Nop.Core.Infrastructure.NopEngine.Initialize(NopConfig config) +36
Nop.Core.Infrastructure.EngineContext.Initialize(Boolean forceRecreate) +92
Nop.Web.MvcApplication.Application_Start() +30
[HttpException (0x80004005): An exception was thrown while executing a resolve operation. See the InnerException for details. ---> The argument 'nameOrConnectionString' cannot be null, empty or contain only white space. (See inner exception for details.)]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9916673
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
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): An exception was thrown while executing a resolve operation. See the InnerException for details. ---> The argument 'nameOrConnectionString' cannot be null, empty or contain only white space. (See inner exception for details.)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.36215
UPDATE
From the links in my comment I think I need to define the connection string in the below?? from NopObjectContext.cs
namespace Nop.Data
{
/// <summary>
/// Object context
/// </summary>
public class NopObjectContext : DbContext, IDbContext
{
#region Ctor
public NopObjectContext(string nameOrConnectionString)
: base(nameOrConnectionString)
{
//((IObjectContextAdapter) this).ObjectContext.ContextOptions.LazyLoadingEnabled = true;
}
}
}
In NopCommerce the connection string is set in a file called Settings.txt which is in your Presnetation\Nop.Web\App_Data folder. However it's not part of the solution so does not get deployed. You can either:
Manually publish that file.
Add the file to your Nop.Web project and deploy it.
Okay so here is what i found.
The statement of the DNS_PROBE_FINISHED_NXDOMAIN error if settings.txt is present in App_Data if 100% correct. The problem is the URL Azure provides http://yourwebsite.azurewebsites.net/ does not work, and its not until the custom domains are hooked up and used to navigate to the website that the site runs as expected.

Error in MVC4-RC (.net 4.0) with Microsoft ASP.NET Web Optimization Framework

I'm using latest MVC4-RC (.net 4.0) with Microsoft ASP.NET Web Optimization Framework http://nuget.org/packages/Microsoft.AspNet.Web.Optimization/1.0.0-beta3 and I'm receiving this error.
Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.
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.MissingMethodException: Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.
[MissingMethodException: Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.]
App.MVC.BundleConfig.RegisterBundles(BundleCollection bundles) in C:...\App_Start\BundleConfig.cs:53
App.MVC.MvcApplication.Application_Start() in C:...\Global.asax.cs:47
[HttpException (0x80004005): Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +4057141
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +352
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375
[HttpException (0x80004005): Method not found: 'Void System.Web.Optimization.Bundle..ctor(System.String, System.Web.Optimization.IBundleTransform[])'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700896
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4869125
This the code I'm using:
in global.asax.cs
protected void Application_Start()
{
...
BundleConfig.RegisterBundles(BundleTable.Bundles);
...
and then in App_Start/BundleConfig.cs
using System.Web.Optimization;
namespace App.MVC.App_Start
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new Bundle("~/scripts/packed.js", new JsMinify()).Include(
// jquery
"~/Scripts/jquery-1.7.1.js",
"~/Scripts/jquery-ui-1.8.17.js",
"~/Scripts/jquery.validate.js",
"~/Scripts/jquery.validate.unobtrusive.js",
"~/Scripts/jquery.unobtrusive-ajax.js"));
bundles.Add(new Bundle("~/content/css/packed.css", new CssMinify()).Include(
// reset
"~/Content/css/cssreset-min.css",
"~/Content/css/cssfonts-min.css",
// themes
"~/Content/themes/base/jquery-ui-1.8.16.custom.css",
// site
"~/Content/css/Site.css"));
}
}
}
I'm also using Azure with this project and funny this is, first time when I start Azure, I get this error. Then when I just rebuild MVC project and refresh page, it works.
How would I approach solving this?
I received the same error when I referenced the wrong package
via
Install-Package Microsoft.Web.Optimization -Version 1.0.0-beta -Pre
resolved by referencing correct newer package
Install-Package Microsoft.Web.Optimization -Pre

DynamicData RegisterContext error using multiple edmx

Before posting this I made sure to read all suggestion made from SO.
The application currently has two projects one for the web application and one for the Entity Frame work (version 4.0). We are trying a tool from RSSBus for the Quickbooks Provider description here
Setting it up was easy enough. I prefixed QB on all the entities and generated the QB.tt file, no issues. Both edmx files are housed in the same project using a shared namespace (SMR.Model)
When I rebuilt the project to run it the global.asax.cs file threw an error:
DefaultModel.RegisterContext(typeof(SMR.Model.SMREntities),
new ContextConfiguration() { ScaffoldAllTables = true });
The error given was:
The given key was not present in the dictionary.
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.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
Source Error:
Line 36: public static void RegisterRoutes(RouteCollection routes)
Line 37: {
Line 38: DefaultModel.RegisterContext(typeof(SMR.Model.SMREntities),
Line 39: new ContextConfiguration() { ScaffoldAllTables = true });
Line 40:
Source File: C:\all\src\smr\smr.pl.Web\Global.asax.cs Line: 38
Stack Trace:
[KeyNotFoundException: The given key was not present in the dictionary.]
System.Collections.Generic.Dictionary2.get_Item(TKey key) +9624829
System.Web.DynamicData.ModelProviders.EFDataModelProvider..ctor(Object contextInstance, Func1 contextFactory) +800
System.Web.DynamicData.ModelProviders.SchemaCreator.CreateDataModel(Object contextInstance, Func1 contextFactory) +126
System.Web.DynamicData.MetaModel.RegisterContext(Func1 contextFactory, ContextConfiguration configuration) +378
System.Web.DynamicData.MetaModel.RegisterContext(Type contextType, ContextConfiguration configuration) +88
smr.pl.Web.Global.RegisterRoutes(RouteCollection routes) in C:\all\src\smr\smr.pl.Web\Global.asax.cs:38
smr.pl.Web.Global.Application_Start(Object sender, EventArgs e) in C:\all\src\smr\smr.pl.Web\Global.asax.cs:91
[HttpException (0x80004005): The given key was not present in the dictionary.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9170941
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 given key was not present in the dictionary.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090044
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
With so little to go on as to what could eb the problem I looked at the .config files to see if they were wrong and all checked out as ok.
<add name="SMREntities" connectionString="metadata=res://*/;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=SMR;Persist Security Info=True;User ID=sa;Password=XXX;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
<add name="RSSQBEntities" connectionString="metadata=res://*/Model.QBOE.csdl|res://*/Model.QBOE.ssdl|res://*/Model.QBOE.msl;provider=System.Data.RSSBus.QuickBooks;provider connection string="Offline=False;Application Id=987654321;Connection Ticket=TGT-000-T_xxxxxxxxxxxxxxxxxxxx;Online Login=ohno"" providerName="System.Data.EntityClient" />
Any thoughts as to what is causing the structure to fail like this?
I finally figured out the "real" problem. I first seperated the two models into separate projects. The problem I was facing was the metadata was being integrated into the same assembly namespace. I resolved my issue by updating the res://*/ section
<add name="SMREntities" connectionString="metadata=res://SMR.Model/;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=SMR;Persist Security Info=True;User ID=sa;Password=XXX;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
<add name="RSSQBEntities" connectionString="metadata=res://SMR.QBOE/Model.RSSQBOE.csdl|res://SMR.QBOE/Model.RSSQBOE.ssdl|res://SMR.QBOE/Model.RSSQBOE.msl;provider=System.Data.RSSBus.QuickBooks;provider connection string="Offline=False;Application Id=987654321;Connection Ticket=TGT-000-T_xxxxxxxxxxxxxxxxxxxx;Online Login=ohno"" providerName="System.Data.EntityClient" />
A Classic "the issue is not the issue".

NullReferenceException on RouteTable.Routes

My ASP.NET MVC 3 web project was working fine, then I recompiled it and now I'm getting this error (some paths and namespaces changed to protect the innocent):
Object reference not set to an
instance of an object. 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.NullReferenceException: Object
reference not set to an instance of an
object.
Source Error:
Line 66:
RouteTable.Routes.MapRoute( Line 67:
"DefaultRoutes", // Route name Line
68:
"{module}/{controller}/{action}/{id}",
// URL with parameters
Source File: ....\Global.asax.cs
Line: 66
Stack Trace:
[NullReferenceException: Object
reference not set to an instance of an
object.]
Project.MvcApplication.RegisterRoutes(RouteCollection
routes) in D:.....\Global.asax.cs:66
Project.MvcApplication.Application_Start()
in D:.....\Global.asax.cs:139
[HttpException (0x80004005): Object
reference not set to an instance of an
object.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context, HttpApplication app) +4051717
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext, HttpContext context,
MethodInfo[] handlers) +191
System.Web.HttpApplication.InitSpecial(HttpApplicationState
state, MethodInfo[] handlers, IntPtr
appContext, HttpContext context) +352
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +407
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +375
[HttpException (0x80004005): Object
reference not set to an instance of an
object.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext
context) +11642112
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext
context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +4865877
I'm using IIS7.5 on Windows 7 x64, and the app pool is configured to run with .NET 4 and the 'Integrated' managed pipeline.
I've tried rebooting, and also cleaning out the bin and obj folders with no success.
Some extra information that turns out to be important - the line missing from the error page above:
RouteTable.Routes.MapRoute(
"DefaultRoutes", // Route name
"{module}/{controller}/{action}/{id}", // URL with parameters
new { module = _loadedModules.FirstOrDefault().Name, controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
In your global.asax.cs you can write like this
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(....);//you should use routes parameter rather than RouteTable.Routes
}
This project dynamically loads modules and what wasn't clear from the original ASP.NET error page was that the NullReferenceException was being caused by the final line of the MapRoute() method call.
It turns out that _loadedModules was empty, so FirstOrDefault() was returning null - hence the exception.

Resources