U4-9896 - SqlCEconnection Type A originates from Version=4.0.0.0, Type B originates from 4.0.0.1

Created by Douglas Robar 10 May 2017, 14:24:53 Updated by Shannon Deminick 19 May 2017, 01:55:01

Tags: Unscheduled

Relates to: U4-9918

Seen in 7.6.0 Experienced by three students on Fundamentals course. Couldn't determine steps to reproduce but I've got a zip file it it might help.

The issue is a dll version mis-match between the GAC, Temporary ASP.NET files, and the site's /bin folder. How that happened is not at all clear. Seems as though it was only new laptops that had never had Umbraco or SQLCE installed before. One student might have used nuget (didn't remember) but the others definitely didn't.

Very, very oddly, this error did not appear often. The back office and website ran fine most of the time. The most likely place for it to appear was when Preview'ing a web page, and creating a partial view macro file and then attempting to set Macro parameters or 'Use in the RTE'.

The following YSOD was typical: Server Error in '/' Application.

[A]System.Data.SqlServerCe.SqlCeConnection cannot be cast to [B]System.Data.SqlServerCe.SqlCeConnection. Type A originates from 'System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' in the context 'Default' at location 'C:\WINDOWS\assembly\GAC_MSIL\System.Data.SqlServerCe\4.0.0.0__89845dcd8080cc91\System.Data.SqlServerCe.dll'. Type B originates from 'System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91' in the context 'Default' at location 'C:\Users\Craig\AppData\Local\Temp\Temporary ASP.NET Files\root\3d0573c4\b3c7eb44\assembly\dl3\4be8d05e\00206b32_ac68d101\System.Data.SqlServerCe.dll'.

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.InvalidCastException: [A]System.Data.SqlServerCe.SqlCeConnection cannot be cast to [B]System.Data.SqlServerCe.SqlCeConnection. Type A originates from 'System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' in the context 'Default' at location 'C:\WINDOWS\assembly\GAC_MSIL\System.Data.SqlServerCe\4.0.0.0__89845dcd8080cc91\System.Data.SqlServerCe.dll'. Type B originates from 'System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91' in the context 'Default' at location 'C:\Users\Craig\AppData\Local\Temp\Temporary ASP.NET Files\root\3d0573c4\b3c7eb44\assembly\dl3\4be8d05e\00206b32_ac68d101\System.Data.SqlServerCe.dll'. 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: [InvalidCastException: [A]System.Data.SqlServerCe.SqlCeConnection cannot be cast to [B]System.Data.SqlServerCe.SqlCeConnection. Type A originates from 'System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' in the context 'Default' at location 'C:\WINDOWS\assembly\GAC_MSIL\System.Data.SqlServerCe\4.0.0.0__89845dcd8080cc91\System.Data.SqlServerCe.dll'. Type B originates from 'System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91' in the context 'Default' at location 'C:\Users\Craig\AppData\Local\Temp\Temporary ASP.NET Files\root\3d0573c4\b3c7eb44\assembly\dl3\4be8d05e\00206b32_ac68d101\System.Data.SqlServerCe.dll'.] SqlCE4Umbraco.SqlCEHelper.ExecuteReader(String commandText, SqlCeParameter[] parameters) +82 umbraco.DataLayer.SqlHelper`1.ExecuteReader(String commandText, IParameter[] parameters) +83

[SqlHelperException: Umbraco Exception (DataLayer): SQL helper exception in ExecuteReader] umbraco.DataLayer.SqlHelper`1.ExecuteReader(String commandText, IParameter[] parameters) +243 umbraco.cms.businesslogic.Content.get_Version() +178 umbraco.cms.businesslogic.web.Document.setupNode() +61 umbraco.cms.businesslogic.CMSNode..ctor(Int32 Id) +36 umbraco.presentation.dialogs.Preview.Page_Load(Object sender, EventArgs e) +97 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51 System.Web.UI.Control.OnLoad(EventArgs e) +95 umbraco.BasePages.BasePage.OnLoad(EventArgs e) +14 System.Web.UI.Control.LoadRecursive() +59 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1637.0

Comments

Douglas Robar 10 May 2017, 19:00:23

@nul800sebastiaan suggests the solution is to update the SQL CE assembly redirect in web.config to go to version 4.0.0.1.


Douglas Robar 15 May 2017, 09:47:58

Asked a student with the issue to try this assembly redirect update and that resolved the problem. Should be the default installation setting in nuget and .zip.


Paul Sterling 15 May 2017, 20:35:20

Some folks still see this error after adding the binding redirect when using Preview Mode. Viewing Published content the error does not get thrown.


Sebastiaan Janssen 15 May 2017, 20:52:30

@paul Let me know if you find a fix for that in U4-9918 please.


Sebastiaan Janssen 15 May 2017, 20:55:42

PR for adding the assembly redirect by default: https://github.com/umbraco/Umbraco-CMS/pull/1947


Priority: Normal

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.6.0

Due in version: 7.6.2

Sprint: Sprint 59

Story Points:

Cycle: