error CS1009: Unrecognized escape sequence on appharbor - asp.net-mvc

i got the following error when uploaded my files to AppHarbor
[HttpCompileException]: d:\temp\f3fkwz4z.mbc\temp\root\0c956e8e\9304c5fb\App_Web_ixu4pbnj.0.cs(43): error CS1009: Unrecognized escape sequence
at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilder(AssemblyBuilder builder)
at System.Web.Compilation.WebDirectoryBatchCompiler.<CompileNonDependentBuildProviders>b__0(AssemblyBuilder assemblyBuilder)
at System.Web.Compilation.CompilationUtil.CompileParallel(ICollection assemblyBuilders, Action`1 action)
at System.Web.Compilation.WebDirectoryBatchCompiler.CompileNonDependentBuildProviders(ICollection buildProviders)
at System.Web.Compilation.WebDirectoryBatchCompiler.Process()
at System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors)
at System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors)
at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
at System.Web.Compilation.BuildManager.PrecompileAppInternal(VirtualPath startingVirtualDir, IEnumerable`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManager.PrecompileApp(VirtualPath startingVirtualDir, IEnumerable`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManager.PrecompileApp(ClientBuildManagerCallback callback, IEnumerable`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback, List`1 excludedVirtualPaths)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback, List`1 excludedVirtualPaths)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback, Boolean forceCleanBuild)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback)
at System.Web.Compilation.Precompiler.Main(String[] args)
although no such file exist in my project it is Asp.Net MVC4 project with EntityFramework
i dont understand from where the error comes

That strange file name that you are seeing is AppHarbor compiling your cshtml/vbhtml files when you deploy. Any errors in those files (bad Model property calls, even bad HTML) can cause the build to fail on those files and provide some pretty cryptic errors.
Try setting the MvcBuildViews property to true (Here is how to do that via Phil Haack) and see if you can use Visual Studio to help localize and correct the error.

Related

Error in Sitecore Content Editor after update to 6.6

I have Sitecore instance 6.6 updated from 6.3. After the update an exception occurs when right-clicking on the left side of the content tree. That's the space where you can choose to show the lock icon and so on. Here's a screenshot:
This is the error message:
[ArgumentException: Empty strings are not allowed.
Parametername: header]
Sitecore.Diagnostics.Assert.ArgumentNotNullOrEmpty(String argument, String argumentName) +241
Sitecore.Web.UI.HtmlControls.Menu.Add(String id, String header, String icon, String hotkey, String click, Boolean check, String radiogroup, MenuItemType type) +68
Sitecore.Shell.Applications.ContentManager.ContentEditorForm.Gutter_ContextMenu() +637
[TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht.]
System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +808
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +38
Sitecore.Shell.Framework.Commands.MethodCommandProcessor.Invoke(PipelineArgs args) +427
Sitecore.Nexus.Pipelines.NexusPipelineApi.Resume(PipelineArgs args, Pipeline pipeline) +330
Sitecore.Pipelines.Pipeline.DoStart(PipelineArgs args) +208
Sitecore.Pipelines.Pipeline.Start(PipelineArgs args, Boolean atomic) +182
Sitecore.Shell.Framework.Commands.MethodCommand.Execute(CommandContext context) +499
Sitecore.Web.UI.Sheer.ClientPage.OnPreRender(EventArgs e) +530
Sitecore.Shell.Applications.ContentManager.ContentEditorPage.OnPreRender(EventArgs e) +25
System.Web.UI.Control.PreRenderRecursiveInternal() +108
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394
Any idea how I can fix this?
There's a couple of things you need to check and doublecheck.
1) Is your Sitecore.Kernel.dll in /bin the correct version for 6.6. A very common mistake to make is, to go through the upgrade fine and then rebuild your project - forgetting that your local obj and bin folders hold Sitecore DLLs for 6.3 that then gets copied to /bin.
To fix this, first try and take the entire /bin directory from your 6.6 zip and copy/replace it to your website /bin. See if the issues goes away.
2) If not, check our commands.config (located in App_Config/Include) and make sure it's the right version for 6.6.
These two, is where I would start looking first.
I found out what caused this error. The items in the core database of that menu lost their language versions during the update. After creating the language versions of those items in the core db, the menu shows up again.

Invalid object name 'dbo.__MigrationHistory' using Database.Create; EF6.02 when connection string is passed in

