3
Vote

Error when adding new page: "Binary format of the specified custom attribute was invalid"

description

I followed the guides on http://tedgustaf.com/en/blog/2010/7/new-episerver-website-using-template-foundation/ and http://tedgustaf.com/en/blog/2011/3/create-new-episerver-site-with-etf/
Everything went well, until I try to create a new page in the CMS, I get an exception.
 
I'm using EPiServer CMS 6 R2, ETF 1.1 and Visual Studio 2010
.Net frameworks 3.5 en 4.0 are installed, but projects are created on .Net 3.5
 
 
I get the exception:
 

Server Error in '/' Application.

 
Binary format of the specified custom attribute was invalid.
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.Reflection.CustomAttributeFormatException: Binary format of the specified custom attribute was invalid.
 
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:
 
 
[CustomAttributeFormatException: Binary format of the specified custom attribute was invalid.]
System.Reflection.CustomAttributeEncodedArgument.ParseAttributeArguments(IntPtr pCa, Int32 cCa, CustomAttributeCtorParameter[]& CustomAttributeCtorParameters, CustomAttributeNamedParameter[]& CustomAttributeTypedArgument, IntPtr assembly) +0
System.Reflection.CustomAttributeEncodedArgument.ParseAttributeArguments(ConstArray attributeBlob, CustomAttributeCtorParameter[]& customAttributeCtorParameters, CustomAttributeNamedParameter[]& customAttributeNamedParameters, Module customAttributeModule) +212
System.Reflection.CustomAttributeData..ctor(Module scope, CustomAttributeRecord caRecord) +722
System.Reflection.CustomAttributeData.GetCustomAttributes(Module module, Int32 tkTarget) +182
System.Reflection.CustomAttributeData.GetCustomAttributes(MemberInfo target) +69
Castle.DynamicProxy.<GetNonInheritableAttributes>d__0.MoveNext() +114
Castle.DynamicProxy.Generators.MetaProperty.BuildPropertyEmitter(ClassEmitter classEmitter) +245
Castle.DynamicProxy.Contributors.CompositeTypeContributor.ImplementProperty(ClassEmitter emitter, MetaProperty property, ProxyGenerationOptions options) +42
Castle.DynamicProxy.Contributors.CompositeTypeContributor.Generate(ClassEmitter class, ProxyGenerationOptions options) +342
Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateType(String name, Type[] interfaces, INamingScope namingScope) +680
Castle.DynamicProxy.Generators.BaseProxyGenerator.ObtainProxyType(CacheKey cacheKey, Func`3 factory) +718
Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors) +141
PageTypeBuilder.Activation.TypedPageActivator.CreateInstance(Type typedType, Object[] ctorArguments) +75
PageTypeBuilder.Activation.TypedPageActivator.CreateAndPopulateTypedInstance(PageData originalPage, Type typedType) +18
PageTypeBuilder.PageTypeResolver.ConvertToTyped(PageData page) +61
PageTypeBuilder.Initializer.DataFactory_LoadedPage(Object sender, PageEventArgs e) +41
EPiServer.Core.PageStoreBase.RaisePageEvent(Object key, PageEventArgs eventArgs) +77
EPiServer.DataFactory.GetDefaultPageData(PageReference parentPageLink, Int32 pageTypeID, ILanguageSelector selector) +200
EPiServer.UI.Edit.EditPanel.CreateNewPageData() +281
EPiServer.UI.Edit.EditPanel.GetCurrentPage() +49
EPiServer.UI.Edit.EditPanel.get_CurrentPage() +32
EPiServer.UI.Edit.XFormPostings.GetCurrentPage() +46
EPiServer.UI.Edit.XFormPostings.PageContainsFormProperties() +20
EPiServer.UI.Edit.XFormPostings.List() +10
EPiServer.PlugIn.AssemblyTypeInfo.UseCustomLoader(Type type, PlugInAttribute matchAttribute, ArrayList list) +115
 
[PlugInException: A error occured while calling ICustomPlugInLoader.List from "EPiServer.UI.Edit.XFormPostings": Binary format of the specified custom attribute was invalid.]
EPiServer.PlugIn.AssemblyTypeInfo.UseCustomLoader(Type type, PlugInAttribute matchAttribute, ArrayList list) +528
EPiServer.PlugIn.AssemblyTypeInfo.ListPlugInDescriptorsForSort(PlugInAttribute matchAttribute, ArrayList list) +255
EPiServer.PlugIn.PlugInLocator.Search(PlugInAttribute matchAttribute) +180
EPiServer.UI.WebControls.TabStrip.LoadPlugIns() +109
EPiServer.UI.WebControls.TabStrip.OnInit(EventArgs e) +48
System.Web.UI.Control.InitRecursive(Control namingContainer) +143
System.Web.UI.Control.InitRecursive(Control namingContainer) +391
System.Web.UI.Control.InitRecursive(Control namingContainer) +391
System.Web.UI.Control.InitRecursive(Control namingContainer) +391
System.Web.UI.Control.InitRecursive(Control namingContainer) +391
System.Web.UI.Control.InitRecursive(Control namingContainer) +391
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1477
 

 

 

Version Information: Microsoft .NET Framework Version:2.0.50727.5420; ASP.NET Version:2.0.50727.5420

file attachments

comments

tednyberg wrote Apr 13, 2011 at 11:50 AM

Odd that there isn't a single TemplateFoundation entry in that stack trace. This is with ETF 1.1.0.7 and PTB 1.3, right? Does the exception occur for all page types? If not, could you paste the source code of the page type of the page you're creating?

Markiemark wrote Apr 13, 2011 at 6:03 PM

Yes, ETF 1.1.0.7 and PTB 1.3

The error occurs for all page types I create
This is my PageType definition for the startpage

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TemplateFoundation.PageTypes;
using PageTypeBuilder;

namespace ETFDemoSite35.Templates.PageTypes
{
[PageType(
    Name = "Start page",
    Description = "Start page template for editorial content",
    Filename = "/Templates/TemplatePages/StartPageTemplate.aspx")]
public class StartPage : StartPageBase
{

}
}


And this is my StartPageTemplate.aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.Web.WebControls;
using ETFDemoSite35.Templates.PageTypes;
using TemplateFoundation.PageTemplates;


namespace ETFDemoSite35.Templates.TemplatePages
{
public partial class StartPageTemplate : PageTemplateBase<StartPage>
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
}

It all compiles without errors and the PageType is create in the CMS
The error occurs when I create a new page in the CMS

Markiemark wrote Apr 13, 2011 at 8:45 PM

A little recap of the tests I did today

Tried to implement ETF 1.1 on EPiServer CMS 6 R2 / Visual Studio 2010 => Error
Tried to implement ETF 1.1 on EPiServer CMS 6 / Visual Studio 2008 => OK

Tried to implement only PageTypeBuilder on EPiServer CMS 6 R2 / Visual Studio 2010 => OK !!!!!
Added ETF and changed masterpage, pagetypes and template pages => Error :(

Funny thing is that the pagetypes are created correctly in the cms but I can't create any pages.
When I remove the pagetypes from the project en rebuild (pagetypes are still available in the cms) I can create pages!!

Also update to ETF 1.1.0.9 didn't help.

tednyberg wrote Apr 14, 2011 at 6:21 AM

Any chance you could attach a ZIP with the site folder + DB? You can skip the EPiServer assemblies in the bin folder. :)

wrote Apr 14, 2011 at 6:45 PM

Markiemark wrote Apr 14, 2011 at 6:45 PM

Sure, here you go.
Skipped the EPiServer assemblies, but left the others in.
Included database backup is SQL 2008 R2 Express

wrote Apr 17, 2011 at 5:01 PM

tsolbjor wrote May 25, 2011 at 11:31 AM

It is a problem related to different versions of the running EPiServer.dll version and the version that the pagetype is compiled with. Not sure how to fix it, other than recompile the project that specifies the PageTypes with the same EPiServer.dll version that the site is running with. Assembly-redirect doesnt seem to be enough.

I have the same problem when trying to create "modules" that can be reused on EPiServer sites. For now it seems that we have to maintain different packages that targets specific EPiServer versions.

Please let me know if you found a solution to this.

An issue is also registered at http://pagetypebuilder.codeplex.com/workitem/8277

tsolbjor wrote May 25, 2011 at 11:39 AM

It is a problem related to the EPiServer.dll version that the PageType is compiled with. It seems like it has to be the same as the running version.

Please let me know if you find a solution.

wrote May 25, 2011 at 11:41 AM

tsolbjor wrote May 31, 2011 at 8:05 AM

Switching to .Net 4.0 seems to fix the problem

tednyberg wrote May 31, 2011 at 8:30 AM

ETF 1.1 is compiled with .NET 3.5, ETF 1.2 is compiled with .NET 4.0. I will investigate to see if there is any problem with the published assemblies. Thanks!

tednyberg wrote Jun 15, 2011 at 8:31 AM

Note that ETF 1.2 is built for .NET 4.0. If you run into this problem it might be that you're targeting a different .NET framework version.

wrote Feb 13, 2013 at 10:34 PM