Hangfire: The invoked member is not supported in a dynamic assembly - asp.net-mvc

I'm trying to use Hangfire in my ASP MVC application, I have configured my application as follows:
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseHangfire(config =>
{
config.UseSqlServerStorage("myconnstring");
config.UseServer();
});
}
}
But I'm getting the following error every time I run my app:
[NotSupportedException: The invoked member is not supported in a dynamic assembly.]
System.Reflection.Emit.InternalAssemblyBuilder.get_Location() +56
log4net.Util.SystemInfo.AssemblyLocationInfo(Assembly myAssembly) +88
log4net.Core.DefaultRepositorySelector.GetInfoForAssembly(Assembly assembly, String& repositoryName, Type& repositoryType) +256
log4net.Core.DefaultRepositorySelector.CreateRepository(Assembly repositoryAssembly, Type repositoryType, String repositoryName, Boolean readAssemblyAttributes) +270
log4net.Core.DefaultRepositorySelector.CreateRepository(Assembly repositoryAssembly, Type repositoryType) +58
log4net.Core.DefaultRepositorySelector.GetRepository(Assembly repositoryAssembly) +115
log4net.Core.LoggerManager.GetLogger(Assembly repositoryAssembly, String name) +180
log4net.LogManager.GetLogger(Assembly repositoryAssembly, String name) +50
log4net.LogManager.GetLogger(String name) +55
lambda_method(Closure , String ) +39
Hangfire.Logging.LogProviders.Log4NetLogProvider.GetLogger(String name) +50
Hangfire.Logging.LogProvider.GetLogger(String name) +103
Hangfire.Logging.LogProvider.GetLogger(Type type) +53
Hangfire.SqlServer.SqlServerObjectsInstaller..cctor() +65

Related

System.TypeLoadException with Entity Framework 6

