Where do I find EF6.0 database mapping files? - c#

I recently renamed my VS2013 Project and am getting the following error page.
Server Error in '/' Application.
Migrations is enabled for context 'ApplicationDbContext' but the
database does not exist or contains no mapped tables. Use Migrations
to create the database and its tables, for example by running the
'Update-Database' command from the Package Manager Console.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Migrations is
enabled for context 'ApplicationDbContext' but the database does not
exist or contains no mapped tables. Use Migrations to create the
database and its tables, for example by running the 'Update-Database'
command from the Package Manager Console.
Source Error:
Line 33: {
Line 34: if(User.Identity.IsAuthenticated)
Line 35: ViewBag.Email = UserManager.FindById(User.Identity.GetUserId()).Email;
Line 36: bll.UpdateLogInStats("Index",User.Identity.GetUserName());
Line 37: ViewBag.versionNumber = bll.GetSiteVersionNumber();
Source File: c:\Users\Evolution\Documents\Visual Studio 2013\Projects\CompleTrance\CompleTrance\Controllers\HomeController.cs Line: 35
Stack Trace:
[InvalidOperationException: Migrations is enabled for context 'ApplicationDbContext' but the database does not exist or contains no mapped tables. Use Migrations to create the database and its tables, for example by running the 'Update-Database' command from the Package Manager Console.]
System.Data.Entity.Internal.MigrationsChecker.IsMigrationsConfigured(InternalContext internalContext, Func1 databaseExists) +147
System.Data.Entity.CreateDatabaseIfNotExists1.InitializeDatabase(TContext context) +193
System.Data.Entity.Internal.<>c_DisplayClasse1.<CreateInitializationAction>b__d() +76
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +60
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +337
System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) +7
System.Data.Entity.Internal.RetryAction1.PerformAction(TInput input) +110
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action1 action) +198
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +27
System.Data.Entity.Internal.Linq.InternalSet1.Initialize() +53
System.Data.Entity.Internal.Linq.InternalSet1.get_InternalContext() +15
System.Data.Entity.Internal.Linq.InternalSet1.FindAsync(CancellationToken cancellationToken, Object[] keyValues) +18
System.Data.Entity.DbSet1.FindAsync(CancellationToken cancellationToken, Object[] keyValues) +34
System.Data.Entity.DbSet1.FindAsync(Object[] keyValues) +13
Microsoft.AspNet.Identity.EntityFramework.EntityStore1.GetByIdAsync(Object id) +49
Microsoft.AspNet.Identity.EntityFramework.UserStore1.FindByIdAsync(String userId) +29
Microsoft.AspNet.Identity.d_a.MoveNext() +102
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
Microsoft.AspNet.Identity.AsyncHelper.RunSync(Func1 func) +159
Microsoft.AspNet.Identity.UserManagerExtensions.FindById(UserManager1 manager, String userId) +157
CompleTranceServer.Controllers.HomeController.Index() in c:\Users\Evolution\Documents\Visual Studio 2013\Projects\CompleTrance\CompleTrance\Controllers\HomeController.cs:35
lambda_method(Closure , ControllerBase , Object[] ) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +157
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +27
System.Web.Mvc.Async.AsyncControllerActionInvoker.b_36(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
System.Web.Mvc.Async.AsyncInvocationWithFilters.b_3c() +50
System.Web.Mvc.Async.<>c_DisplayClass45.b_3e() +225
System.Web.Mvc.Async.<>c_DisplayClass30.b_2f(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c_DisplayClass28.b_19() +26
System.Web.Mvc.Async.<>c_DisplayClass1e.b_1b(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.b_1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.b_15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +28
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.b__4(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514812
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408
I believe the problem is that the db mapping file contains the old project name but I do not see anywhere that I can edit the mapping files to correct the problem. I would rather not delete the database and recreate it and the suggested idea to run "update-database" did not work and gives me the following error.
Cannot create file 'C:\Users\Evolution\Documents\Visual Studio
2013\Projects\CompleTrance\CompleTrance\App_Data\aspnet-CompleTranceServer-20131116015908.mdf'
because it already exists. Change the file path or the file name, and
retry the operation. CREATE DATABASE failed. Some file names listed
could not be created. Check related errors.
Connection strings:
Here are my connection strings.
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-CompleTranceServer-20131116015908.mdf;Initial Catalog=aspnet-CompleTranceServer-20131116015908;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="AWSiteContext" connectionString="Data Source=(localdb)\v11.0; Initial Catalog=AWSiteContext-20140105010431; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|AWSiteContext-20140105010431.mdf" providerName="System.Data.SqlClient" />
</connectionStrings>
I don't recall why I named the context listed AWSiteContext. The old name of my project was AncientWorld, so AW was the initials of the site name. I have my IIS going to defaultConnection though so I'm not sure the AWSiteContext really does anything. It isn't in the project anywhere else.
Any help would be greatly appreciated. Thanks.

Related

Two connection strings in web.config to one SQL DB work in debug but not when published

I am trying to add asp identity to a very basic MVC site currently containing a singular table from a SQL database.
The SQL was added as a ADO.NET Entity Data Model, using EF Designer From Database and I can read and write without issue from my MVC site (both locally in development and after being published).
I then added asp.net identity and this added a local DB file which worked.
I then tried to migrate the identity tables across to my main SQL server so that I only have to maintain the one DB (both the hosting of the website and SQL DB are with the same provider).
I have managed to create the tables in the main SQL DB and have added a second connection string to my web.config to allow both asp identity and my existing edmx setup to work (if I try to run asp identity through the EF connection string I get the error "The entity type ApplicationUser is not part of the model for the current context."). I then removed the local DB files to be sure.
When testing on my client (with two connection strings) I can create accounts, login and out and use asp.identity as expected and can also see the identity tables in the main SQL DB being populated. I can also use my general EF connection for the core MVC site reading and writing of the DB.
However when I publish to the main site no matter if I call an identity or EF DB function I get the error
Error. An error occurred while processing your request.
which is displayed over / inline with the rendered page (I've tried turning on custom errors in the web.config but this doesn't appear to give me more details.)
My two connection strings can be seen below (I'm assuming this is where the problem is?) Do I need anything else in the web.config? Or am I missing something fundamental?
<connectionStrings>
<add name="BDIdentityString" connectionString="Data Source=IPADDRESS; Initial Catalog=DBNAME; User ID=USERNAME; Password=PASSWORD; Connect Timeout=60;" providerName="System.Data.SqlClient" />
<add name="BDString" connectionString="metadata=res://*/Models.DBENTITYNAME.csdl|res://*/Models.DBENTITYNAME.ssdl|res://*/Models.DBENTITYNAME.msl;provider=System.Data.SqlClient;provider connection string="data source=IPADDRESS;initial catalog=DBNAME;user id=USERNAME;password=PASSWORD;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
UPDATE:
So I finally got custom errors to work (think I had a typo somewhere) and the errors are posted below. As a test I used a backup copy of my project to test again the EF DB queries without the introduction of identity - published it and tested it live. Again it all worked as expected. I then restored my current build with identity added and back to the same issue. (the connection string for EF has remained the same in both versions of the project)
For clarity I am using fasthosts.co.uk and in my testing I am doing this by reading and writing to the live SQL DB hosted with fasthosts from my client. As is the backed up version without identity when published to fasthosts is still able to connect and read / write to the SQL DB.
I'm using their Momentum package so have included a machineKey as required generated from a local IIS server I have. This key is present in both version 1 without identity and version 2 with identity.
I have also tried adding the following to AssemblyInfo.cs
[assembly: AllowPartiallyTrustedCallers]
[assembly: SecurityRules(SecurityRuleSet.Level1)]
(AllowPartiallyTrustedCallers being recommended by fasthosts for Security Exception Description type errors)
With the customerErrors off I get two different responses based on if I am calling the DB via identity or calling the DB from my EF calls in my MVC code. The errors are as such:
EF error:
erver Error in '/' Application.
Operation could destabilize the runtime.
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.Security.VerificationException: Operation could destabilize the runtime.
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:
[VerificationException: Operation could destabilize the runtime.]
System.Data.Entity.Core.Metadata.Edm.FacetDescription.Validate(String declaringTypeName) +70
System.Data.Entity.Core.Metadata.Edm.FacetDescription..ctor(String facetName, EdmType facetType, Nullable`1 minValue, Nullable`1 maxValue, Object defaultValue, Boolean isConstant, String declaringTypeName) +103
System.Data.Entity.Core.SchemaObjectModel.FacetDescriptionElement.CreateAndValidateFacetDescription(String declaringTypeName) +115
System.Data.Entity.Core.SchemaObjectModel.TypeElement.ResolveTopLevelNames() +119
System.Data.Entity.Core.SchemaObjectModel.Schema.ResolveTopLevelNames() +206
System.Data.Entity.Core.SchemaObjectModel.Schema.Resolve() +16
System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, AttributeValueNotification providerNotification, AttributeValueNotification providerManifestTokenNotification, ProviderManifestNeeded providerManifestNeeded, IList`1& schemaCollection) +553
System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, DbProviderManifest providerManifest, IList`1& schemaCollection) +156
System.Data.Entity.Core.SchemaObjectModel.SchemaManager.LoadProviderManifest(XmlReader xmlReader, String location, Boolean checkForSystemNamespace, Schema& schema) +139
System.Data.Entity.Core.Common.DbXmlEnabledProviderManifest.Load(XmlReader reader) +75
System.Data.Entity.Core.Common.DbXmlEnabledProviderManifest..ctor(XmlReader reader) +116
System.Data.Entity.SqlServer.SqlProviderManifest..ctor(String manifestToken) +37
System.Data.Entity.SqlServer.<>c.<GetDbProviderManifest>b__29_0(String s) +25
System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +73
System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifest(String versionHint) +124
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifest(String manifestToken) +55
[ProviderIncompatibleException: The provider did not return a ProviderManifest instance.]
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifest(String manifestToken) +186
System.Data.Entity.Core.Metadata.Edm.Loader.InitializeProviderManifest(Action`3 addError) +312
System.Data.Entity.Core.Metadata.Edm.Loader.OnProviderManifestTokenNotification(String token, Action`3 addError) +33
System.Data.Entity.Core.SchemaObjectModel.Schema.HandleProviderManifestTokenAttribute(XmlReader reader) +97
System.Data.Entity.Core.SchemaObjectModel.Schema.HandleAttribute(XmlReader reader) +184
System.Data.Entity.Core.SchemaObjectModel.SchemaElement.ParseAttribute(XmlReader reader) +185
System.Data.Entity.Core.SchemaObjectModel.SchemaElement.Parse(XmlReader reader) +76
System.Data.Entity.Core.SchemaObjectModel.Schema.HandleTopLevelSchemaElement(XmlReader reader) +37
System.Data.Entity.Core.SchemaObjectModel.Schema.InternalParse(XmlReader sourceReader, String sourceLocation) +739
System.Data.Entity.Core.SchemaObjectModel.Schema.Parse(XmlReader sourceReader, String sourceLocation) +58
System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, AttributeValueNotification providerNotification, AttributeValueNotification providerManifestTokenNotification, ProviderManifestNeeded providerManifestNeeded, IList`1& schemaCollection) +340
System.Data.Entity.Core.Metadata.Edm.Loader.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths) +158
System.Data.Entity.Core.Metadata.Edm.Loader..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, Boolean throwOnError, IDbDependencyResolver resolver) +127
System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError, IDbDependencyResolver resolver, DbProviderManifest& providerManifest, DbProviderFactory& providerFactory, String& providerInvariantName, String& providerManifestToken, Memoizer`2& cachedCTypeFunction) +131
System.Data.Entity.Core.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths) +223
System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadStoreCollection(EdmItemCollection edmItemCollection, MetadataArtifactLoader loader) +88
System.Data.Entity.Core.Metadata.Edm.<>c__DisplayClass9_1.<GetMetadataWorkspace>b__1() +14
System.Lazy`1.CreateValue() +429
System.Lazy`1.LazyInitValue() +158
System.Lazy`1.get_Value() +79
System.Data.Entity.Core.Metadata.Edm.<>c__DisplayClass9_1.<GetMetadataWorkspace>b__4() +9
System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.LoadAndCheckItemCollection(Func`1 itemCollectionLoader) +16
System.Data.Entity.Core.Metadata.Edm.<>c__DisplayClass12_0.<.ctor>b__3() +21
System.Lazy`1.CreateValue() +429
System.Lazy`1.LazyInitValue() +158
System.Lazy`1.get_Value() +79
System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace, Boolean required) +95
System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace) +12
System.Data.Entity.Core.Objects.ObjectContext.InitializeMappingViewCacheFactory(DbContext owner) +46
System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory) +575
System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel() +65
System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() +21
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +506
System.Data.Entity.Internal.InternalContext.Initialize() +20
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +16
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +53
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName) +62
System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity) +108
System.Data.Entity.DbSet`1.Add(TEntity entity) +72
HotBrewCrew.Controllers.HomeController.Register(interested_parties fromForm) in C:\Users\ewilson\Documents\Development\HotBrewCrew\HotBrewCrew\Controllers\HomeController.cs:26
lambda_method(Closure , ControllerBase , Object[] ) +100
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +166
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
System.Web.Mvc.Async.<>c__DisplayClass11_0.<InvokeActionMethodFilterAsynchronouslyRecursive>b__0() +58
System.Web.Mvc.Async.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2() +228
System.Web.Mvc.Async.<>c__DisplayClass7_0.<BeginInvokeActionMethodWithFilters>b__1(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__4() +35
System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +11
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +45
System.Web.Mvc.<>c.<BeginExecute>b__151_2(IAsyncResult asyncResult, Controller controller) +13
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +28
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9839161
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +50
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +163
And Identity error
Server Error in '/' Application.
Inheritance security rules violated while overriding member: 'Microsoft.AspNet.Identity.TaskExtensions+CultureAwaiter`1<T>.UnsafeOnCompleted(System.Action)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
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: Inheritance security rules violated while overriding member: 'Microsoft.AspNet.Identity.TaskExtensions+CultureAwaiter`1<T>.UnsafeOnCompleted(System.Action)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.
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:
[TypeLoadException: Inheritance security rules violated while overriding member: 'Microsoft.AspNet.Identity.TaskExtensions+CultureAwaiter`1<T>.UnsafeOnCompleted(System.Action)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.]
Microsoft.AspNet.Identity.Owin.SignInManager`2.PasswordSignInAsync(String userName, String password, Boolean isPersistent, Boolean shouldLockout) +0
HotBrewCrew.Controllers.<Login>d__11.MoveNext() in C:\Users\ewilson\Documents\Development\HotBrewCrew\HotBrewCrew\Controllers\AccountController.cs:74
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +97
System.Web.Mvc.Async.<>c__DisplayClass8_0.<BeginInvokeAsynchronousActionMethod>b__1(IAsyncResult asyncResult) +17
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
System.Web.Mvc.Async.<>c__DisplayClass11_0.<InvokeActionMethodFilterAsynchronouslyRecursive>b__0() +58
System.Web.Mvc.Async.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2() +228
System.Web.Mvc.Async.<>c__DisplayClass7_0.<BeginInvokeActionMethodWithFilters>b__1(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__4() +35
System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +11
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +45
System.Web.Mvc.<>c.<BeginExecute>b__151_2(IAsyncResult asyncResult, Controller controller) +13
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +28
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9839161
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +50
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +163
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.3928.0
Update 2
This could be a trust issue with fasthosts. I've just built a out of the box MVC site with identity enabled. Changed the connection string to point to the SQL DB - again works from development environment (with details registered from main project development testing) but fails when pushed live with no other changes.
I will endeavour to ask the hosting provider but am not 100% convinced this is my only / or actual problem as EF works without identity just not with identity installed in the project.
As expected the limitation was with https://www.fasthosts.co.uk/ - Moving my site with no code changes (other than the SQL connection string to reflect the new SQL server) with provider https://hostinguk.net/ the site worked without issue.

Index was outside the bounds of the array in asp.net mvc connected with oracle database

I am facing an strange issue in asp.net mvc website that is connected with oracle database and deployed on IIS. When I am adding a new field in oracle database table (without changing anything in existing table structure), asp.net website running on IIS throwing exception in the method that is retrieving data from that table.
I am simply adding a new field in oracle database table using Oracle SQL Developer. I can understand that table schema is getting changed in this way, but not able to understand how does its effecting on existing sql query results.
I tried to do same-thing in SQL Server database, but it works perfectly fine.
Below is the code that is displaying data from oracle database. Getting exception at line having code "sda.Fill(dt);"
using Oracle.ManagedDataAccess.Client;
OracleConnection Ocon = null;
string oradb = System.Configuration.ConfigurationManager.ConnectionStrings["OracleDBConnStr"].ConnectionString;
Ocon = new Oracle.ManagedDataAccess.Client.OracleConnection(oradb);
string str = "select * from TABLE_NAME where TRIM(STATUS)!=1 and TRIM(STATUS)!=2";
OracleDataAdapter sda = new OracleDataAdapter(str, Ocon);
DataTable dt = new DataTable();
sda.Fill(dt);
Server Error in '/' Application.
Index was outside the bounds of the array.
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.<br>
Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.<br>
Source Error: <br>
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.<br>
Stack Trace: <br>
[IndexOutOfRangeException: Index was outside the bounds of the array.]
Oracle.ManagedDataAccess.Client.OracleDataReader.GetMinSchemaTable() +3066
Oracle.ManagedDataAccess.Client.OracleDataReader.set_IsFillReader(Boolean value) +102
Oracle.ManagedDataAccess.Client.OracleDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +376
System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +141
TradingAutomationUI.Controllers.OtherAccountTransactionController.getbankTransectionCustom(String Query, String searchPerm) +255
TradingAutomationUI.Controllers.OtherAccountTransactionController.CustomEntriesView(Nullable`1 id) +347
lambda_method(Closure , ControllerBase , Object[] ) +145
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +229
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +35
System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +77
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +72
System.Web.Mvc.Async.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() +387
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +38
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +188
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +43
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
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<br>
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3282.0

System.Globalization.CultureInfo.GetCultures returning null in dev environment (Visual Studio)

First of all, this could very well be a rookie mistake on my part, I'm fairly new to .net and c#.
I'm using the CMS system Umbraco on our latest project, and a recent update has meant the system has started using the System.Globalization.CultureInfo class to deal with localization. This has resulted in multiple "Culture Not Found" errors in the CMS back office that renders it unusable. Here's a stack trace from one of them:
Server Error in '/' Application.
Culture is not supported.
Parameter name: name
.-no is an invalid culture identifier.
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.Globalization.CultureNotFoundException: Culture is not supported.
Parameter name: name
.-no is an invalid culture identifier.
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:
[CultureNotFoundException: Culture is not supported.
Parameter name: name
.-no is an invalid culture identifier.]
System.Globalization.CultureInfo.GetCultureInfo(String name) +12488971
Umbraco.Core.Services.LocalizedTextServiceFileSources.<.ctor>b__0() +573
System.Lazy`1.CreateValue() +180
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +26
System.Lazy`1.get_Value() +12446617
Umbraco.Core.Services.LocalizedTextServiceFileSources.TryConvert2LetterCultureTo4Letter(String twoLetterCulture) +61
Umbraco.Core.Services.LocalizedTextService.ConvertToSupportedCultureWithRegionCode(CultureInfo currentCulture) +110
Umbraco.Core.Services.LocalizedTextService.GetAllStoredValues(CultureInfo culture) +72
Umbraco.Web.Editors.BackOfficeController.LocalizedText(String culture) +123
lambda_method(Closure , ControllerBase , Object[] ) +77
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +157
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9765121
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
I'm still not completely sure where the .-no is coming from, but after some amount of research into this I tried running the following code with a breakpoint inserted:
var locale = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);
This returned null, and doesn't seem to be throwing an exception anywhere. I'm guessing this might be the cause of the errors, judging by the stack trace. Could this be an issue with my local setup? I'm running Windows 10, mainly in a virtualization environment, but it can also run natively via OSX Bootcamp, where the problem still seems to be present. I've also tried using Powershell to output the list of installed cultures, and that works fine.
If it helps, I'm using IISExpress for the web server and the database is running under SQL Server 2016 Express.
Thanks in advance! Let me know if I can supply any extra info to help out with this.
Make use of the fact that Umbraco is open source.
Judging from the stack trace and exception details you have provided, problem is caused by this line:
https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Core/Services/LocalizedTextServiceFileSources.cs#L102
Apparently invalid value .-no is passed into GetCultureInfo method. If you look a bit up in the source code, it seems that this value comes from XML file name or XML file content.
I cannot provide complete solution for your problem, but here are some things to try to pinpoint root cause of it:
1) Clean deployment folder
Do full clean & rebuild cycle
2) Check localization XML files to check if they contain valid cultures
If you have edited files manually, make sure there is no typo there.
3) Compare folders of "fresh" install and your non-working solution folder
Check if update hasn't left behind some XML files from previous versions;

