Error on an Icomparer Implementation. Please help !
I created an array sorter to sort arrays like in Win Explorer in a DNN module. As in the answer to a preview question:
Sorting an array of folder names like Windows Explorer (Numerically and Alphabetically) - VB.NET
A user is getting the following error (below) whenever they run the module, I'm not a particularly seasoned ASP.NET developer. Is this error caused becuase I used StrCmpLogicalW in my IComparer and is being used on a platform that does not support StrCmpLogicalW. Or is it caused becuase of a permissions issue.
Any help is much appriciated,
Thanks a huge 开发者_Go百科lot.
Here's the sorter that causes the error.
Public Class nvSorter
Implements IComparer(Of String)
Declare Unicode Function StrCmpLogicalW Lib "shlwapi.dll" ( _
ByVal s1 As String, _
ByVal s2 As String) As Int32
Public Function Compare(ByVal x As String, ByVal y As String) As Integer Implements System.Collections.Generic.IComparer(Of String).Compare
Return StrCmpLogicalW(x, y)
End Function
End Class
And this is the Exception stack trace :
InnerException: Failed to compare two elements in the array.
Message: DotNetNuke.Services.Exceptions.PageLoadException: Failed to compare two elements in the array. ---|> System.InvalidOperationException: Failed to compare two elements in the array. ---|> System.Security.SecurityException: System.Security.Permissions.SecurityPermission at Nukeville.Modules.SkinLab.View.nvSorter.Compare(String x, String y) at System.Collections.Generic.ArraySortHelper
1.SwapIfGreaterWithItems(T[] keys, IComparer
1 comparer, Int32 a, Int32 b) at System.Collections.Generic.ArraySortHelper1.QuickSort(T[] keys, Int32 left, Int32 right, IComparer
1 comparer) at System.Collections.Generic.GenericArraySortHelper1.Sort(T[] keys, Int32 index, Int32 length, IComparer
1 comparer) The type of the first permission that failed was: System.Security.Permissions.SecurityPermission The Zone of the assembly that failed was: MyComputer --- End of inner exception stack trace --- at System.Collections.Generic.GenericArraySortHelper1.Sort(T[] keys, Int32 index, Int32 length, IComparer
1 comparer) at System.Array.Sort[T](T[] array, Int32 index, Int32 length, IComparer1 comparer) at System.Array.Sort[T](T[] array, IComparer
1 comparer) at Nukeville.Modules.SkinLab.View.GetNVFolder(String ParentName, String[] cf) at Nukeville.Modules.SkinLab.View.GetJavaFolderArrays(String RootPath) at Nukeville.Modules.SkinLab.View.Page_PreRender(Object s, EventArgs e) at System.Web.UI.Control.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---
It's a security issue. You can't p/invoke StrCmpLogicalW() from a partial trust ASP.NET environment.
精彩评论