views:

129

answers:

2

I am having a problem with code that worked fine in .NET 2.0 but is giving this error under .Net 4.

Build (web): Inheritance security rules violated while overriding member: 'Controls.RelatedPosts.RenderControl(System.Web.UI.HtmlTextWriter)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.

This is in DotNetBlogEngine. There were several other security demands in the code that .NET 4.0 doesn't seem to like. I followed some of the advice I found on blogs (and here) and got rid of all the other errors. But this one still eludes me.

The Main BlogEngine core dll is not set for security demands any longer and is compiled for .NET 4.0 as well.

This error is in the website side attempting to use the dll. There are controls that call a RenderControl method taking an HtmlTextWriter. Apparently the text writer now has some soft of security attributes set on it.

Each of the controls implements a custom interface ( public interface ICustomFilter ), there are no security permissions present or demands. The site is running full trust on my local dev machine.

Update:

I have tried the various settings under the security namespace in .NET 4 I read about here. I know this is a code access security change, but I don't understand the why behind it not working (or the error message).

A: 

Set this attribute [assembly: SecurityRules(SecurityRuleSet.Level1)]

ref: http://msdn.microsoft.com/en-us/library/dd233102%28VS.100%29.aspx

Raj Kaimal
Yea, did that. It didn't work. I also tried level 2, and tried doing the same in the website instead of the dll. None of the combinations I tried worked. Thanks.
Jason Short
A: 

The only thing I needed to do to run under .net 4.0 was to add a reference to System.Web.ApplicationServices to the Core project.

rtur