Cant find image in network drive

I know this question have been asking many times but none of then have solved my situation.
I have this simple code
Image f = Image.FromFile(#"\\NetWork\imagenes\folder0\1690D-PC.tif");
But it throws:
System.IO.FileNotFoundException \\NetWork\imagenes\folder0\1690D-PC.tif
I have total access to the related network
I do can find the image in that location. I copy the path, START + r, pasted the path and the image opens.
Is the same for all images in that server.
But the situation not only remains there:
I tested in another pc to checked if is was a IIS problem or
whatever, but when I tested it throws the same(2 pc cannot access to
that file, having they full access... weird...)
When im in development, I can find the image everything work normaly, but when i deploy and
upload to my local iis and the other pc, throw the related exception(FileNotFoundException).
My parner has the same code(almost the same proyect, just with some
diferrent functionality and public) and he can find the image and
display it.
I ran into this situation last friday and i havent came up with a solution yet.
Im willing to hear all your suggestions.
Update 2.
More info:
There are 2 more application that request images from that server and those application can find it normally. Those application are in my local IIS.
Updte
Tracktrace
[FileNotFoundException: \\DAVID-PC\imagenes\folder0\1690D-PC.tif]
System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement) +472351
System.Drawing.Image.FromFile(String filename) +6
Muckup.Controllers.HomeController.Index() in C:\Users\pkm\Documents\Visual Studio 2010\Projects\Muckup\Muckup\Controllers\HomeController.cs:20
lambda_method(Closure , ControllerBase , Object[] ) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +211
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +57
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +223
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514812
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Have you tried using double back slashes instead of # to find the file? Might be worth trying.
Image f = Image.FromFile(" *FullPath* \\NetWork\\imagenes\\folder0\\1690D-PC.tif");

