Cannot create/shadow copy 'xyz' when that file already exists

A bug in ASP.NET and/or the development web server

You can vote at microsoft for this bug to be fixed

Or read about a possible workaround

NHibernate.HibernateException ----> NHibernate.Cache.NoCachingEnabledException

NHibernate.HibernateException : Could not instantiate cache implementation
  ----> NHibernate.Cache.NoCachingEnabledException : Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]

After upgrading to the latest version the site keeps throwing this error during initialization.

Update the following web.config section:

    <add key="use_second_level_cache" value="false" />

The 1.2 version of the NHibernate library introduces a new exception that warns for configuration mistakes. Since N2 mapping files are cache-enabled NHibernate needs to know the deal with caching. Of course if you want caching set the setting to true and configure "hibernate.cache.provider_class".

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Check your bin folder.

This exception can occur if there is compiled reference to a class no longer in a certain assembly. E.g. the N2.Edit.Web.EditPage class was moved from the N2.Edit to the N2 assembly. Make sure all dlls in the bin folder are updated to the latest version.

Parser Error Message: The resource file '/edit/App_LocalResources/Copy.aspx.it.resx' cannot be used, as it conflicts with another file with the same name.

Delete /edit/App_Resource/*.it.resx

These resources were moved to a sub-directory.

Could not find section 'castle' in the configuration file associated with this domain.

Update web.config

Version 1.2 comes with a new way of configuration. You'll need to remove the n2 and nhibernate configuration sections and add a castle configuration section:

            <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" />
              <!-- Required properties -->
                  <entry key="hibernate.connection.provider">NHibernate.Connection.DriverConnectionProvider</entry>
                  <entry key="hibernate.connection.connection_string_name">LocalSqlServer</entry>
                  <entry key="hibernate.cache.use_second_level_cache">false</entry>
                  <!-- MS SQL settings -->
                  <entry key="hibernate.connection.driver_class">NHibernate.Driver.SqlClientDriver</entry>
                  <entry key="hibernate.dialect">NHibernate.Dialect.MsSql2005Dialect</entry>

            <!-- Include default configuration settings -->
            <include uri="assembly://N2/Engine/n2.configuration.xml"/>
            <!-- Configuration of the services goes here, e.g. -->

Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

Some weirdness in XP SP 2

Deleting the folder C:\\Documents and Settings\\USERNAME\\Local Settings\\Application Data\\Microsoft\\Microsoft SQL Server Data\\SQLEXPRESS worked for me.


When viewing a page: Unable to cast object of type 'XXX' to type 'YYY'.

An item's TemplateUrl property points out a a template whose generic type cannot be assigned from it

E.g. with item types defined like this:

  • AbstractBaseType
    • Page
      • News
    • StartPage

The class Page's TemplateUrl property points out "/default.aspx" and default.aspx's code behind file is reads class _default : N2.Web.UI.Page<StartPage>. The problem is that an object of the Page class cannot be assigned to a property of the StartPage type. You can either let the Page return another template or change the defualt.aspx codebehind to class _default : N2.Web.UI.Page<AbstractBaseType>.


Method not found: 'System.Nullable1 N2.ContentItem.get_Published()'.

In the N2 version 1.2.3 the published property was made nullable.

DateTime Published was changed into DateTime? Published

If you've been overriding this property or programmatically doing anything with it you will probably need re-reference the latest version of N2.dll and recompile to find out what needs to be fixed.

Could not load file or assembly 'NHibernate.Caches.SysCache' or one of its dependencies. The system cannot find the file specified.

You need to manually copy NHibernate.Caches.SysCache.dll from the lib folder to the bin folder

The following types may not be used as proxies:

Exception Details: NHibernate.InvalidProxyTypeException: The following types may not be used as proxies:
MyClassName: method MyMethodName should be virtual

Just follow the instructions

NHibernate and thus N2 does lazy-loading by dynamically subclassing your content classes and proxying method invocations. This is quite useful but a side effect is that properties must be made virtual.

'MyCustomAttribute' does not implement inherited abstract member 'N2.Details.AbstractEditableAttribute.AddEditor(System.Web.UI.Control)'

Minor breaking change between 1.3.1 and 1.3.2

The AbstractEditableAttribute now implements AddTo but requires you to implement AddEditor instead (before version 1.3.2 you had to explicitly add the container elements and label yourself).

Duplicate import: N2.Edit.Wizard.Items.Wonderland refers to both N2.Edit.Wizard.Items.Wonderland, N2.Edit, and N2.Edit.Wizard.Items.Wonderland, N2.Edit.Wizard

Old dll's

Since version 1.3.2 the edit interface dll's are sometimes ILMerged into one assembly: N2.Edit.dll. To fix the problem remove all dll's N2.Edit.*.dll Except N2.Edit.dll itself.

I'm having troubles upgrading to 1.3.3

Weird exceptions or can't create items.

Here are the known pits and a ladder

Exception: A plugin named 'versions' is already defined, assembly: N2.Edit.Versions
Resolution: delete bin\\n2.edit.versions.dll

Exception: There is a component already registered for the given key n2.parts.createHandler
Resolution: delete bin\\n2.parts.dll

Exception: Could not load file or assembly 'N2.Parts' or one of its dependencies.
Resolution: remove any project references to n2.parts
remove in web.config: <add tagPrefix="n2" assembly="N2.Parts" namespace="N2.Parts.Web.UI.WebControls"/>

Exception: Unknown server tag 'n2:Toolbar'.
Resolution: change code to <n2:DraggableToolbar

Problem: Can't create some pages. They appear on /edit/install/diagnose.aspx and all.
Resolution: change your code, add a [N2.Definition] attribute to all your content classes

NHibernate.MappingException : Could not compile the mapping document: (unknown)

Did you upgrade to nhibernate 2.0?

This may be caused by not removing the "hibernate." part in your configuration keys.

Invalid object name 'n2Item'.

The database defined by the connection string in web.config doesn't contain any N2 tables.

You can setup database through /edit/install

Cannot use a leading .. to exit above the top directory.

Exception Details: System.Web.HttpException: Cannot use a leading .. to exit above the top directory.

Stack Trace:
[HttpException (0x80004005): Cannot use a leading .. to exit above the top directory.] System.Web.Util.UrlPath.ReduceVirtualPath(String path) +3527398

This is a bug in asp.net's Context.RewritePath

N2 uses Context.RewritePath for it's friendly url feature. Unfortunatly when this method is used from certain user-agents (such as most search spiders) a bug in asp.net 2.0 is triggered which effectively prevent the site from beeing crawled and indexed.


More information:

  • Problems with RewritePath and Search Engines.
  • How to disappear from Google, Yahoo, MSN etc... indexes with CommunityServer 2.0 in less than a week...
  • Get GoogleBot to crash your .NET 2.0 site

What's this error?

I'm using MySQL and get this error: #22001Data too long for column 'StringValue' at row 1 

When installing the database on MySQL a column gets the wrong type.

To fix it you can:

  • change the type of the column named StringValue from VARCHAR(255) to LONGTEXT
  • or re-create the database with this corrected sql script

What is this ArgumentNullException?

Value cannot be null.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: methodInfo

Line 78: NHSessionFactory = NHConfiguration.BuildSessionFactory();


This can heppen when you only override the getter of a base class property.


public override int SortOrder
get { return CalculateMyCustomSortOrder(); }
// no setter

There is a component already registered for the given key n2.templates.seo.definitions

Version 1.3.5 consolidates a few libraries. If you upgraded to this version you should delete n2.templates.seo.dll, n2.templates.syndication.dll and n2.templates.security.dll.

The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ehh?

Copy the file lib\\System.Data.SQLite.DLL to src\\wwwroot\\bin.