We have quite a large EPiServer 6 site that used PageTypeBuilder which is in the process of being upgraded to EPiServer 7. The site is compiling and we've worked through several runtime errors. We are now at the stage where the site actually runs and aspects of the CMS work, but we are having trouble displaying CMS pages.
When we try and the home page (and many other pages), we get the following error:
ContentData Cast. The requested type Site.PageTypes.Public.Home is not compatible with EPiServer.Core.PageData
Which seems strange because PageTypes.Public.Home inherits from PageData. The error occurs on this line:
There is another problem with the CurrentPage object elsewhere in the site, and we get errors like this:
Object reference not set to an instance of an object.
Which occurs at this seemingly innocent line:
TwitterAndFacebookButtons.FacebookImage = CurrentPage.FacebookThumbnail.OriginalString;
Both of these problems appear to be caused be a difference in the CurrentPage object. I have done some searching on the web but couldn't find anything that appeared relevant.
All of our page types inherit from EPiServer.Core.PageData.
Can you suggest any possible causes or solutions?
It sounds like you might have two different versions of EPiServer.dll loaded in your appdomain (you should see this if you attach to the process from visual studio and check in Debug/Windows/modules).
Do you still have references to PageTypeBuilder? my thought is that maybe PageTypeBuilder is built against another version of EPiServer than your templates and if you do not have a assembly redirect then both assemblies will be loaded into the appdomain. In that case PageData from one assembly is not assignable to PageData from the other assembly.
If this is the case assembly redirects in web.config should solve your problem.
Thanks for your reply,
There was a third party library (PageTypeExtensions) that had a dependency on PageTypeBuilder, however even with it included there was only one EPiServer.dll loaded. I have removed all references to it, cleaned and rebuilt to be sure that it wasn't causing the problem and the same issue occurs. There is still only one EPiServer.dll loaded and I have gone through all the modules and found no EPiServer related duplicates. The binaries loaded all appear to be of the correct version.
We have done upgrade from 6 to 7 then to 7.5(also removing PTB) as well and we have really similar exception on some of page types:
ContentData Cast. The requested type WebSite.StartPage is not compatible with Castle.Proxies.SpecificPageProxy
For some reason on specific page(that is not start page) CurrentPage is requested as StartPage therefore cast error.
How did you resolve this issue?
I've done the same upgrade as Gatis. Also stuck with the same problem.Did you manage to fix the problem Gatis?
Good Jens Qvist that you remainded me this.
So at the moment we are using 7.6.3 versions of CMS
We had this problem one select page that is page without template and is used as container to store data and it has numerous properties defined.
What we did to get rid of
[InvalidCastException: ContentData Cast. The requested type ***.PageTypes.StartPage is not compatible with Castle.Proxies.***PageProxy]
EPiServer.Core.ContentDataExtensions.Cast(ContentData content) +234
this exception is following:
Found that particular page type in CMS->Admin->Content type-> <find particular page type affected>-> Settings -> Revert to Default
That did the trick for me
I have not tested, but its possible that the same trick will work for other page types that have also templates, Jens Qvist can you confirm that?
Okay, I resolved this issue this way. and it's soooo stupid! :-DUnder Admin -> Config -> Manage WebsiteI noticed that the sitename was unknown and the local address was set to local.site.se
The problem was that the address I used in iis and hosts was local.siteupgrade.se
Sooooo, after setting a sitename, changing to the right address and adding the site in the hosts list in epi everything started working. My suggestion is that you check website-settings :-)
We are currently experiencing the same issue. We uppgraded from CMS 6R2 to 7.5 and 7.6.3 through nuget packages.
Startpage loads currently but no other. We get the following on random content page navigation (from startpage).
System.InvalidCastException: ContentData Cast. The requested type Public.BasePageData is not compatible with Castle.Proxies.PublicStartPageTypeProxy.
Our startpage inherits PageData, while most other inherit BasePageData wich in turn inherit PageData.This triggers our error handling module wich redirects to our Error page, there we get this.
System.InvalidCastException: ContentData cast. The requested type Public.ErrorPageType is not compatible with Castle.Proxies.PublicStartPageTypeProxy.
Anyone who has managed to sort this out ?
First, make sure under Admin->Config->Manage Websites that they have correct DNS names and languages.
Second, try Admin->Content Type->Page Type-> find particular page type-> Settings and click Revert to Default
This is how we sorted it out.
Manage websites corresponds with my local iis site, wich im running.
Revert to default only removed my path to the actual aspx file så it could no longer display the page, after adding it back i have the same error again.
by 'correct DNS name' I mean if you access your site trough myEpiSite make sure its there with appropriate language
my iis website is configured to be accessible with stfepi.local.
the url in manage website is "http://stfepi.local/" and by checking in hostnames there is also a "stfepi.local" culture was not set. We only have one language enabled on our website and i set the host name to that but it made no difference.
You dont need aspx there.
When you define page you have something like this:
public partial class MyPage : EPiServer.TemplatePage<MyPageModel> ...
[ContentType(GUID = "871F6CC7-04C0-4644-8424-F421F49C8CF5", DisplayName = "My Page")]
public class MyPageModel : EPiServer.Core.PageData
this way EPiServer does not need aspx to be specified because model and page are linked
My startpage was not strongly typed so i fixed it and now still loads, however when going to my default text page i still get:
System.InvalidCastException: ContentData Cast. The requested type STF_EPi.AppCode.PageTypes.Public.BasePageData is not compatible with Castle.Proxies.PublicStartPageTypeProxy
and the type and page looks like:
[ContentType(DisplayName = "[Publik] Löpande text", Order = 2, GUID = "F57E6D09-B9DC-462E-9995-FAA476AF295C")]
public class StandardPageType : BasePageData
public partial class StandardPage : TemplatePage<StandardPageType>
then it goes to redirect to error page and still get:
System.InvalidCastException: ContentData Cast. The requested type STF_EPi.AppCode.PageTypes.Public.ErrorPageType is not compatible with Castle.Proxies.PublicStartPageTypeProxy
and the type and page for error page looks like:
[ContentType(DisplayName = "[Publik] Felsida", Order = 10, GUID = "E4B38FAC-B605-4C36-B6F9-BB310777D7BC")]
public class ErrorPageType : BasePageData
public partial class ErrorPage : TemplatePage<ErrorPageType>
Also i have done the revert on all these thre page types.
Sorry, these two were reasons that helped us, when you figure out your reasons please share them here
So in manage websites you have added the hostname for your site? I think you might need to add "*" as hostname aswell, or maybe that just applies to multiple sites.
Have you checked your Guids? Do you have any duplicates for your pagetypes?
What does your BasePageData look like?
Mattias Jöraas Could you able to resolved your issue ? I'm facing the same problem and very keen to know how to resolve this
In my case turned out my Global.asax was not inherited by EpiServer.Global, wich solved this mostly. But i still have a pagetype that stol wants to be resolved from my startpage type proxy. Currently have the epi support working on my issues.
try Admin->Content Type->Page Type-> find particular page type-> Settings and click Revert to Default. This fixed my issue.
@Mattias Is epi support fixed that issue?