J'ai créé un trieur matriciel pour trier les tableaux comme dans Win Explorer dans un module DNN. Comme dans la réponse à une question d'aperçu:Erreur sur une implémentation Icomparer. S'il vous plaît aider!
Sorting an array of folder names like Windows Explorer (Numerically and Alphabetically) - VB.NET
Un utilisateur obtient l'erreur suivante (ci-dessous) chaque fois qu'ils courent le module, je ne suis pas un développeur ASP.NET particulièrement expérimenté. Cette erreur est-elle due au fait que j'ai utilisé StrCmpLogicalW dans mon IComparer et est utilisé sur une plateforme qui ne supporte pas StrCmpLogicalW. Ou est-ce causé par un problème d'autorisations?
Toute aide est très appriciated,
Merci beaucoup un énorme.
Voici le trieur qui provoque l'erreur.
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
Et ceci est la trace de pile d'exception:
InnerException: impossible de comparer deux éléments dans le tableau.
Message: DotNetNuke.Services.Exceptions.PageLoadException: Impossible de comparer deux éléments dans le tableau. --- |> System.InvalidOperationException: Impossible de comparer deux éléments dans le tableau. --- |> System.Security.SecurityException: System.Security.Permissions.SecurityPermission at Nukeville.Modules.SkinLab.View.nvSorter.Compare (String x, String y) à System.Collections.Generic.ArraySortHelper
1.SwapIfGreaterWithItems(T[] keys, IComparer
1 Comparatif, Int32 a, Int32 b) at System.Collections.Generic.ArraySortHelper1.QuickSort(T[] keys, Int32 left, Int32 right, IComparer
1 comparaison) Le type de la première autorisation qui a échoué était: System.Security.Permissions.SecurityPermission La zone de la 1) à l'adresse System.Collections.Generic.GenericArraySortHelper1.Sort(T[] keys, Int32 index, Int32 length, IComparer
1 comparaison) à System.Array.Sort [T] (tableau T [], index Int32, longueur Int32 , IComparer1 comparer) at System.Array.Sort[T](T[] array, IComparer
1 comparaison à Nukeville.Modules.SkinLab.View.GetNVFolder (String ParentName, String [] cf) à Nukeville.Modules.SkinLab.View.GetJavaFolderArrays (String RootPath) à Nukevill e.Modules.SkinLab.View.Page_PreRender (Object s, EventArgs e) à System.Web.UI.Control.OnPreRender (EventArgs e) à System.Web.UI.Control.PreRenderRecursiveInternal() à System.Web.UI.Control .PreRenderRecursiveInternal() à System.Web.UI.Control.PreRenderRecursiveInternal() à System.Web.UI.Control.PreRenderRecursiveInternal() à System.Web.UI.Control.PreRenderRecursiveInternal() à System.Web.UI.Control.PreRenderRecursiveInternal() à System.Web.UI.Control.PreRenderRecursiveInternal() à System.Web.UI.Control.PreRenderRecursiveInternal() à System.Web.UI.Control.PreRenderRecursiveInternal() à System.Web.UI.Control.PreRenderRecursiveInternal() à System.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- Fin de trace de pile d'exception interne ---
Y a-t-il des solutions pour que ce comparateur fonctionne également dans un environnement d'approbation partielle? Ou passer à un autre «tri alphabétique» simple si cela ne pouvait pas fonctionner? – Norman
Vous devrez implémenter 'StrCmpLogicalW()' dans le code managé, ce qui ne sera pas facile. Heureusement, [il y a de l'espoir] (http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting). –
Merci pour toute votre aide :) .. J'ai commencé une autre question ici: http://stackoverflow.com/questions/4165662/ toute aide serait appriciated. – Norman