Try our conversational search powered by Generative AI!

Error when trying a "Differences" compare

Vote:
 

When trying to do a "Differences" compare in v6 R1, I get a yellow screen of death with this:

Unable to cast object of type 'EPiServer.UI.Edit.PageCompare.Core.DummyWorkerRequest' to type 'System.Web.Hosting.IIS7WorkerRequest'.

Googling turns up nothing.  I have this problem on two different installs.

Any ideas?

#50585
May 04, 2011 21:40
Vote:
 

Have you got the complete stacktrace from the errorscreen?

Looks like some internal asp.net-code expects the workerrequestobject we use to create the phony HttpContext in order to be able to render page's html to be of type IIS7WorkerRequest, which it's not. (its inheriting from HttpWorkerRequest).

/johan

#50589
May 04, 2011 23:35
Vote:
 
InvalidCastException: Unable to cast object of type 'EPiServer.UI.Edit.PageCompare.Core.DummyWorkerRequest' to type 'System.Web.Hosting.IIS7WorkerRequest'.]
System.Web.EtwTrace.Trace(EtwTraceType traceType, HttpWorkerRequest workerRequest, String data1, String data2, String data3, String data4) +284
System.Web.EtwTrace.Trace(EtwTraceType traceType, HttpWorkerRequest workerRequest, String data1, String data2) +27
System.Web.Profile.SqlProfileProvider.GetPropertyValuesFromDatabase(String userName, SettingsPropertyValueCollection svc) +168
System.Web.Profile.SqlProfileProvider.GetPropertyValues(SettingsContext sc, SettingsPropertyCollection properties) +505
System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider) +400
System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName) +216
System.Configuration.SettingsBase.get_Item(String propertyName) +102
System.Web.Profile.ProfileBase.GetInternal(String propertyName) +49
System.Web.Profile.ProfileBase.get_Item(String propertyName) +129
EPiServer.Globalization.SystemLanguage.LanguagePreferenceList(String priorityLanguage) +147
EPiServer.Globalization.SystemLanguage.SetCulture(String priorityLanguage) +22
EPiServer.PageBase.InitializeCulture() +86
ASP.templates_public_pages_page_aspx.__BuildControlTree(templates_public_pages_page_aspx __ctrl) in c:\Sites\TriWestCustomDev\Templates\Public\Pages\Page.aspx:1
ASP.templates_public_pages_page_aspx.FrameworkInitialize() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\1bacfcf8\e4708475\App_Web_hcu0qge4.4.cs:0
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +72
System.Web.UI.Page.ProcessRequest() +119
System.Web.UI.Page.ProcessRequest(HttpContext context) +167
ASP.templates_public_pages_page_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\1bacfcf8\e4708475\App_Web_hcu0qge4.4.cs:0
EPiServer.UI.Edit.PageCompare.Core.PageComparerProviderBase.GetHtmlByDummyRequest(String pageUrl) +463
EPiServer.UI.Edit.PageCompare.Core.PageComparerProviderBase.GetHtmlFromPage(PageData pageData) +34
EPiServer.UI.Edit.PageCompare.VisualPageCompare.GetHtmlDiff(PageReference first, PageReference second, Int32 firstVersionNumber, Int32 secondVersionNumber) +281
EPiServer.UI.Edit.PageCompare.VisualPageCompare.OnLoad(EventArgs e) +358
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048
#50590
May 05, 2011 0:03
Vote:
 

uhm yeah...

A quick run through ILSpy (now Reflectors gone commercial) reveals that some internal code in EtwTrace assumes the given HttpWorkerRequest can be casted to an II7WorkerRequest....

The problem is that the flag determining the type of the workerequest (s_wrType) is static, and it's set the first time it gets called, probably from a "normal" webrequest (which of course really *is* of type IIS7WorkerRequest):

internal static void Trace(EtwTraceType traceType, HttpWorkerRequest workerRequest, string data1, string data2, string data3, string data4)
{
	if (EtwTrace.s_WrType == EtwWorkerRequestType.Undefined)
	{
		EtwTrace.ResolveWorkerRequestType(workerRequest);
	}
	if (EtwTrace.s_WrType == EtwWorkerRequestType.Unknown)
	{
		return;
	}
	if (workerRequest == null)
	{
		return;
	}
	if (EtwTrace.s_WrType == EtwWorkerRequestType.IIS7Integrated)
	{
		UnsafeNativeMethods.TraceRaiseEventMgdHandler((int)traceType, ((IIS7WorkerRequest)workerRequest).RequestContext, data1, data2, data3, data4);
		return;
	}
	if (EtwTrace.s_WrType == EtwWorkerRequestType.InProc)
	{
		UnsafeNativeMethods.TraceRaiseEventWithEcb((int)traceType, ((ISAPIWorkerRequest)workerRequest).Ecb, data1, data2, data3, data4);
		return;
	}
	if (EtwTrace.s_WrType == EtwWorkerRequestType.OutOfProc)
	{
		UnsafeNativeMethods.PMTraceRaiseEvent((int)traceType, ((ISAPIWorkerRequest)workerRequest).Ecb, data1, data2, data3, data4);
	}
}

    

Personally, I think this is a bug with the EtwTrace-code, 
and to be able to workaround, you would have to turn off tracing...

/johan

 

#50630
Edited, May 05, 2011 13:54
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.