Thomas Gathings II
hey buddy, the truth hurts.

ASP.Net 2.0 CS0716: Cannot convert to static type 'System.Web.Security.Roles'

Monday, April 10, 2006 11:33 AM

I have a simple page which displays the current users active roles. Silly me, I thought a good name would be 'Roles'.

Turns out, this caused a namespace collision, I think, with the static class System.Web.Security.Roles. The namespace 'System.Web.Security' is included by default with ASP.NET 2.0 code-behinds. Also of interest, by default there are no namespace regions with code-behinds. Not wanting to stray from the typified lazy developer, I left this as-is. Hey, Microsoft knows best.

This error only appeared on the release to production, as I chose the 'Publish Web Site' deployment method, where I was using the 'Copy Web Site' deployment method to our QA server. For some reason, only the former method yields this error.

The fix? Changed 'Roles' to '_Roles'. Alternatively, I could have enclosed the class in a namespace.


Feedback

# re: ASP.Net 2.0 CS0716: Cannot convert to static type 'System.Web.Security.Roles'

Thanks so much for that. Had the same problem with a class called Consol that worked on XP, but not on Server2003.

Namespaces are important;-) 8/5/2008 7:36 PM | Pete

# re: ASP.Net 2.0 CS0716: Cannot convert to static type 'System.Web.Security.Roles'

Sorry that was Console. 8/5/2008 7:37 PM | Pete

# re: ASP.Net 2.0 CS0716: Cannot convert to static type 'System.Web.Security.Roles'

I had the same error on Win. 2003 server with System.Web.Security.Membership class

membership.aspx page breaks down.

I also use windows 2003 on my local server and it didn't give any error until I deploy it to my web server.

Thanks for this explanation... 10/15/2008 2:30 AM | Altuğ Can Aldanmaz

Post a comment