Hi guys,
First of all, sorry for the long post.
I'm having a problem with a custom module. At the moment we're creating a bunch of custom modules and coming across the following Exception on a redirect in the first one:
A critical error has occurred.
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
A look into the Log Viewer shows a Page Load Exception with the following details:
RawURL: /[PageName]/[PageName]/tabid/53/ctl/Edit/mid/375/Default.aspx
AbsoluteURL: /Default.aspx
AbsoluteURLReferrer: http://[URL under NDA]/[PageName]/[PageName]/tabid/53/ctl/Edit/mid/375/Default.aspx
UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: a2bf43de-1927-491d-8fa1-c8ac2caa28ab
InnerException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: System.Threading.Thread.ResetAbort
StackTrace:
Message: DotNetNuke.Services.Exceptions.PageLoadException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Threading.Thread.ResetAbort() at DotNetNuke.Services.Exceptions.Exceptions.ThreadAbortCheck(Exception exc) at DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(PortalModuleBase ctrlModule, Exception exc) at C4Communication.Nuke.Modules.Sport.Codes.EditCode.Update_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) The action that failed was: Demand The type of the first permission that failed was: System.Security.Permissions.SecurityPermission The first permission that failed was: <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlThread"/> The demand was for: <PermissionSet class="System.Security.PermissionSet" version="1"> <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlThread"/> </PermissionSet> The granted set of the failing assembly was: <PermissionSet class="System.Security.PermissionSet" version="1"> <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/> <IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Allowed="None" UserQuota="1048576"/> <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Execution"/> <IPermission class="System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Level="Unrestricted" Unrestricted="true"/> <IPermission class="System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/> </PermissionSet> The refused set of the failing assembly was: <PermissionSet class="System.Security.PermissionSet" version="1"> <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode"/> </PermissionSet> The assembly or AppDomain that failed was: C4Communication.Nuke.Modules.Sport.Codes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null The method that caused the failure was: Void Update_Click(System.Object, System.EventArgs) The Zone of the assembly that failed was: MyComputer The Url of the assembly that failed was: file:///e:/inetpub/afl/bin/C4Communication.Nuke.Modules.Sport.Codes.DLL --- End of inner exception stack trace ---
The problem occurs post-save on an item content. the content is 2 text boxes, one with name (string) and one with a reference (string). The two are set as props in a class (CodeInfo) and the controller class (CodeController) saves it through a SqlDataProvider to a SQL 2005 Server. Once all those bits and pieces are done it does a Redirect back to the content page (Response.Redirect(NavigateUrl(), true)) and shows the content list again. it is displaying the content just fine, however, above the module (there is only one module on the page) it displays the critical error above. The full code for the event handler after which the error occurs is:
/// <summary>
/// Handles the <see cref="LinkButton.Click"/> event for the <see cref="EditCode.Update"/>
/// <see cref="LinkButton"/>.
/// </summary>/// <param name="sender">The <see cref="Object"/> source of the event.</param>
/// <param name="e">An <see cref="EventArgs"/> that contains event data.</param>
protected void Update_Click(object sender, EventArgs e)
{
try
{
CodeInfo itemInfo = new CodeInfo();
itemInfo.Id = this._id;
itemInfo.Name = this.Name.Text;
itemInfo.Reference = this.Reference.Text;
itemInfo.CreatedByUser = this.UserId;
if (this._id == 0 || DotNetNuke.Common.Utilities.Null.IsNull(this._id))
CodeController.AddCode(itemInfo);
else
CodeController.UpdateCode(itemInfo);
// refresh cache
this.SynchronizeModule();
this.Response.Redirect(Globals.NavigateURL(), true);
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
The problem occurs whether adding a new code or updating an existing one, or even when you cancel (in the edit screen) or delete a code.
Here is the code for the cancel and delete handlers:
/// <summary>
/// Handles the <see cref="LinkButton.Click"/> event for the <see cref="EditCode.Cancel"/>
/// <see cref="LinkButton"/>.
/// </summary>
/// <param name="sender">The <see cref="Object"/> source of the event.</param>
/// <param name="e">An <see cref="EventArgs"/> that contains event data.</param>
protected void Cancel_Click(object sender, EventArgs e)
{
try
{
this.Response.Redirect(Globals.NavigateURL(), true);
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
/// <summary>
/// Handles the <see cref="LinkButton.Click"/> event for the <see cref="EditCode.Delete"/>
/// <see cref="LinkButton"/>.
/// </summary>
/// <param name="sender">The <see cref="Object"/> source of the event.</param>
/// <param name="e">An <see cref="EventArgs"/> that contains event data.</param>
protected void Delete_Click(object sender, EventArgs e)
{
try
{
// only attempt delete if item exists
if (!DotNetNuke.Common.Utilities.Null.IsNull(this._id))
{
CodeController.DeleteCode(this.ModuleId, this._id);
//refresh cache
this.SynchronizeModule();
this.Response.Redirect(Globals.NavigateURL(), true);
}
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
This is the view page normally (i'm logged in as 'host')
|
TopPane
|
LeftPane
|
ContentPane
|
|
Codes |
| |
Visible By Administrators Only
|
| |
|
|
[codref] |
[code name] |
| | |
| |
RightPane
|
BottomPane
| |
Edit screen
Has anyone seen this? Ideas, suggestions, comments?
Thanks in advance.
/b.