I experience an error when trying to create a database using the following code.
Note the problem does not happen if the connection string is not passed in.
Also the problem happens when I run the program in the IDE. It does not happen if I run the program .exe or if I run the unit tests within the IDE.
However if the database is created by running the unit tests or by running the .EXE then the __MigrationHistory table is created in the main tables section, not the system tables.
public Context(string connString, bool AddInitialRecords )
: base(connString ?? "MyContextName")
{
this.CheckDatabase(AddInitialRecords);
}
public void CheckDatabase(bool AddInitialRecords)
{
if (this.Database.Exists())
{
// upgrade stuff
}
else
{
Database.Create(); // error occurs here
// seeding stuff
}
}
I don't get the problem if I just use something like
var db1 = new Context();
db1.Database.CreateIfNotExists();
I have found some documentation here but it confuses me. I am installing from a "stable build" surely I aren't experiencing something from 2012? What could I be doing wrong with PM?
The error message for the problem is....
System.Data.Entity.Core.EntityCommandExecutionException occurred
HResult=-2146232004 Message=An error occurred while executing the
command definition. See the inner exception for details.
Source=EntityFramework StackTrace:
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand
entityCommand, CommandBehavior behavior) InnerException:
System.Data.SqlClient.SqlException
HResult=-2146232060
Message=Invalid object name 'dbo.__MigrationHistory'.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=16
LineNumber=1
Number=208
Procedure=""
Server=.\SQLEXPRESS
State=1
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, TaskCompletionSource`1 completion, Int32 timeout, Task& task,
Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<>c__DisplayClassb.b__8()
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TInterceptionContext,TResult](Func`1
operation, TInterceptionContext interceptionContext, Action`1
executing, Action`1 executed)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand
command, DbCommandInterceptionContext interceptionContext)
at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior
behavior)
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand
entityCommand, CommandBehavior behavior)
InnerException:
This happens because EF does some probing for the __MigrationsHistory table. For instance you can use EF with an existing database that was not created using EF Migrations but EF has no way of knowing it so it tries to connect to the database and uses the table to check this. If the table does not exist an exception will be thrown. EF then catches the exception and does the right thing (e.g. creates the __MigrationsHistory table if needed or proceeds without using migrations).
In general you won't see this exception when running without the debugger. However when debugging your code AND when the option to break the execution when an exception is thrown is set you will see all the exceptions that are being thrown even if they are internally handled and never reach your code. The default setting is not to break when the exception is thrown but only when an exception that is not being handled is thrown. You can change the setting by checking/unchecking a check box in the "Thrown" column in the Debug -> Exceptions dialog.
In VS 2017 you open exception settings using Debug->Windows->Exception Settings. If you right-click on the "Common Language Runtime Exceptions" you can select the "Restore Defaults" which disables breaking your program when most of the exceptions are thrown.
You can turn off code first database initialization for your database, by adding this to your context's constructor:
System.Data.Entity.Database.SetInitializer<YourContext>(null);
This should prevent the attempt to access dbo.__MigrationHistory.
I faced the same issue. It means that EF is not able to find the __Migration history table. also note for some reason it has to be dbo.__MigrationHistory (note dbo). Ensure that you have run "update-database" atleast once before running the Context
I forgot to add the database name in my connection string. After I added, it started to work
Just uncheck break checkbox then click enable editing to proceed
the database I was using Table __MigrationHistory was missing, so when I Scripted migrations, it generated this code:
IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL
BEGIN
CREATE TABLE [__EFMigrationsHistory] (
[MigrationId] nvarchar(150) NOT NULL,
[ProductVersion] nvarchar(32) NOT NULL,
CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId])
);
END;
and This fixed..

EF code first migration

