ASP.NET, Error Handling, Programming, Visual Studio 2010, Web Development

‘CreateResourceBasedLiteralControl’ is not a member of

When developing or deploying a Web site you may be confronted with the rather vague error message: ‘CreateResourceBasedLiteralControl’ is not a member of ‘PageName.aspx’.

I encountered this error today while deploying a site to our production  environment. The surprise was that I did not see this error when working on my local machine or our development server. I am still not sure why it did work on some machines but not others.

After spending some time tracking down the cause, I found it to be related to conflicts in control Naming on a Web page. This can be due to:

  1. Conflicts in the control IDs where two or more controls on the page share the same ID
  2. Setting the Inherits property of the @Page directive to the codebehind partial class of another page
  3. Setting the codebehind of the page itself to be a partial class for another page.

On reviewing my page it was clear that the site I was trying to deploy had  all three of these problems.

I had labels on the page that were set to the same ID, which was confusing the compiler.

Likewise, I had set the Inherits property to a codebehind file that was a partial class and that shared its Class name with the codebehind of another page. This sort of behavior can easily happen if one is putting in place new pages on a Web site by Copying and Pasting the pages.

I was able to resolve the error ( ‘CreateResourceBasedLiteralControl’ is not a member of ‘PageName.aspx’) by:

  1. Making sure the labels on the page had unique IDs
  2. Changing the Partial Class name of the codebehind file to the name of the Web page as I had intended
  3. Updating the Inherits property of the @Page directive to point to the newly renamed Partial Class name intended for the page

The mysterious error ( ‘CreateResourceBasedLiteralControl’ is not a member of ‘PageName.aspx’) vanished once I tracked down and corrected the issues mentioned above.

I hope this description &  resolution of the error I encountered today will help people looking for information on the cause of the rather vague error message.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s