MVC4 OAuth HasLocalAccount method throws InvalidOperationException

I have a MVC4 Application that spends debug process locally without enabling Register External site clients (like twitter , etc...) yet. And I'm Using custom membership user and role providers. But unfortunately when I browse the 'Manage' Page get this error:
Operation is not valid due to the current state of the object.
And the stack trace :
[InvalidOperationException: Operation is not valid due to the current state of the object.]
Microsoft.Web.WebPages.OAuth.OAuthWebSecurity.VerifyProvider() +91
Microsoft.Web.WebPages.OAuth.OAuthWebSecurity.HasLocalAccount(Int32 userId) +41
Melk.Controllers.AccountController.Manage(Nullable1 message) in C:\Users\AmirMehr\documents\visual studio 2010\Projects\Melk\Melk\Controllers\AccountController.cs:141
lambda_method(Closure , ControllerBase , Object[] ) +153
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +211
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 ) +10
System.Web.Mvc.Async.WrappedAsyncResult1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +57
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +223
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.<>c_DisplayClass2a.b_20() +24
System.Web.Mvc.Async.<>c_DisplayClass25.b_22(IAsyncResult asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
System.Web.Mvc.Async.<>c_DisplayClass4.b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629708
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Please help to be aware. Thanks.
VerifyProvider will throw if you are using the SimpleMembershipProvider and it is not yet initialized, or if the provider does not inherit from ExtendedMembershipProvider.
If you are using WebSecurity out of the box, you need to make sure WebSecurity.InitializeDatabaseConnection is called first.
If you are using custom providers, make sure they are inheriting from ExtendedMembershipProvider (or SimpleMembershipProvider), otherwise you cannot use this function.

Categories

Resources