I have followed below steps to create database using code first approach.
Create classes
Launch package manager
Enable-Migrations -ContextTypeName -MyDb
Made change in Model class
execute 'Update-Database -Verbose'
Change was reflected in the database table
Now I connect to the database and delete table. When I am executing 'Update-Database -Verbose' command, my expectation was it will create table again but its failing with below error message.
PM> Update-Database -Force
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
No pending code-based migrations.
Applying automatic migration: 201308221453295_AutomaticMigration.
System.Data.SqlClient.SqlException (0x80131904): Either the parameter #objname is ambiguous or the claimed #objtype (COLUMN) is wrong.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable`1 migrationStatements)
at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument targetModel, IEnumerable`1 operations, Boolean downgrading, Boolean auto)
at System.Data.Entity.Migrations.DbMigrator.AutoMigrate(String migrationId, XDocument sourceModel, XDocument targetModel, Boolean downgrading)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.AutoMigrate(String migrationId, XDocument sourceModel, XDocument targetModel, Boolean downgrading)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
ClientConnectionId:d07c8463-88f6-44fa-a242-fe0da2c36f31
Either the parameter #objname is ambiguous or the claimed #objtype (COLUMN) is wrong.
Can anyone help? How can I create table again using code first approach?
Regards,
Hemant Shelar
There's a system table in the database that holds all the run migrations, so rerunning Update-Database shouldn't do anything. Unless you've changed your model in your project causing an Automatic Migration, where you haven't explicitly created the migration and Entity Framework is trying to match the database to the models.
As Raphaƫl mentioned, it's code first. You shouldn't be modifying the tables directly if you want to manage it through code first. If you really want to do this, you need to remove the migration from the __MigrationHistory system table so Entity Framework doesn't think the migration has run. Or use the Update-Database -Target:[migration target here] to downgrade/revert a database through the commandlet.

Ambiguous pre-compile error

When deploying my ASP.NET MVC 3 application from VS2012 RC I keep getting the below error. I am guessing something in my code is incorrect, however, I cannot determine from the error information where the problem code resides. This code builds on my home and work PC. Any Help?
d:\temp\zb5bedyk.2dr\temp\root\6b14f900\b1889a38\App_Web_nrwr2tuj.0.cs(37): error CS1041: Identifier expected; 'long' is a keyword
d:\temp\zb5bedyk.2dr\temp\root\6b14f900\b1889a38\App_Web_nrwr2tuj.0.cs(37): error CS1519: Invalid token '>' in class, struct, or interface member declaration
[HttpCompileException]: d:\temp\zb5bedyk.2dr\temp\root\6b14f900\b1889a38\App_Web_nrwr2tuj.0.cs(37): error CS1041: Identifier expected; 'long' is a keyword
at System.Web.Compilation.AssemblyBuilder.Compile()
at System.Web.Compilation.WebDirectoryBatchCompiler.CompileAssemblyBuilder(AssemblyBuilder builder)
at System.Web.Compilation.WebDirectoryBatchCompiler.CompileNonDependentBuildProviders(ICollection buildProviders)
at System.Web.Compilation.WebDirectoryBatchCompiler.Process()
at System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors)
at System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors)
at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
at System.Web.Compilation.BuildManager.PrecompileWebDirectoriesRecursive(VirtualDirectory vdir, Boolean topLevel)
at System.Web.Compilation.BuildManager.PrecompileAppInternal(VirtualPath startingVirtualDir)
at System.Web.Compilation.BuildManager.PrecompileApp(VirtualPath startingVirtualDir)
at System.Web.Compilation.BuildManager.PrecompileApp(ClientBuildManagerCallback callback)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManagerCallback callback)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback, Boolean forceCleanBuild)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(ClientBuildManagerCallback callback)
at System.Web.Compilation.Precompiler.Main(String[] args)
An error occurred during the website precompile. Precompilation failed with exit code 1
You can optionally disable precompilation in application settings if you don't need it.
Also note that .NET 4.5 is not yet installed on AppHarbor infrastructure (it will be soon) so you may need to downtarget you project to 4.0.

ASP.NET MVC Application crashing randomly

I created a MVC 2 Application to work as a RSS Feeder and deliver News Contents for a number of applications to consume.
Everything was doing fine until yesterday when suddenly my application started throwing a random error which doesn't tell me much of what's going on (or at least I don't understand it).
This error only occurs in Production and cannot be reproduced in staging or my local machine.
Here's the stack trace:
Error executing child request for handler
'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'.errorPath:/Android/Edition/2011-11-22/P1
HostIP:##.##.##.## at
System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler,
TextWriter writer, Boolean preserveForm, Boolean setPreviousPage,
VirtualPath path, VirtualPath filePath, String physPath, Exception
error, String queryStringOverride) at
System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter
writer, Boolean preserveForm, Boolean setPreviousPage) at
System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter
writer, Boolean preserveForm) at
System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler,
TextWriter writer, Boolean preserveForm) at
System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext) at
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.<>c_DisplayClass14.b_11()
at
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter
filter, ResultExecutingContext preContext, Func1 continuation) at
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter
filter, ResultExecutingContext preContext, Func1 continuation) at
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext
controllerContext, IList1 filters, ActionResult actionResult) at
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
controllerContext, String actionName) at
System.Web.Mvc.Controller.ExecuteCore() at
System.Web.Mvc.MvcHandler.<>c__DisplayClass8.b__4() at
System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.b__0() at
System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass81.b__7(IAsyncResult
_) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End() at
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)
This error only occurs sometimes and can throw at any action of any controller.
I would like to have found the reason in a specific action but it only throws sometimes and can throw for any action.
Such byzantine errors are hard to debug. The stack trace you're seeing does not help in diagnosing the error.
First, you should improve error logging. In your global.asax, create an implementation of the Application_Error hook that logs the exception and all inner exceptions to a file (I wouldn't log this to the database, because the db connection could be the culprit). Make sure that this code is solid: it should focus on these critical errors and not log every 404 page. Also, make sure that the logging code itself does not create any problems (it should be highly error tolerant).
The cause for this kind of problems is usually access to some kind of static variables. Out of all keywords, I believe static is by far the most dangerous one because it is so subtle.
Some common errors I've seen.
Caching Someone wanted to be smart and cache some data in a static dictionary or so. Unfortunately, the locking code is flawed. An exception occurs only if the code for some user tries to add sth. to the cache, but it's already there:
if(_dict.ContainsKey(cacheKey) == false)
{
// second thread adds data to the dictionary here
_dict.Add(cacheKey, cacheData); // exception
}
This can also happen in a 3rd party library that uses caching or pooling. Access static variables with care.
Uncommon Code Paths Something unusual happens that calls code that is not called very often, and that code is flawed. If you have testing with high code coverage, check the spots that are not covered by the tests.
DB Connection Lost A socket reset on the db connection could lead to exceptions. Many database connection libraries / drivers fix this quickly (i.e. the next request will be fine). This is hard to handle; basically it shouldn't happen but there are many reasons why it could occur.
This error tells you, that the true error is somewhere in some child action, that is action rendered by Html.RenderAction().
There is no such thing as "random" error - there has to be scenario where it happens, you just dont know it because the conditions vary maybe.
You should identify all your child actions, and test them with various inputs.. after you identify the problematic input set, try disabling child actions one by one and find the error this way.

Resources