I'm running into following error after i've deploid my website in IIS and try to view the page in the browser.
Could not load type 'DienstbulletinApp.DienstbulletinContext' from
assembly 'DienstbulletinApp'. 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.TypeLoadException: Could not load type
'DienstbulletinApp.DienstbulletinContext' from assembly
'DienstbulletinApp'.
When i run my application in visual studio 2019, i don't have this error.
I have removed the contexts from my webconfig file but nothing seems to be the sollution
<contexts>
<context type="DienstbulletinApp.DAL.DienstbulletinAppContext, DienstbulletinApp, Version=1.0.0.0, Culture=neutral">
<databaseInitializer type="DienstbulletinApp.DAL.DienstbulletinAppInitializer, DienstbulletinApp, Version=1.0.0.0, Culture=neutral" />
</context>
</contexts>
DienstbulletinContext:
public class DienstbulletinAppContext : DbContext
{
public DienstbulletinAppContext() : base("name=DienstbulletinDBConnectionString")
{
Database.SetInitializer(new DienstbulletinAppInitializer());
}
public DbSet<Dienstbulletin> Dienstbulletins { get; set; }
public DbSet<Voertuig> Voertuigen { get; set; }
public DbSet<Opdracht> Opdrachts { get; set; }
public DbSet<DienstbulletinDetail> DienstbulletinDetails { get; set; }
public DbSet<Locatie> Locaties { get; set; }
public DbSet<Gebruiker> Gebruikers { get; set; }
public DbSet<Persoon> Personen { get; set; }
public DbSet<OpdrachtType> OpdrachtTypes { get; set; }
public DbSet<Aandachtspunt> Aandachtspunten { get; set; }
public DbSet<Gsm> Gsms { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Persoon>().ToTable("t_Persoon");
modelBuilder.Entity<Voertuig>().ToTable("t_Voertuig");
modelBuilder.Entity<Gebruiker>().ToTable("t_Gebruiker");
modelBuilder.Entity<OpdrachtType>().ToTable("t_OpdrachtType");
modelBuilder.Entity<Opdracht>().ToTable("t_Opdracht");
modelBuilder.Entity<Dienstbulletin>().ToTable("t_Dienstbulletin");
modelBuilder.Entity<DienstbulletinDetail>().ToTable("t_DienstbulletinDetail");
modelBuilder.Entity<Locatie>().ToTable("t_Locatie");
modelBuilder.Entity<Aandachtspunt>().ToTable("t_Aandachtspunt");
modelBuilder.Entity<Gsm>().ToTable("t_Gsm");
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
}
}
I'm using .Net Framework version 4.0.30319 and ASP.NET 4.7.3535.0
I know that all DLL must be referenced in the solution but the files where i get an error are my own classes of my application.
here's the full error:
[TypeLoadException: Could not load type 'DienstbulletinApp.DienstbulletinAppContext' from assembly 'DienstbulletinApp'.]
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) +95
System.Type.GetType(String typeName, Boolean throwOnError) +63
System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type requiredContextType, String contextTypeName, String initializerTypeName, Boolean isDisabled, Func1 initializerArgs, Func3 exceptionMessage) +46
[InvalidOperationException: Failed to set database initializer of type 'DienstbulletinApp.DienstbulletinAppInitializer, DienstbulletinApp' for DbContext type 'DienstbulletinApp.DienstbulletinAppContext, DienstbulletinApp' specified in the application configuration. Entries should be of the form 'key="DatabaseInitializerForType MyNamespace.MyDbContextClass, MyAssembly" value="MyNamespace.MyInitializerClass, MyAssembly"' or 'key="DatabaseInitializerForType MyNamespace.MyDbContextClass, MyAssembly" value="Disabled"'. Also verify that 'DatabaseInitializerArgumentForType' entries are present for every parameter of the database initializer constructor. See inner exception for details. Consider using the configuration section to set the database initializer (http://go.microsoft.com/fwlink/?LinkID=237468).]
System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type requiredContextType, String contextTypeName, String initializerTypeName, Boolean isDisabled, Func1 initializerArgs, Func3 exceptionMessage) +327
System.Data.Entity.Internal.InitializerConfig.TryGetInitializerFromLegacyConfig(Type contextType) +644
System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type contextType) +39
System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetServiceFactory(Type type, String name) +513
System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) +87
System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetService(Type type, Object key) +187
System.Linq.WhereSelectArrayIterator2.MoveNext() +78
System.Linq.Enumerable.FirstOrDefault(IEnumerable1 source, Func2 predicate) +115
System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver2.GetService(Type type, Object key) +41
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +159
System.Data.Entity.Internal.RetryAction1.PerformAction(TInput input) +171
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action1 action) +269
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +20
System.Data.Entity.Internal.Linq.InternalSet1.Initialize() +69
System.Data.Entity.Internal.Linq.InternalSet1.get_InternalContext() +21
System.Data.Entity.Infrastructure.DbQuery1.System.Linq.IQueryable.get_Provider() +59
System.Linq.Queryable.FirstOrDefault(IQueryable1 source, Expression1 predicate) +61
DienstbulletinApp.Controllers.GebruikerController.Login() in D:\Plastic\Dienstbulletin\Dienstbulletin\Controllers\GebruikerController.cs:24
lambda_method(Closure , ControllerBase , Object[] ) +87
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +35
System.Web.Mvc.Async.<>c.b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39
System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass11_0.<InvokeActionMethodFilterAsynchronouslyRecursive>b__0() +80
System.Web.Mvc.Async.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2() +387
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__4() +50
System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +188
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +26
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +68
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +40
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +68
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +602
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +128
Found the error removing the version and culture=neutral from contexts solved the issue:
<contexts>
<context type="DienstbulletinApp.DAL.DienstbulletinAppContext, DienstbulletinApp">
<databaseInitializer type="DienstbulletinApp.DAL.DienstbulletinAppInitializer, DienstbulletinApp" />
</context>
</contexts>

Unity MVC using SOA and gereric Repository and UnitOfWork

