System.ArgumentException: Duplicate type name within an assembly - asp.net-mvc-3

I am working on an ASP.Net MVC 3 web application using EF 4.1. Since today, I am getting this error:
System.ArgumentException: Duplicate type name within an assembly
and I can't figure out what is causing it. It is happening in my repository when performing a Find:
public virtual T GetById(long id)
{
return dbset.Find(id);
}
Here is the stack trace:
[ArgumentException: Duplicate type name within an assembly.]
System.Reflection.Emit.ModuleBuilder.CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType) +9544354
System.Reflection.Emit.AssemblyBuilderData.CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType) +53
System.Reflection.Emit.TypeBuilder.Init(String fullname, TypeAttributes attr, Type parent, Type[] interfaces, Module module, PackingSize iPackingSize, Int32 iTypeSize, TypeBuilder enclosingType) +178
System.Reflection.Emit.ModuleBuilder.DefineType(String name, TypeAttributes attr, Type parent, Type[] interfaces) +118
System.Data.Objects.Internal.ProxyTypeBuilder.get_TypeBuilder() +299
System.Data.Objects.Internal.ProxyTypeBuilder.CreateType(ModuleBuilder moduleBuilder) +227
System.Data.Objects.Internal.EntityProxyFactory.BuildType(ModuleBuilder moduleBuilder, ClrEntityType ospaceEntityType) +63
System.Data.Objects.Internal.EntityProxyFactory.TryCreateProxyType(EntityType ospaceEntityType) +193
System.Data.Objects.Internal.EntityProxyFactory.GetProxyType(ClrEntityType ospaceEntityType) +104
System.Data.Common.Internal.Materialization.Translator.Visit(EntityColumnMap columnMap, TranslatorArg arg) +178
System.Data.Query.InternalTrees.EntityColumnMap.Accept(ColumnMapVisitorWithResults`2 visitor, TArgType arg) +16
System.Data.Common.Internal.Materialization.Translator.ProcessCollectionColumnMap(CollectionColumnMap columnMap, TranslatorArg arg, ColumnMap discriminatorColumnMap, Object discriminatorValue) +116
System.Data.Common.Internal.Materialization.Translator.Visit(SimpleCollectionColumnMap columnMap, TranslatorArg arg) +13
System.Data.Query.InternalTrees.SimpleCollectionColumnMap.Accept(ColumnMapVisitorWithResults`2 visitor, TArgType arg) +17
System.Data.Common.Internal.Materialization.Translator.TranslateColumnMap(QueryCacheManager queryCacheManager, ColumnMap columnMap, MetadataWorkspace workspace, SpanIndex spanIndex, MergeOption mergeOption, Boolean valueLayer) +314
System.Data.Common.Internal.Materialization.TypedShaperFactoryCreator`1.TypedCreate(QueryCacheManager cacheManager, ColumnMap columnMap, MetadataWorkspace metadata, SpanIndex spanInfo, MergeOption mergeOption, Boolean valueLayer) +64
System.Data.Common.Internal.Materialization.ShaperFactory.Create(Type elementType, QueryCacheManager cacheManager, ColumnMap columnMap, MetadataWorkspace metadata, SpanIndex spanInfo, MergeOption mergeOption, Boolean valueLayer) +185
System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Span span, ReadOnlyCollection`1 compiledQueryParameters) +285
System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption) +696
System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +149
System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +44
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +184
System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__2(IEnumerable`1 sequence) +41
System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle(IEnumerable`1 query, Expression queryRoot) +59
System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +150
System.Linq.Queryable.SingleOrDefault(IQueryable`1 source) +265
System.Data.Entity.Internal.Linq.InternalSet`1.FindInStore(WrappedEntityKey key, String keyValuesParamName) +602
System.Data.Entity.Internal.Linq.InternalSet`1.Find(Object[] keyValues) +124
System.Data.Entity.DbSet`1.Find(Object[] keyValues) +12
XXXXXXXX.Data.Infrastructure.RepositoryBase`1.GetById(Int64 id) in C:\XXXXXXXX\XXXXXXXX\XXXXXXXX.Data\Infrastructure\RepositoryBase.cs:58
MatchesHorsConcours.Service.MatchService.GetMatch(Int32 id) in C:\XXXXXXXX\XXXXXXXX\XXXXXXXX.Service\XxxService.cs:55
XXXXXXXX.Controllers.XXXXXXXX.Edit(Int32 id) in C:\XXXXXXXX\XXXXXXXX\XXXXXXXX.Web\Controllers\XxxController.cs:130
lambda_method(Closure , ControllerBase , Object[] ) +101
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
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() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8920029
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
This could be related to table in which I duplicated a foreign key. It was called something like myKeyId, and I now have myKey1Id and myKey2Id in that table. I checked everywhere in my code, and I can't find myKeyId anymore.
The error message is so generic that I don't know how to pin-point what is causing this error. Any advice would be welcome.

I hade the same error.
I did clean solution rebuilt and it worked.

My solution was to turn off IIS and then start VS project again.

I ran into this error today, too.
It turned out, that my data model has missing the foreign and primary key constraints in the data base.
I had copied the original database to a local database to speed up the execution, but I had only copied the data and not the relationships.
Other errors i had in this context were
an item with the same key has already been added
and
Unable to update the EntitySet Table because it has a DefiningQuery and no InsertFunction element exists in the ModificationFunctionMapping element to support the current operation
it all was due to a faultive database structure

Ran into this issue today. I deleted all of my tables from the Entity Model .edmx file, the updated my model from the Database (right-click --> update from database).
Then I re-compiled and it ran fine. Such an odd error.
I am running MVC 4 and EF 5.0

Related

What kind of Dynamics CRM 2011 Online authentication needs to use deploy in godaddy shared server

I am having an issue when I tried to deploy an application which communicates with Dynamics CRM 2011 online in godaddy shared server.
I don't have any issue when I run in my local, I am using wsdlbaseproxies online code provided in sdk\samplecode\cs\wsdlbasedproxies\online to authenticate the dynamics CRM. This process is creating LiveDeviceID.xml in the local system and failing to create the same in the godaddy shared hosting server.
This application is developed in .net which captures leads, opportunity and saves/retrieves the same in/from CRM 2011 online.
I really appreciate your help and input on this.
Updated with error message:
The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.
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.Cryptography.CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.
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:
[CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.]
System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy, DataProtectionScope scope) +522
Microsoft.Crm.Services.Utility.DeviceUserName.Encrypt(String value) in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Models\DeviceidManager.cs:970
Microsoft.Crm.Services.Utility.DeviceUserName.UpdateCredentials(String encryptedValue, String decryptedValue) in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Models\DeviceidManager.cs:941
Microsoft.Crm.Services.Utility.DeviceUserName.set_DecryptedPassword(String value) in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Models\DeviceidManager.cs:897
Microsoft.Crm.Services.Utility.DeviceIdManager.GenerateDeviceUserName() in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Models\DeviceidManager.cs:462
Microsoft.Crm.Services.Utility.DeviceIdManager.GenerateDevice(String deviceName, String devicePassword) in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Models\DeviceidManager.cs:377
Microsoft.Crm.Services.Utility.DeviceIdManager.RegisterDevice(Guid applicationId, Uri issuerUri, String deviceName, String devicePassword) in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Models\DeviceidManager.cs:189
Microsoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice(Uri issuerUri, String deviceName, String devicePassword) in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Models\DeviceidManager.cs:116
Microsoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice(Uri issuerUri) in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Models\DeviceidManager.cs:99
Microsoft.Crm.Sdk.Samples.WsdlTokenManager.Authenticate(ClientCredentials credentials, String appliesTo, String policy, Uri issuerUri) in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Models\WsdlTokenManager.cs:141
CRMDynamicsService.CRMDynamicsOnline.Authenticate(LiveIdAuthenticationPolicy policy, String userName, String password) in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Models\CRMDynamicsService.cs:262
CRMDynamicsService.CRMDynamicsOnline.GetLeads() in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Models\CRMDynamicsService.cs:420
hcrm.Controllers.LeadsController.Leads() in C:\Users\Aashritha\Documents\Visual Studio 2010\Projects\hcrm\hcrm\Controllers\LeadsController.cs:20
lambda_method(Closure , ControllerBase , Object[] ) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
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() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970061
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Why won't Visual Studio break on this unhandled exception?

When submitting a form, a Yellow Screen of Death appeared even while in Debug mode in Visual Studio. The problem I had is solved, it was a missing resource value, but I'm interested in why I'm not able to break on the exception.
I tried the following, but nothing changed the situation:
Stepping through the code.
Changing the Debug -> Exceptions settings.
Checking Enable .NET Framework source stepping and Enable source server support.
How can such an exception be caught, or why is it not possible to catch it?
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.ArgumentNullException: Value cannot be null.
Parameter name: value
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:
[ArgumentNullException: Value cannot be null.
Parameter name: value]
System.ComponentModel.DataAnnotations.ValidationContext.set_DisplayName(String value) +52015
System.Web.Mvc.<Validate>d__1.MoveNext() +135
System.Web.Mvc.<Validate>d__5.MoveNext() +318
System.Web.Mvc.DefaultModelBinder.OnModelUpdated(ControllerContext controllerContext, ModelBindingContext bindingContext) +139
System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +66
System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1367
System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +449
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +317
System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +117
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
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() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970061
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
It is not possible to break on this exception, because Microsoft's public Symbol Server does not provide source code for everything.
Adding a breakpoint via the dialog to System.ComponentModel.DataAnnotations.ValidationContext.set_DisplayName will break, but Visual Studio will say that there is no source code available.
Looks like you have some dataAnnotationAttribute for model field, so asp.net takes care about it - before your request fires breakpoint in controller

Security Exception with medium trust, ninject and entity framework

I keep getting this exception whenever I try running my project in medium trust. The project is MVC Forum, and even though I don't need to run any of my own sites in medium trust, I figure I better make it work in the medium trust environment anyway.
I'm using Ninject for DI (the DLL that works in medium trust), and that works - the MVC controllers are loaded with constructor injection as expected.
The "funny" thing is that the method (in my code) that fails, take 2 arguments, these are both loaded from the database using entity framework, so I have no idea why this fails, when entity framework clearly already work in other parts of the code.
What is the reason behind this exception? It's like looking for the famous needle in a haystack.
Here's the stacktrace:
[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31
System.Security.CodeAccessPermission.Demand() +46
System.Data.Common.Internal.Materialization.Translator.DemandMemberAccess() +50
System.Data.Common.Internal.Materialization.Shaper`1..ctor(DbDataReader reader, ObjectContext context, MetadataWorkspace workspace, MergeOption mergeOption, Int32 stateCount, CoordinatorFactory`1 rootCoordinatorFactory, Action checkPermissions, Boolean readerOwned) +165
System.Data.Common.Internal.Materialization.ShaperFactory`1.Create(DbDataReader reader, ObjectContext context, MetadataWorkspace workspace, MergeOption mergeOption, Boolean readerOwned) +93
System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute(ObjectContext context, ObjectParameterCollection parameterValues) +736
System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) +149
System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +44
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +182
System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1(IEnumerable`1 sequence) +41
System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle(IEnumerable`1 query, Expression queryRoot) +59
System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) +150
System.Data.Entity.Internal.Linq.DbQueryProvider.Execute(Expression expression) +102
System.Linq.Queryable.FirstOrDefault(IQueryable`1 source) +265
ApplicationBoilerplate.DataProvider.EntityFramework.Repository`1.ReadOne(ISpecification`1 spec) +217
mvcForum.Web.Extensions.ForumExtensions.GetAccess(Forum forum, Group group) +129
mvcForum.Web.Extensions.ForumExtensions.GetAccess(Forum forum) +895
mvcForum.Web.ViewModels.ForumViewModel..ctor(Forum forum, Int32 topicsPerPage) +1353
mvcForum.Web.Areas.Forum.Controllers.HomeController.Index() +1260
lambda_method(Closure , ControllerBase , Object[] ) +74
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
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() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8970061
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
Small update, I'm using code first. Thanks for looking!
This looks like the exception you get if your entity classes contain properties that are not public--i.e. they are internal, protected, or private. EF5 and below only support mapping to public properties when running in a partial trust environment.

Kerberos Double-Hop Issue between IIS and SSAS [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Can I turn off impersonation just in a couple instances
I've created an application that, when uploaded to my server throws the following exceptions:
[Win32Exception (0x80004005): No credentials are available in the security package]
[AdomdConnectionException: Authentication failed.]
Here is my connection string:
public AdomdConnection conn = new AdomdConnection("Data Source=BTN-SQL1;Initial Catalog=BTNTurboAnalysisServices;Integrated Security=SSPI;SSPI=Kerberos;Persist Security Info=False;");
Its worth noting that BTN-SQL1 is on a different server to my web server and I'm also using Windows Authentication with Impersonation enabled.
Below is my stack trace:
[Win32Exception (0x80004005): No credentials are available in the security package]
Microsoft.AnalysisServices.AdomdClient.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean& handshakeComplete) +424
Microsoft.AnalysisServices.AdomdClient.XmlaClient.Authenticate(ConnectionInfo connectionInfo, DateTime startTime) +175
[AdomdConnectionException: Authentication failed.]
Microsoft.AnalysisServices.AdomdClient.XmlaClient.Authenticate(ConnectionInfo connectionInfo, DateTime startTime) +1308
Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenTcpConnection(ConnectionInfo connectionInfo) +498
Microsoft.AnalysisServices.AdomdClient.XmlaClient.Connect(ConnectionInfo connectionInfo, Boolean beginSession) +1142
Microsoft.AnalysisServices.AdomdClient.XmlaClientProvider.Connect(Boolean toIXMLA) +267
Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ConnectToXMLA(Boolean createSession, Boolean isHTTP) +235
Microsoft.AnalysisServices.AdomdClient.AdomdConnection.Open() +973
btn_intranet.Areas.Sales.Controllers.HomeController.CumulativeChart(String month, String year) in <path to file>/HomeController.cs:69
lambda_method(Closure , ControllerBase , Object[] ) +182
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +129
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +798650
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +314
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +798704
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +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
Any help would be appreciated, thanks!
I've managed to solve the problem. Basically I just disabled impersonation for the specific methods that were causing the problem by using the solution found here:
Can I turn off impersonation just in a couple instances

Example of implementing a ViewModel for the Razor _Layout.cshtml

I have read that you can use a ViewModel for your _Layout in Razor but I have not seen any examples...
At the top of my _Layout i have..
#inherits System.Web.Mvc.WebViewPage<CAPPortal.ViewModels.MasterViewModel>
but every time I try to access one of the properties I get an error..
System.NullReferenceException: Object reference not set to an instance of an object.
Line 23: #Model.Foobar
Exception:
[NullReferenceException: Object reference not set to an instance of an object.]
ASP._Layout_cshtml.Execute() in d:\Visual Studio 2010\CAPPortal\CAPPortal\Views\Shared\_Layout.cshtml:23
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +172
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +86
System.Web.WebPages.<>c__DisplayClass7.<RenderPage>b__6(TextWriter writer) +98
System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +12
System.Web.WebPages.WebPageBase.Write(HelperResult result) +67
System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 b ody) +67
System.Web.WebPages.WebPageBase.PopContext() +262
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +93
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
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() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
Please make sure that you're passing in an actual model object when you render the view. For example:
public ActionResult ShowStuff() {
return View(new MyModelType());
}
If you don't pass in a model object then the Model property will indeed be null, and trying to access a property of it within the view will of course throw a NullReferenceException.

Resources