I am working in mvc3 razor my project fistly run correctly but i get the error
Error 3 Assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.Mvc.dll MvcApplication1
and i replace the system.web.mvc.dll and System.Web.WebPages.Razor files from mvc4 folder to mvc3 folder. and some changes in web.config and it start working correctly. but now after few days it show me the following error message
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.Web.Mvc.Razor.MvcWebPageRazorHost.GetRidOfNamespace(String ns) +32
System.Web.Mvc.Razor.MvcWebPageRazorHost..ctor(String virtualPath, String physicalPath) +196
System.Web.Mvc.MvcWebRazorHostFactory.CreateHost(String virtualPath, String physicalPath) +113
System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfigCore (RazorWebSectionGroup config, String virtualPath, String physicalPath) +422
System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfig(String virtualPath, String physicalPath) +228
System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfig(String virtualPath) +38
System.Web.WebPages.Razor.RazorBuildProvider.GetHostFromConfig() +51
System.Web.WebPages.Razor.RazorBuildProvider.CreateHost() +57
System.Web.WebPages.Razor.RazorBuildProvider.get_Host() +56
System.Web.WebPages.Razor.RazorBuildProvider.EnsureGeneratedCode() +92
System.Web.WebPages.Razor.RazorBuildProvider.get_CodeCompilerType() +54
System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) +59
System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() +209
System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +15
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +9929933
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +299
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +103
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +165
System.Web.Compilation.BuildManager.GetObjectFactory(String virtualPath, Boolean throwIfNotFound) +33
System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath) +40
System.Web.Mvc.BuildManagerViewEngine.FileExists(ControllerContext controllerContext, String virtualPath) +54
System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List1
locations, String name, String controllerName, String areaName, String cacheKey, String[]& searchedLocations) +197
System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) +681
System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache) +315
System.Web.Mvc.<>c__DisplayClassc.<FindView>b__b(IViewEngine e) +68
System.Web.Mvc.ViewEngineCollection.Find(Func2 lookup, Boolean trackSearchedPaths) +182
System.Web.Mvc.ViewEngineCollection.Find(Func2 cacheLocator, Func2 locator) +110
System.Web.Mvc.ViewEngineCollection.FindView(ControllerContext controllerContext, String viewName, String masterName) +329
System.Web.Mvc.ViewResult.FindView(ControllerContext context) +135
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +230
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +74
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext,
Func1 continuation) +388
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +72
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext,IList1filters, ActionResult actionResult) +303
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +844
System.Web.Mvc.Controller.ExecuteCore() +130
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +229
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +39
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +71
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +44
System.Web.Mvc.Async.<>c__DisplayClass8
1.<BeginSynchronous>b__7(IAsyncResult _) +42
System.Web.Mvc.Async.WrappedAsyncResult
1.End() +152
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +75
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +31
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +61
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +118
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629708
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
settings in my web.config are as under
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
Please any one give me help about this.
Have you installed .NET Framework 4.5 or Visual Studio 2012? The problem is most likely a bug in the framework. You may find your answers here:
http://elegantcode.com/2012/08/23/net-4-5-operation-could-destabilize-the-runtime-yikes/
We had a similar issue with one of our projects. We had been using MVC3 and tried upgrading to MVC4. We also upgraded to Razor 2.0. Turned out that the web.configs did not all update as expected. Check your web config in the ~/Views folder as well as the root web.config and make sure the assembly binding redirects are correct and all the assembly references are correct. We did that and the issue went away
Related
I am developing a Xamarin.Forms app with ASP.NET Web Api with VS2019.
Somehow I when I run the web api project I am getting this error regarding
Xamarin.Forms.Xaml which has no reference to it in my web api.
Could not load file or assembly 'Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file 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.IO.FileNotFoundException: Could not load file or assembly 'Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file 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.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/Malcolm/Documents/Visual Studio 2019/Projects/LakesLinenOrdersApp/LakesLinenOrdersApi/
LOG: Initial PrivatePath = C:\Users\Malcolm\Documents\Visual Studio 2019\Projects\LakesLinenOrdersApp\LakesLinenOrdersApi\bin
Calling assembly : GUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
This is the Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +151
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +135
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +92
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +502
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +108
System.Reflection.RuntimeAssembly.GetCustomAttributes(Boolean inherit) +40
Owin.Loader.DefaultLoader.SearchForStartupAttribute(String friendlyName, IList1 errors, Boolean& conflict) +106
Owin.Loader.DefaultLoader.GetDefaultConfiguration(String friendlyName, IList1 errors) +46
Owin.Loader.DefaultLoader.LoadImplementation(String startupName, IList1 errorDetails) +75
Owin.Loader.DefaultLoader.Load(String startupName, IList1 errorDetails) +21
Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +115
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +28
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +119
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +552
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +181
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +228
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +314
[HttpException (0x80004005): Could not load file or assembly 'Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10085052
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +99
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +263
I have a simple .rdlc file which has a parameter defined, when i fill(send) a value to the parameter, i get the error:
Failed to load expression host assembly.
Details: Type 'System.Web.HttpContextWrapper'
in assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
is not marked as serializable.
however, removing the value for the parameter, renders report without any problem.
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report/report1.rdlc");
//If following line commented, there is no problem,
//and report is rendered correctly.
ReportViewer1.LocalReport.SetParameters(new ReportParameter("test1", "some value"));
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", Data));
ReportViewer1.DataBind();
target .net framework is : 4.5.2, project is asp.net webform(web application), Microsoft.ReportingServices.ReportViewerControl.WebForms version 140.1000.523 is added by nuget.
update
I have added System.Web as reference to rdlc file, and now get full error:
[SerializationException: Type 'System.Web.HttpContextWrapper' in assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.]
System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, String typeName) +0
Microsoft.ReportingServices.Diagnostics.AssemblyLocationResolver.CreateResolver(AppDomain tempAppDomain) +98
Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.ResolveAssemblylocations(List`1 codeModules, CompilerParameters options, ErrorContext errorContext, AppDomain compilationTempAppDomain) +35
Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.InternalCompile(AppDomain compilationTempAppDomain, Boolean refusePermissions) +377
Microsoft.ReportingServices.RdlExpressions.<>c__DisplayClass2.<Compile>b__0() +19
Microsoft.ReportingServices.Diagnostics.<>c__DisplayClass1.<Run>b__0(Object state) +116
System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state) +13049529
Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.Run(ContextBody callback) +99
Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.Compile(IExpressionHostAssemblyHolder expressionHostAssemblyHolder, AppDomain compilationTempAppDomain, Boolean refusePermissions, PublishingVersioning versioning) +184
Microsoft.ReportingServices.ReportPublishing.ReportPublishing.Phase3(ParameterInfoCollection& parameters, Dictionary`2& groupingExprCountAtScope) +1445
Microsoft.ReportingServices.ReportPublishing.ReportPublishing.InternalCreateIntermediateFormat(Stream definitionStream, String& description, String& language, ParameterInfoCollection& parameters, DataSourceInfoCollection& dataSources, DataSetInfoCollection& sharedDataSetReferences, UserLocationFlags& userReferenceLocation, ArrayList& dataSetsName, Boolean& hasExternalImages, Boolean& hasHyperlinks, Byte[]& dataSetsHash) +125
Microsoft.ReportingServices.ReportPublishing.ReportPublishing.CreateIntermediateFormat(Byte[] definition, String& description, String& language, ParameterInfoCollection& parameters, DataSourceInfoCollection& dataSources, DataSetInfoCollection& sharedDataSetReferences, UserLocationFlags& userReferenceLocation, ArrayList& dataSetsName, Boolean& hasExternalImages, Boolean& hasHyperlinks, Byte[]& dataSetsHash) +82
Microsoft.ReportingServices.ReportProcessing.ReportProcessing.CompileOdpReport(PublishingContext reportPublishingContext, PublishingErrorContext errorContext, String& reportDescription, String& reportLanguage, ParameterInfoCollection& parameters, DataSourceInfoCollection& dataSources, DataSetInfoCollection& sharedDataSetReferences, UserLocationFlags& userReferenceLocation, ArrayList& dataSetsName, Boolean& hasExternalImages, Boolean& hasHyperlinks, Byte[]& dataSetsHash) +122
Microsoft.ReportingServices.ReportProcessing.ReportProcessing.CreateIntermediateFormat(PublishingContext reportPublishingContext) +192
[ReportProcessingException: An unexpected error occurred in Report Processing.]
Microsoft.ReportingServices.ReportProcessing.ReportProcessing.CreateIntermediateFormat(PublishingContext reportPublishingContext) +1006
Microsoft.Reporting.ReportCompiler.CompileReport(ICatalogItemContext context, Byte[] reportDefinition, Boolean generateExpressionHostWithRefusedPermissions, ControlSnapshot& snapshot) +195
[DefinitionInvalidException: The definition of the report 'F:\*****************\report1.rdlc' is invalid.]
Microsoft.Reporting.ReportCompiler.CompileReport(ICatalogItemContext context, Byte[] reportDefinition, Boolean generateExpressionHostWithRefusedPermissions, ControlSnapshot& snapshot) +261
Microsoft.Reporting.LocalService.GetCompiledReport(PreviewItemContext itemContext, Boolean rebuild, ControlSnapshot& snapshot) +228
Microsoft.Reporting.LocalService.CompileReport() +29
Microsoft.Reporting.LocalService.Microsoft.Reporting.ILocalProcessingHost.CompileReport() +5
Microsoft.Reporting.WebForms.LocalReport.EnsureExecutionSession() +61
[LocalProcessingException: An error occurred during local report processing.]
Microsoft.Reporting.WebForms.LocalReport.EnsureExecutionSession() +149
Microsoft.Reporting.WebForms.LocalReport.SetParameters(IEnumerable`1 parameters) +57
Microsoft.Reporting.WebForms.Report.SetParameters(ReportParameter parameter) +48
***********.btnPrint_Click(Object sender, EventArgs e) in F:\************.cs:199
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9782450
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +204
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1639
I have installed MVC4 and an MVC3 app that I have is now causing me problems. I get the error :
Could not load file or assembly 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference
However, I cannot find any references in my code to v2 of WebPages, and I am wondering why I am getting this error. Can anybody help?
EDIT : Here is the full stack trace :
[FileLoadException: Could not load file or assembly 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
ljMVC.Helpers.EditableHelpers.Editable(HtmlHelper helper, String htmlElement, String cssId, String defaultContent, Object htmlAttributes) in C:\Users\M\Desktop\Development\ASP.NET projects\ljMVC\ljMVC\ljMVC\Helpers\EditableHelpers.cs:90
ASP._Page_Areas_Gameplan_Views_MainGP_Index_cshtml.Execute() in e:\web\lovelyjubbl\htdocs\Areas\Gameplan\Views\MainGP\Index.cshtml:85
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +208
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +89
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +78
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +199
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c_DisplayClass1c.b_19() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +176
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.b_5() +37
System.Web.Mvc.Async.<>c_DisplayClass1.b_0() +21
System.Web.Mvc.Async.<>c_DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult1.End() +55
System.Web.Mvc.<>c_DisplayClasse.b_d() +31
System.Web.Mvc.SecurityUtil.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() +8970061
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
Here:
EditableHelpers.cs:90
I guess you are using some NuGet or something that depends on WebPages 2.0 (a.k.a System.Web.WebPages, Version=2.0.0.0). You probably updated this NuGet or whatever it is and now you have dependency with this assembly.
So I have created a MVC3 (Razor) Website in Visual Studio 2010. Now I want to publish it to a server but keep getting the following error message after I have published and uploaded files to server:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Stack Trace
[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5103182
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +260
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +389
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject, Boolean withFailover) +197
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +963
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) +316
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +5119675
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
WebMatrix.Data.Database.EnsureConnectionOpen() +44
WebMatrix.Data.<QueryInternal>d__0.MoveNext() +71
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +4231764
WebMatrix.Data.Database.QuerySingle(String commandText, Object[] args) +103
WebMatrix.WebData.SimpleMembershipProvider.CheckTableExists(Database db, String tableName) +59
WebMatrix.WebData.SimpleMembershipProvider.CreateTablesIfNeeded() +55
WebMatrix.WebData.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider sMembership, DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean createTables) +73
WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
ASP._Page__AppStart_cshtml.Execute() in *:\HostingSpaces\***\***.com\wwwroot\_AppStart.cshtml:3
System.Web.WebPages.ApplicationStartPage.<ExecuteInternal>b__3() +65
System.Web.WebPages.ApplicationStartPage.<GetSafeExecuteStartPageThunk>b__a(Action action) +7
System.Web.WebPages.ApplicationStartPage.ExecuteInternal() +78
System.Web.WebPages.ApplicationStartPage.ExecuteStartPageInternal(HttpApplication application, Action`1 monitorFile, Func`2 fileExists, Func`2 createInstance, IEnumerable`1 supportedExtensions) +202
System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application, Action`1 monitorFile, Func`2 fileExists, Func`2 createInstance, IEnumerable`1 supportedExtensions) +41
[HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown.]
System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application, Action`1 monitorFile, Func`2 fileExists, Func`2 createInstance, IEnumerable`1 supportedExtensions) +88
System.Web.WebPages.ApplicationStartPage.ExecuteStartPage(HttpApplication application) +287
System.Web.WebPages.WebPageHttpModule.StartApplication(HttpApplication application, Action`1 executeStartPage, EventHandler applicationStart) +113
System.Web.WebPages.WebPageHttpModule.StartApplication(HttpApplication application) +71
System.Web.WebPages.WebPageHttpModule.Init(HttpApplication application) +217
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +517
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253
[HttpException (0x80004005): Exception of type 'System.Web.HttpException' was thrown.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090876
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
This is my Web.Config file:
<configuration>
<system.web>
<customErrors mode="Off"/>
<authentication mode="Forms" />
<roleManager enabled="true" />
<pages maintainScrollPositionOnPostBack="true">
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
</controls>
</pages>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
<buildProviders>
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
</buildProviders>
</compilation>
</system.web>
<connectionStrings>
<add name="WhimsicalFurnishingEntities" connectionString="metadata=res://*/App_Code.WhimsicalFurnishingModel.csdl|res://*/App_Code.WhimsicalFurnishingModel.ssdl|res://*/App_Code.WhimsicalFurnishingModel.msl;provider connection string="data source=localhost\sqlexpress;Database=DBNAME;Uid=USERNAME;Password=PASSWORD;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Is there something I am missing to add in my project? I am sure the data source is correct with localhost\sqlexpress.
Thank You
I am assuming you are publishing this to a different server like a virtual private host? If so, it is very weird that the datasource is sqlexpress.
Localhost\sqlexpress is for SQLServer Express which is typically installed on developer machines, if it's on a production server you will usually have SQLServer Enterprise or something else.
If you have provided the correct database connection string with SQL Server Instance, then you may restart your database server service. Then again try to publish your site. Please ask if it not worked for you.
I am trying to secure elmah in an asp.net mvc 3 application.
I been searching around and found this to be the way to do it
<location path="elmah.axd">
<system.web>
<authorization>
<allow roles="Admin" />
<deny users="*" />
</authorization>
</system.web>
</location>
Yet when I do this resharper says "Location Element is unused no project item found at elmah.axd"
When I load my site up with the location surrounding my system.web I get
Server Error in '/' Application.
There is no build provider registered for the extension '.cshtml'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
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.Web.HttpException: There is no build provider registered for the extension '.cshtml'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
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:
[HttpException (0x80004005): There is no build provider registered for the extension '.cshtml'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.]
System.Web.Compilation.CompilationUtil.GetBuildProviderTypeFromExtension(CompilationSection config, String extension, BuildProviderAppliesTo neededFor, Boolean failIfUnknown) +8753269
System.Web.Compilation.BuildManager.CreateBuildProvider(VirtualPath virtualPath, BuildProviderAppliesTo neededFor, CompilationSection compConfig, ICollection referencedAssemblies, Boolean failIfUnknown) +40
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +281
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +320
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +111
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +125
System.Web.Compilation.BuildManager.GetObjectFactory(String virtualPath, Boolean throwIfNotFound) +35
System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath) +9
System.Web.Mvc.BuildManagerViewEngine.FileExists(ControllerContext controllerContext, String virtualPath) +41
System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List`1 locations, String name, String controllerName, String areaName, String cacheKey, String[]& searchedLocations) +150
System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) +304
System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache) +136
System.Web.Mvc.<>c__DisplayClassc.<FindView>b__b(IViewEngine e) +24
System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths) +127
System.Web.Mvc.ViewEngineCollection.FindView(ControllerContext controllerContext, String viewName, String masterName) +181
System.Web.Mvc.ViewResult.FindView(ControllerContext context) +138
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +129
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.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
So it loses the ability to basically render razor views.
I had some luck with this
<location path="admin">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<authorization>
<allow users="bzink" />
<deny users="*" />
</authorization>
</system.web>
</location>
I can access the elmah page from http://host/admin/elmah.axd now.
OHHHH just reread your question more carefully. You say... "When I load my site up with the location surrounding my system.web
That's your problem. You need to keep system.web intact. Here's how the structure should look.
Do all the important stuff like caching, authorization, http handlers, etc.. You shouldn't need to touch this section.
</system.web>
<system.diagnostics>diagnostics was next, but i don't think that should matter</system.diagnostics>
<location path="admin">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<authorization>
<allow users="bzink" />
<deny users="*" />
</authorization>
</system.web>
</location>
See you need the main system.web, and then an additional system.web goes inside each location tag.
I'm using MVC 4 and I searched and tried a few thing, finally this worked.
<appSettings>
<add key="elmah.mvc.requiresAuthentication" value="true" />
...
</appSettings>
Change value to "true". This will bring up your Login page, you can also set roles, etc. At the very least, this will require authentication.