MemberShip.GetUser(model.Username) throws exception in hosted MVC3 site - asp.net-mvc-3

So I've build this website in MVC3 in which I am using the default ASP.NET Membership provider for users, logins, roles etc.
It was finally the time to host the solution online which is causing some problems for me.
I have migrated my SQL 2008 Express database to the Hosted database by means of a sql script file which worked out nicely (Had some error, but worked around it). I can render the page fine and it loads data out from the DB fine.
The problem is when I either try to login with an existing users or try to create a new. Basically anything that uses a Membership provider Stored Procedure it get thrown an exception.
This one is from an attempted login which is thrown by the standard Logon function in the AccountController.
Any suggestions how come these stored procedures are acting up all of a sudden?
If i try to run the SP directly from the database with an existing user as the parameter it works out fine. It just wont work in the context of the website.
The line of code in the method from the AccountController that fails:
MembershipUser user = Membership.GetUser(model.UserName);
[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5009598
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +341
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +129
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +270
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
System.Data.SqlClient.SqlConnection.Open() +125
System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +95
System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +206
**System.Web.Security.SqlMembershipProvider.GetUser(String username, Boolean userIsOnline) +1169
System.Web.Security.Membership.GetUser(String username, Boolean userIsOnline) +63
System.Web.Security.Membership.GetUser(String username) +6
Venatores.Controllers.AccountController.LogOn(LogOnModel model, String returnUrl) in C:\Users\dktvo\Desktop\Private TVO\Ørsø v1\Venatores\Venatores\Controllers\AccountController.cs:32
lambda_method(Closure , ControllerBase , Object[] ) +157
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() +8841105
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Check your connection string, it might not be correct and if it is correct, the database (SQL Server) may not be running or something else
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: SQL
Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)]

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

How to deploy an MVC3 site with pre configured accounts

I have created a simple MVC3 web site and I want to limit access to certain pages depending upon who logs in.
In my development environment I have created the default users and roles which have been placed into a SQLEXPRESS database.
In my installer, I have included the App_Data folder and the database. The server I install onto has SQL express but when I try to log in to a restricted page, the site thinks about it and generates the error below.
In my web.config file I have a connection string set as:
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
Server Error in '/UNICH' Application.
--------------------------------------------------------------------------------
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
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.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
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:
[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5050218
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +341
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +129
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +270
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +5063943
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
System.Data.SqlClient.SqlConnection.Open() +125
System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +95
System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +206
System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +827
System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105
System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +106
UNICH.Web.Controllers.AccountController.LogOn(LogOnModel model, String returnUrl) +108
lambda_method(Closure , ControllerBase , Object[] ) +157
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +188
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +267
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +190
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +329
System.Web.Mvc.Controller.ExecuteCore() +115
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +94
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() +55
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +31
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +23
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +59
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8897857
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
EDIT: Some more data...
I have placed the database file in the App_Data folder within the web site.
Do I need to set any special permissions on this folder for the database to be accessed?
The NETWORK SERVICE user needs to have read and write permission on the App_Data folder (or wherever you place the database file).

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

WCF service attempting to read mdf file

I have a Silverlight application, developed in VS2010 and deployed on Server 2008.
The application calls a WCF service within the project to read an mdf file, again within the application.
After getting through a number of what can only be called bugs within the VS deployement system (missing out the svc.cs file, placing the references in a folder the service can't see) I have managed to get it running.
The problem I'm having is that the service fails after a few seconds. Using WCF Storm I was able to run the service and get the following error information:
removed, see comments and below
has anyone any suggestions as to how to fix this? I'm getting to the end of my tether with WCF services!
Thanks in advance
Cap
Edit:
I have now activated errors in the web.config (thanks Upendra Chaudhari) and it has given the following error:
<GetDataTypes>
<MethodParameters>
<FaultException1>
<Detail>
<HelpLink isNull="true" />
<InnerException>
<HelpLink isNull="true" />
<InnerException isNull="true" />
<Message>A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)</Message>
<StackTrace>at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)</StackTrace>
<Type>System.Data.SqlClient.SqlException</Type>
</InnerException>
<Message>The underlying provider failed on Open.</Message>
<StackTrace>at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) at System.Data.EntityClient.EntityConnection.Open() at System.Data.Objects.ObjectContext.EnsureConnection() at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at e_on_silverlight_bing.Web.Services.NewSiteService.GetDataTypes() in C:\Documents and Settings\richardsonl\My Documents\Visual Studio 2010\Projects\E-on Site Map\SilverlightApplication3\e-on silverlight bing.Web\Services\NewSiteService.svc.cs:line 65 at SyncInvokeGetDataTypes(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
<Type>System.Data.EntityException</Type>
</Detail>
<Action>http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault</Action>
<Code>System.ServiceModel.FaultCode</Code>
<Message>The underlying provider failed on Open.</Message>
<Reason>The underlying provider failed on Open.</Reason>
<Data>
<KeysAndValues attr0="KeyValuePairArray" isNull="false" />
</Data>
<InnerException isNull="true" />
<TargetSite>Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)</TargetSite>
<StackTrace>Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at NewSiteService.GetDataTypes() at NewSiteServiceClient.GetDataTypes()</StackTrace>
<HelpLink isNull="true" />
<Source>mscorlib</Source>
</FaultException1>
It looks like the service cannot see the database. I'm not particularly experienced with this sort of thing so I may be missing something important.
Within VS2010 I have the mdf file inside App_Data within the webpage. The service is within the services folder. I have published the site and moved the files and folders to a new folder within wwwroot. Any ideas?
Thanks again
Cap
Your problem is one of these:
your connection string is wrong:you must open web.config file in your web part of your project and right that.
database system is inaccessible because:
the database computer is turn off
firewall or antivirus of database system is active

System.ArgumentException: Duplicate type name within an assembly

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

Resources