I am trying to put together a project that is based on SOA and uses Gereric Repository and UnitOfWork along with Unity.
My problem is that when the controllers try to initialize I get the following error:
The type String cannot be constructed. You must configure the container to supply this value.
I have the following Unity Configuration:
public static class UnityConfig
{
#region Unity Container
private static Lazy<IUnityContainer> container = new Lazy<IUnityContainer>(() =>
{
var container = new UnityContainer();
RegisterTypes(container);
return container;
});
/// <summary>
/// Gets the configured Unity container.
/// </summary>
public static IUnityContainer GetConfiguredContainer()
{
return container.Value;
}
#endregion
public static void RegisterTypes(IUnityContainer container)
{
// register all your components with the container here
// it is NOT necessary to register your controllers
// e.g. container.RegisterType<ITestService, TestService>();
container.RegisterType<IDataContextAsync, MyDbContext>(new PerRequestLifetimeManager())
.RegisterType<IRepositoryProvider, RepositoryProvider>(
new PerRequestLifetimeManager(),
new InjectionConstructor(new object[] { new RepositoryFactories() })
)
.RegisterType<IUnitOfWorkAsync, UnitOfWork>(new PerRequestLifetimeManager())
.RegisterType<IUnitOfWork, UnitOfWork>(new PerRequestLifetimeManager())
.RegisterType<IRepositoryAsync<ApplicationSetting>, Repository<ApplicationSetting>>()
.RegisterType<IApplicationSettingService, ApplicationSettingService>();
container.RegisterType<IRepositoryProvider, RepositoryProvider>(new InjectionConstructor(container));
}
}
The following Activator
using System.Linq;
using System.Web.Mvc;
using Microsoft.Practices.Unity.Mvc;
using XNETProductQuote.Web;
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(UnityWebActivator), "Start")]
[assembly: WebActivatorEx.ApplicationShutdownMethod(typeof(UnityWebActivator), "Shutdown")]
namespace XNETProductQuote.Web
{
/// <summary>Provides the bootstrapping for integrating Unity with ASP.NET MVC.</summary>
public static class UnityWebActivator
{
/// <summary>Integrates Unity when the application starts.</summary>
public static void Start()
{
var container = UnityConfig.GetConfiguredContainer();
FilterProviders.Providers.Remove(FilterProviders.Providers.OfType<FilterAttributeFilterProvider>().First());
FilterProviders.Providers.Add(new UnityFilterAttributeFilterProvider(container));
DependencyResolver.SetResolver(new UnityDependencyResolver(container));
// TODO: Uncomment if you want to use PerRequestLifetimeManager
Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(UnityPerRequestHttpModule));
}
/// <summary>Disposes the Unity container when the application is shut down.</summary>
public static void Shutdown()
{
var container = UnityConfig.GetConfiguredContainer();
container.Dispose();
}
}
}
My controller that I am trying to load is the following
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using XNETProductQuote.Entities ;
using XNETProductQuote.Entities.Models;
using XNETProductQuote.Service;
namespace XNETProductQuote.Controllers
{
public class ApplicationSettingController : Controller
{
private IApplicationSettingService service;
public ApplicationSettingController(IApplicationSettingService svr)
{
service = svr;
}
//
// GET: /ApplicationSetting/
public ActionResult Index()
{
var applicationSettings = service.GetAll();
return View(applicationSettings);
}
}
As far as I can see the Unityconfig Registers the IApplicationSettingService type that should be used to initialise the controller.
am I missing something else?
UPDATE:
The error I get is
[InvalidOperationException: The type String cannot be constructed. You must configure the container to supply this value.]
Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.GuardTypeIsNonPrimitive(IBuilderContext context) +299
Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.PreBuildUp(IBuilderContext context) +131
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +274
Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlanCreatorPolicy.CreatePlan(IBuilderContext context, NamedTypeBuildKey buildKey) +162
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) +245
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +274
Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) +167
Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context) +101
lambda_method(Closure , IBuilderContext ) +222
Microsoft.Practices.ObjectBuilder2.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context) +71
Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) +42
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) +333
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +274
Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) +167
Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context) +101
lambda_method(Closure , IBuilderContext ) +232
Microsoft.Practices.ObjectBuilder2.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context) +71
Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) +42
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) +333
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +274
Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) +167
Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context) +101
lambda_method(Closure , IBuilderContext ) +222
Microsoft.Practices.ObjectBuilder2.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context) +71
Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) +42
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) +333
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +274
Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) +167
Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context) +101
lambda_method(Closure , IBuilderContext ) +224
Microsoft.Practices.ObjectBuilder2.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context) +71
Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) +42
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) +333
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +274
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) +384
[ResolutionFailedException: Resolution of the dependency failed, type = "XNETProductQuote.Controllers.ApplicationSettingController", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type String cannot be constructed. You must configure the container to supply this value.
-----------------------------------------------
At the time of the exception, the container was:
Resolving XNETProductQuote.Controllers.ApplicationSettingController,(none)
Resolving parameter "svr" of constructor XNETProductQuote.Controllers.ApplicationSettingController(XNETProductQuote.Service.IApplicationSettingService svr)
Resolving XNETProductQuote.Service.ApplicationSettingService,(none) (mapped from XNETProductQuote.Service.IApplicationSettingService, (none))
Resolving parameter "repository" of constructor XNETProductQuote.Service.ApplicationSettingService(Repository.Pattern.Repositories.IRepositoryAsync`1[[XNETProductQuote.Entities.Models.ApplicationSetting, XNETProductQuote.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] repository)
Resolving Repository.Pattern.Ef6.Repository`1[XNETProductQuote.Entities.Models.ApplicationSetting],(none) (mapped from Repository.Pattern.Repositories.IRepositoryAsync`1[XNETProductQuote.Entities.Models.ApplicationSetting], (none))
Resolving parameter "context" of constructor Repository.Pattern.Ef6.Repository`1[[XNETProductQuote.Entities.Models.ApplicationSetting, XNETProductQuote.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]](Repository.Pattern.DataContext.IDataContextAsync context, Repository.Pattern.UnitOfWork.IUnitOfWorkAsync unitOfWork)
Resolving XNETProductQuote.Entities.MyDbContext,(none) (mapped from Repository.Pattern.DataContext.IDataContextAsync, (none))
Resolving parameter "connectionString" of constructor XNETProductQuote.Entities.MyDbContext(System.String connectionString)
Resolving System.String,(none)
]
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) +447
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name, IEnumerable`1 resolverOverrides) +50
Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides) +48
Microsoft.Practices.Unity.UnityContainerExtensions.Resolve(IUnityContainer container, Type t, ResolverOverride[] overrides) +61
Microsoft.Practices.Unity.Mvc.UnityDependencyResolver.GetService(Type serviceType) +142
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +87
[InvalidOperationException: An error occurred when trying to create a controller of type 'XNETProductQuote.Controllers.ApplicationSettingController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +247
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +438
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +226
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +326
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +157
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +88
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +50
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
My Repository class is as follow
public static class ApplicationSettingRepository
{
public static ApplicationSetting GetByID(this IRepository<ApplicationSetting> repository, int applicationSettingId)
{
return repository.Find(applicationSettingId);
}
public static IEnumerable<ApplicationSetting> GetAll(this IRepository<ApplicationSetting> repository)
{
return repository.Queryable().AsEnumerable();
}
}

Calling action method in MVC with $.post and then returning an object for Edit not working

I'm trying to call an action method in an MVC4 application using jQuery. I'm using a button on Edit form shown in fancybox:
<input type="button" value="Approve" id="Approve" />
I'm using a jquery $.post on this button click
$("#Approve").click(function () {
debugger;
var ID = $("#AjaxGrid tbody tr:first").attr("data-pkey");
debugger;
var postParams = { Id: ID }
$.post('#Html.Raw(Url.Action("Approve"))', postParams)
.fail(function () {
alert("error occured while Approving");
});
});
In the controller the following is my action method:
[HttpPost]
public ActionResult Approve(long id)
{
Evaluation evaluation = db.EvaluationRepository.GetByID(id);
evaluation.EvaluationStatusID = Convert.ToInt32(EvaluationStatusType.Approved);
return PartialView(evaluation);
}
But I always get the same result i.e. error occured while Approving
Can any one help me in finding what's wrong?
got this error with F12 on browser
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
and this annoying detail
Server Error in '/' Application.
The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int64' for method 'System.Web.Mvc.ActionResult Approve(Int64)' in 'CubicHRMWeb.Areas.Employees.Controllers.EvaluationController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
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 parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int64' for method 'System.Web.Mvc.ActionResult Approve(Int64)' in 'CubicHRMWeb.Areas.Employees.Controllers.EvaluationController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
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.
Stack Trace:
[ArgumentException: The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int64' for method 'System.Web.Mvc.ActionResult Approve(Int64)' in 'CubicHRMWeb.Areas.Employees.Controllers.EvaluationController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters]
System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo parameterInfo, IDictionary2 parameters, MethodInfo methodInfo) +654635
System.Web.Mvc.<>c__DisplayClass1.<Execute>b__0(ParameterInfo parameterInfo) +18
System.Linq.WhereSelectArrayIterator2.MoveNext() +85
System.Linq.Buffer1..ctor(IEnumerable1 source) +217
System.Linq.Enumerable.ToArray(IEnumerable1 source) +78
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +133
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +27
System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
System.Web.Mvc.Async.<>c__DisplayClass81.b__7(IAsyncResult ) +12
System.Web.Mvc.Async.WrappedAsyncResult1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +50
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +58
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +237
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +12
System.Web.Mvc.Async.WrappedAsyncResult1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50
System.Web.Mvc.Async.<>c_DisplayClass2a.b_20() +24
System.Web.Mvc.Async.<>c_DisplayClass25.b_22(IAsyncResult asyncResult) +126
System.Web.Mvc.Async.WrappedAsyncResult1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +45
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
System.Web.Mvc.Async.WrappedAsyncResult1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +61
System.Web.Mvc.Async.<>c_DisplayClass4.b__3(IAsyncResult ar) +25
System.Web.Mvc.Async.WrappedAsyncResult1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +49
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
System.Web.Mvc.Async.WrappedAsyncResult1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +49
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8862381
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225
HTML:
<input type="button" value="Approve" id="Approve" data-action="#Url.Action("Approve")" />
JS:
Number.tryParseInt = function(value) {
return value.toString().match(/^(\d)/) != null;
}
Number.tryParseFloat = function(value) {
return value.toString().match(/^(\d|\d\.|\.\d)/) != null;
}
$("#Approve").click(function () {
var
id = $("#AjaxGrid tbody tr:first").data('pkey'),
postParams = { id: 0 };
if (!Number.tryParseFloat(id)) {
alert('id "' + id + '" is not a number');
return false;
}
postParams.id = parseInt(id);
$.post($(this).data('action'), postParams)
.done(function(data) {
alert('ok Approving: ' + data.EvaluationStatusID);
})
.fail(function () {
alert('error occured while Approving');
});
return false;
});
C#:
Why you are using ActionResult if not using the return?
[HttpPost]
public JsonResult Approve(long id)
{
Evaluation evaluation = db.EvaluationRepository.GetByID(id);
evaluation.EvaluationStatusID = Convert.ToInt32(EvaluationStatusType.Approved);
return Json(evaluation);
}
Need you a larger number of '2.147.483.647'?, if you continue with the error, try using int:
[HttpPost]
public JsonResult Approve(int id)
{
Evaluation evaluation = db.EvaluationRepository.GetByID(id);
evaluation.EvaluationStatusID = Convert.ToInt32(EvaluationStatusType.Approved);
return Json(evaluation);
}
From your stack trace it appears the id parameter of your AJAX call is null, data-pkey is empty for the selected element.
Without seeing your HTML I can't tell you why this is but you need to look at and change the $("#AjaxGrid tbody tr:first") selector.
I think there is a Circular Refrence Issue
My Model Class
public class Evaluation
{
[Key]
public int ID {get; set;}
public int UserID {get; set;} //whose evaluation is due
public DateTime EvaluationDueOn {get; set;}
public DateTime EvaluatedOn {get; set;}
public decimal evaluationAmount {get; set;}
public string comments {get; set;}
public string ApproverID {get; set;} //(userid of staff doing approval)
public int EvaluationStatusID { get; set; }
public virtual Users EvaluatedUser { get; set; }
public virtual Users ApprovingUser { get; set; }
}
uses Navigational properties like
public virtual Users EvaluatedUser { get; set;
public virtual Users ApprovingUser { get; set; }
and Serialization problem occurs due to this Circular Refrence

asp.net mvc A network-related or instance-specific error occurred

I'm trying to set up a asp.net mvc with portable areas (in seperate projects) and a generic repository.
I use a IContext interface to generate the database for each context that implements that interface:
public class Context : DbContext
{
public List<IContext> Contexts {get;set;}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
foreach (IContext context in Contexts)
context.Setup(modelBuilder);
}
}
and the implementation of IContext:
public class TaskListContext : Context, IContext
{
public DbSet<Task> Tasks { get; set; }
void IContext.Setup(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Task>().ToTable("Tasks");
modelBuilder.Entity<Task>().HasKey(task => task.Id);
}
}
When I run this code:
Context context = new Context();
context.Contexts = new List<IContext>();
context.Contexts.Add(new ModuleContext());
String assemblyPath = ControllerContext.HttpContext.Server.MapPath(String.Format("~/bin/{0}", "TaskList.dll")); //it is in a seperate project.
Assembly assembly = Assembly.LoadFrom(assemblyPath);
var contexts = from t in assembly.GetExportedTypes()
where typeof(IContext).IsAssignableFrom(t)
select t;
foreach (Type t in contexts)
{
IContext cont = (IContext)Activator.CreateInstance(t);
context.Contexts.Add(cont);
}
context.Database.CreateIfNotExists();
The database and the tables are created as expected.
But when I want to query the db with a repository pattern I get an error.
The query:
TaskListRepository Rep = new TaskListRepository();
var task = Rep.FindBy(t => t.Id==2);
The repository:
public class TaskListRepository : GenericRepository<TaskListContext, Task>, ITaskListRepository
{
}
The abstract repository:
public abstract class GenericRepository<C, T> :
IGenericRepository<T>
where T : class
where C : DbContext, new()
{
private C _entities = new C();
public C ConcreteContext
{
get { return _entities; }
set { _entities = value; }
}
public virtual IQueryable<T> GetAll()
{
IQueryable<T> query = _entities.Set<T>();
return query;
}
public IQueryable<T> FindBy(System.Linq.Expressions.Expression<Func<T, bool>> predicate)
{
IQueryable<T> query = _entities.Set<T>().Where(predicate);
return query;
}
public virtual void Add(T entity)
{
_entities.Set<T>().Add(entity);
}
public virtual void Delete(T entity)
{
_entities.Set<T>().Remove(entity);
}
public virtual void Edit(T entity)
{
_entities.Entry(entity).State = System.Data.EntityState.Modified;
}
public virtual void Save()
{
_entities.SaveChanges();
}
}
Then I get this error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Stack Trace:
[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +6351920
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +412
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +6366506
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +180
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +6366917
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +6366793
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +352
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +831
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +49
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +6368598
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +78
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +2194
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +89
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +6372110
System.Data.SqlClient.SqlConnection.Open() +300
System.Data.SqlClient.SqlProviderServices.UsingConnection(SqlConnection sqlConnection, Action`1 act) +132
System.Data.SqlClient.SqlProviderServices.UsingMasterConnection(SqlConnection sqlConnection, Action`1 act) +3981391
System.Data.SqlClient.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +10513049
System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +44
[ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.]
System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +11121429
System.Data.Entity.ModelConfiguration.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +94
[ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.]
System.Data.Entity.ModelConfiguration.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +357
System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) +108
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +118
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +237
System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +279
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +888
System.Data.Entity.Internal.InternalContext.Initialize() +50
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +45
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +151
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +50
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +140
System.Linq.Queryable.Where(IQueryable`1 source, Expression`1 predicate) +135
MonackFr.Repository.GenericRepository`2.FindBy(Expression`1 predicate) in D:\code\MonackFr\MonackFr\MonackFr.Library\Repository\GenericRepository.cs:34
MonackFr.Mvc.Areas.TaskList.Controllers.TaskController.Index() in D:\code\MonackFr\MonackFr\MonackFr.Mvc\MonackFr.Mvc\Areas\TaskList\Controllers\TaskController.cs:18
lambda_method(Closure , ControllerBase , Object[] ) +113
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +261
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +34
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +129
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +954935
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +15
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +33
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +955452
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +67
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +53
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__4(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +20
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
Connection String:
<connectionStrings>
<add name="Context" providerName="System.Data.SqlClient" connectionString="Data Source=localhost;Initial Catalog=monackfr;User Id=sa;Password=*******" />
</connectionStrings>
I really don't see it anymore? Does anyone know what's going wrong? The connectionstring should be correct: it is making the database and tables.
Regards,
Willem
EF has a lots of useful conventions. One of them is that EF tries to find out the connection string automatically.
If you haven't specify otherwise and there is no connection string in your config file EF will creates one with the DB name based on the DbContext type's name.
So when you use Context it can find your connection string with name="Context" in your config. But when you use TaskListContext it could not find a connection string with name='TaskListContext' so it will geneate a connection string for you which will result in the exception what you get.
To avoid this you can add a new connection string with the name='TaskListContext' in your app/web.config
Or you can use one of the DbContext contructor overloads to specify the connection excplicitly. With your current design it should look like this:
public class Context : DbContext
{
public Context()
{
}
public Context(string nameOrConnectionString) : base(nameOrConnectionString)
{
}
//.. rest of Context
}
public class TaskListContext : Context, IContext
{
public TaskListContext() : base("Context")
{
}
//.. rest of TaskListContext
}
With this modification in all the IContext derived types EF will use the same connection string named "Context" from your config file for every DbContext.

PathTooLongException after migrating from ASP.NET MVC 1 to ASP.NET MVC 2

I had updated my app from MVC 1 to MVC 2. After that some pages throws PathTooLongException:
[PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.]
System.IO.Path.SafeSetStackPointerValue(Char* buffer, Int32 index, Char value) +7493057
System.IO.Path.NormalizePathFast(String path, Boolean fullCheck) +387
System.IO.Path.NormalizePath(String path, Boolean fullCheck) +36
System.IO.Path.GetFullPathInternal(String path) +21
System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath) +73
System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath) +278
System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) +87
System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path) +65
System.Web.InternalSecurityPermissions.PathDiscovery(String path) +29
System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping) +146
System.Web.HttpRequest.MapPath(VirtualPath virtualPath) +37
System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) +43
System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +28
System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +22
System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext) +284
System.Web.Mvc.WebFormView.RenderViewPage(ViewContext context, ViewPage page) +82
System.Web.Mvc.WebFormView.Render(ViewContext viewContext, TextWriter writer) +85
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +267
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +10
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +320
System.Web.Mvc.Controller.ExecuteCore() +104
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +36
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +53
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +30
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8678910
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
I know the issue with 260-character-url-lenght in ASP.NET, but my app works fine before update to ASP.NET MVC 2.0!
This problem occurs not only locally but on a remote hosting too
I compare RenderView method implementations.
MVC 1:
public virtual void RenderView(ViewContext viewContext) {
ViewContext = viewContext;
InitHelpers();
// Tracing requires Page IDs to be unique.
ID = Guid.NewGuid().ToString();
ProcessRequest(HttpContext.Current);
}
MVC 2:
public virtual void RenderView(ViewContext viewContext) {
ViewContext = viewContext;
InitHelpers();
bool needServerExecute = false;
SwitchWriter switchWriter = viewContext.HttpContext.Response.Output as SwitchWriter;
if (switchWriter == null) {
switchWriter = new SwitchWriter();
needServerExecute = true;
}
using (switchWriter.Scope(viewContext.Writer)) {
if (needServerExecute) {
// It's safe to reset the _nextId within a Server.Execute() since it pushes a new TraceContext onto
// the stack, so there won't be an ID conflict.
int originalNextId = _nextId;
try {
_nextId = 0;
viewContext.HttpContext.Server.Execute(HttpHandlerUtil.WrapForServerExecute(this), switchWriter, true /* preserveForm */);
}
finally {
// Restore the original _nextId in case this isn't actually the outermost view, since resetting
// the _nextId may now cause trace ID conflicts in the outer view.
_nextId = originalNextId;
}
}
else {
ProcessRequest(HttpContext.Current);
}
}
}
This is more of an ASP.NET 4.0 default limit rather than ASP.NET MVC 1.0 to 2.0 migration issue. Try increasing this limit in web.config:
<httpRuntime maxUrlLength="1000" relaxedUrlToFileSystemMapping="true" />
Problem is solved. It was caused by Spring.NET. WebApplicationContext works correctly with ASP.NET MVC 1.0. But couple WebApplicationContext + ASP.NET MVC 2.0 causes PathTooLongException. Now i just switch to XmlApplicationContext and all pages renders without errors.

Resources