Hi am new ASP.NET MVC. Currently am learning MVCmusicstore tutorial from asp.net official website.But Iam getting error while executing the project after implementing role based authorization in it.The stack trace is given below.Please advice
Stack Trace:
[FileLoadException: Could not load file or assembly 'System.Runtime.DurableInstancing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1136
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +23
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +60
System.Web.Configuration.HttpModulesSection.CreateModules() +221
System.Web.HttpApplication.InitModules() +28
System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +828
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +304
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +327
It looks like you are missing a reference to the following assembly:
System.Runtime.DurableInstancing
Right-click on the project, select "Add Reference" and add this assembly.
Related
i have to change the port of website for ssl proxy implementation but the site is not working when im trying to listen to any other port than 80 (ex:81,82,90,8443, 9443 etc).
The site works fine in port 80, other ports getting below error,
**
Server Error in '/' Application.
**
No parameterless constructor defined for this 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.MissingMethodException: No parameterless constructor defined for this object.
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:
[MissingMethodException: No parameterless constructor defined for this object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +159
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +256
System.Activator.CreateInstance(Type type, Boolean nonPublic) +127
System.Activator.CreateInstance(Type type) +11
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +92
[InvalidOperationException: An error occurred when trying to create a controller of type 'WRIPMS.Controllers.LoginController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +256
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +81
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +280
System.Web.Mvc.<>c__DisplayClass6.b__2() +80
System.Web.Mvc.<>c__DisplayClassb1.<ProcessInApplicationTrust>b__a() +19
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func1 func) +128
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12650919
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
The error indicates that one of your controllers has a constructor that accepts a parameter. This is normal for an application with dependency injection. To make it work, you must create a custom IControllerFactory and inject it at application startup using
ControllerBuilder.Current.SetControllerFactory(new MyControllerFactory());
Since your application is working on port 80, I suspect that you have a controller factory (or a dependency of controller factory) that has something hard coded to work with port 80 only.
Im sorry it was my mistake there was some redundant entries in my web.config like Keys having path to save error log and all. My understanding was it wont make any troubles. It was working in local servers too. Well it got worked when i cleaned web.config redundant entries.
thank you.
I published my web project to Azure and when I pull it up in the browser I see the error below.
I fixed the same error by disabling IntelliTrace, when I published my Web ROLE to windows azure. But I could not find where to disable it in Publish web settings.
http://www.windowsazure.com/media/devcenter/dotnet/dev-net-getting-started-039.png
[VerificationException: Operation could destabilize the runtime.]
FluentValidation.AbstractValidator`1..ctor() in c:\Projects\FluentValidation\src\FluentValidation\AbstractValidator.cs:36
Poll.Areas.Shared.Validators.Account.LogOnValidator..ctor() in D:\Code\Poll\Poll\Areas\Shared\Validators\Account\LogOnValidator.cs:15
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +113
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232
System.Activator.CreateInstance(Type type, Boolean nonPublic) +83
System.Activator.CreateInstance(Type type) +6
FluentValidation.Internal.InstanceCache.GetOrCreateInstance(Type type, Func2 factory) in c:\Projects\FluentValidation\src\FluentValidation\Internal\InstanceCache.cs:58
FluentValidation.Internal.InstanceCache.GetOrCreateInstance(Type type) in c:\Projects\FluentValidation\src\FluentValidation\Internal\InstanceCache.cs:37
FluentValidation.Attributes.AttributedValidatorFactory.GetValidator(Type type) in c:\Projects\FluentValidation\src\FluentValidation\Attributes\AttributedValidatorFactory.cs:48
FluentValidation.Mvc.FluentValidationModelValidatorProvider.GetValidators(ModelMetadata metadata, ControllerContext context) in c:\Projects\FluentValidation\src\FluentValidation.Mvc3\FluentValidationModelValidatorProvider.cs:75
System.Web.Mvc.<>c__DisplayClass7.<GetValidators>b__6(ModelValidatorProvider provider) +21
System.Linq.<SelectManyIterator>d__142.MoveNext() +234
System.Linq.d__142.MoveNext() +397
System.Web.Mvc.HtmlHelper.GetUnobtrusiveValidationAttributes(String name, ModelMetadata metadata) +297
System.Web.Mvc.Html.InputExtensions.InputHelper(HtmlHelper htmlHelper, InputType inputType, ModelMetadata metadata, String name, Object value, Boolean useViewData, Boolean isChecked, Boolean setId, Boolean isExplicitValue, IDictionary2 htmlAttributes) +794
System.Web.Mvc.Html.InputExtensions.HiddenHelper(HtmlHelper htmlHelper, ModelMetadata metadata, Object value, Boolean useViewData, String expression, IDictionary2 htmlAttributes) +124
System.Web.Mvc.Html.InputExtensions.HiddenFor(HtmlHelper1 htmlHelper, Expression1 expression, IDictionary2 htmlAttributes) +90
System.Web.Mvc.Html.InputExtensions.HiddenFor(HtmlHelper1 htmlHelper, Expression1 expression) +54
I fixed this problem by "Enable package manager restore". Right click on solution -> Enable package manager restore
If you think it's IntelliTrace, and you've enabled it, you can disable it by:
Right click on your Cloud Project
Select Publish
Go to Settings
Advanced
(Un)check the "IntelliTrace" checkbox
This dialog is only available when you chose the "Publish" action for the context menu.
You can continue to use IntelliTrace by taking a look at the top of your exception stack and add exception module in advanced settings. Explained here.
Maybe you can give a clue about this error, I have been googling and testing things for hours without result. I am using Mysql and Mysql connector 6.3.5. The error only happens on server, locally everything goes well.
The error:
Method not found:
'System.Data.Objects.ObjectSet`1
MyModelEntities.get_my_aspnet_Users()'.
StackTrace:
[MissingMethodException: Method not
found:
'System.Data.Objects.ObjectSet`1
MyModelEntities.get_my_aspnet_Users()'.]
Utils.GetCurrentUserId() +0
Project.Controllers.ApplicationController..ctor()
+70 Project.Controllers.HomeController..ctor()
+29
[TargetInvocationException: Exception
has been thrown by the target of an
invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType
type, Boolean publicOnly, Boolean
noCheck, Boolean& canBeCached,
RuntimeMethodHandleInternal& ctor,
Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean
publicOnly, Boolean skipCheckThis,
Boolean fillCache) +98
System.RuntimeType.CreateInstanceDefaultCtor(Boolean
publicOnly, Boolean
skipVisibilityChecks, Boolean
skipCheckThis, Boolean fillCache) +241
System.Activator.CreateInstance(Type
type, Boolean nonPublic) +69
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext
requestContext, Type controllerType)
+67
[InvalidOperationException: An error
occurred when trying to create a
controller of type
'Project.Controllers.HomeController'.
Make sure that the controller has a
parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext
requestContext, Type controllerType)
+182 System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext
requestContext, Type controllerType)
+80 System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext
requestContext, String controllerName)
+74 System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase
httpContext, IController& controller,
IControllerFactory& factory) +196
System.Web.Mvc.<>c_DisplayClass6.b_2()
+49 System.Web.Mvc.<>c__DisplayClassb1.<ProcessInApplicationTrust>b__a()
+13 System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action
f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action
action) +22
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func1
func) +124
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase
httpContext, AsyncCallback callback,
Object state) +98
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext
httpContext, AsyncCallback callback,
Object state) +50
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext
context, AsyncCallback cb, Object
extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+8841400 System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)
+184
A little bit more background info on your model would be needed to pinpoint the issue.
If I had to infer with only the stack trace... It seems that in your HomeController constructor there is a call to get_my_aspnet_Users on your model class - MyModelEntities. For some reason the code is not able to find that method.
Is it possible that you somehow have an older version of the model file that does not have the particular method your code is looking for?
Hope this helps.
I'm trying to deploy ASP.NET MVC 3 application wich uses Unity as a IoC container. Application works fine on local server, but when deployed it throws an exception: No parameterless constructor defined for this object. And this is thrown for a controller that should get some repository injected by my Unity DependencyResolver.
I've installed Unity with NuGet so it should be referenced directly, and I've checked that it gets copied to bin folder.
Edit:
Here's the stack trace:
[MissingMethodException: No parameterless constructor defined for this object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +67
[InvalidOperationException: An error occurred when trying to create a controller of type 'nBlog.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +182
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +80
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +196
System.Web.Mvc.<>c__DisplayClass6.<BeginProcessRequest>b__2() +49
System.Web.Mvc.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a() +13
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +124
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +98
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841400
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +18
Anyone have an idea what might be the problem?
Edit 2:
I've solved the problem by adding references to Mvc libraries (System.Web.Mvc, etc.) in GAC instead of direct references.
Previously the application was referencing Mvc libraries directly and they were bin deployed to hosting server, because server had .net 4.0 and mvc 2 installed, but since hosting provider installed Mvc 3, I've changed to references to GAC. I guess it was some security issue, but I'm new to this application security in hosted environments and I would really like to know what exactly was the problem? Resource links would also be appreciated.
If Unity uses Reflection internally to construct classes and dependencies, then you will have an implicit dependency on your application being run in Full Trust.
Many shared hosting providers only allow up to Medium Trust, so it could be that Unity is being prevented from reflecting your code at runtime. You might be able to request that your application be run in Full Trust, but it depends on your hosting provider.
Some similar experiences from Rick Strahl's blog here
[EDIT]
Try testing locally by editing your web.config file:
<location allowOverride="false">
<system.web>
<!-- level="[Full|High|Medium|Low|Minimal]" -->
<trust level="Medium" originUrl=""/>
</system.web>
</location>
I am using ASP.NET MVC Preview 2 that is installed with VS2010 Beta 2. I am hooking up WindsorControllerFactory like so:
Container = new WindsorContainer();
Container.RegisterControllers(typeof(HomeController).Assembly);
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(Container));
My HomeController has one dependency that is passed into the constructor, when running I am getting the following error:
No parameterless constructor defined for this object.
[MissingMethodException: No parameterless constructor defined for
this object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType
type, Boolean publicOnly, Boolean
noCheck, Boolean& canBeCached,
RuntimeMethodHandle& ctor, Boolean&
bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean
publicOnly, Boolean fillCache) +86
System.RuntimeType.CreateInstanceImpl(Boolean
publicOnly, Boolean
skipVisibilityChecks, Boolean
fillCache) +230
System.Activator.CreateInstance(Type
type, Boolean nonPublic) +67
System.Activator.CreateInstance(Type
type) +6
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext
requestContext, Type controllerType)
+522
[InvalidOperationException: An error occurred when trying to create a
controller of type
'Xenotar.WedPlannerPro.Controllers.HomeController'.
Make sure that the controller has a
parameterless public constructor.]
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext
requestContext, Type controllerType)
+659
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext
requestContext, String controllerName)
+198
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase
httpContext) +225
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext
httpContext) +86
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext
httpContext) +36
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+181
System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)
+75
By looking at this stack trace it does not look like MVC is using the WindsorControllerFactory but instead it still uses the DefaultControllerFactory?
When doing this in MVC 1.0 it works.
SOLUTION
The MvcContrib is not compatible with ASP.NET MVC 2.
You should be able to modify MvcContrib to work with ASP.NET MVC 2. The code for controller registration is pretty minimal.