IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Presentation Foundation Discussion :

Index was outside the bounds of the array


Sujet :

Windows Presentation Foundation

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut Index was outside the bounds of the array
    Bonjour

    " Tour d'un coup" je me retrouve avec une erreur (dans le error list de visual studio) concernant mon fichier XAML.
    Cette erreure est
    Index was outside the bounds of the array
    Mais lorsque je clique dessus, cela me souligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
            <ObjectDataProvider x:Key="odpComboBoxLeft"
                        ObjectType="{x:Type ODP:UgmProvider}" />
    Je ne voit pas ou est l'erreur dans mon code XAML
    - Cela ne m'empêche pas de compiler mais du coup je n'accède plus aux méthodes des mes ObjectDataProvider.
    - Et le designer refuse de se charger tant que je n'ai pas résolu cette erreur.
    Voicis le contenu de ma page XAML.

    Merci pour votre aide

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    <UserControl x:Class="ADManagementIHM.Tabs.UGMTab"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ODP="clr-namespace:ADManagementIHM.ODP"
        xmlns:Styles="clr-namespace:ADManagementIHM.Styles"
        xmlns:Commons="clr-namespace:ADManagementIHM.Common">
        <UserControl.Resources>
            <ObjectDataProvider x:Key="odpComboBoxLeft"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpComboBoxRight"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpUgmUserGroupsLeft"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpUgmUserGroupsRight"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <ObjectDataProvider x:Key="odpOrganizationalUnits"
                        ObjectType="{x:Type ODP:UgmProvider}" />
            <Styles:UgmStyle x:Key="ugmStyleSelector"/>
            <Styles:UgmImgConverter x:Key="UgmImgConverter"/>
        </UserControl.Resources>
        <Grid Width="671.63" Height="517.298">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="261*" />
                <ColumnDefinition Width="155*" />
                <ColumnDefinition Width="256*" />
            </Grid.ColumnDefinitions>
            <!--Top Radio Buttons-->
            <RadioButton Name="rbUserMode" Height="16" Margin="0,21.671,96.686,0"  VerticalAlignment="Top"  GroupName="UGMMode" Click="rbMode_Checked" Grid.ColumnSpan="2" HorizontalAlignment="Right" Width="105.698">User Mode</RadioButton>
            <RadioButton Name="rbGroupMode" Height="16" Margin="35.007,21.671,10.002,0"  VerticalAlignment="Top" GroupName="UGMMode" Click="rbMode_Checked" Grid.Column="1">Group Mode</RadioButton>
            <RadioButton Name="rbTemplateMode" Height="16" Margin="125.025,21.671,186.704,0" VerticalAlignment="Top" GroupName="UGMMode" Click="rbMode_Checked" Grid.Column="1" Grid.ColumnSpan="2">Template Mode</RadioButton>
     
            <!--OU Comboboxes-->
     
            <ComboBox Name="cbRightOu" 
                      ItemsSource="{Binding}"
                      Margin="0,55.011,0,0"
                      DisplayMemberPath="Name"
                      Text="Please Select An OU"
                      VerticalAlignment="Top"
                      Grid.Column="2" 
                      SelectionChanged="LoadComboBox" Height="21.277" HorizontalAlignment="Left" Width="255.859" />
     
            <ComboBox Name="cbLeftOu"
                      SelectionChanged="LoadComboBox"
                      ItemsSource="{Binding}" DisplayMemberPath="Name"
                      Text="Please Select An OU"
                      Margin="0,55.011,0,0"  VerticalAlignment="Top"
                      />
     
     
            <!--Object Searched Comboboxes-->
            <ComboBox Name="cbListLeft" Height="23" Margin="0,87.769,0,0"
                      Focusable="true"  VerticalAlignment="Top" IsEditable="true"
                      IsReadOnly="False" IsTextSearchEnabled="True" DisplayMemberPath="Cn"
                      ItemsSource="{Binding}"
                      TextBoxBase.TextChanged="cbListLeft_TextChangedEventArgs"
                      DropDownClosed="cbListLeft_DropDownClosed" />
     
            <ComboBox Name="cbListRight" Height="23" Margin="0,87.769,0,0" 
                      VerticalAlignment="Top" Grid.Column="2"
                      IsEditable="True" DropDownClosed="cbListRight_DropDownClosed"
                      IsReadOnly="False" IsTextSearchEnabled="True"
                      DisplayMemberPath="Cn" ItemsSource="{Binding}"
                      SelectionChanged="cbList_SelectionChanged" />
     
     
            <!--Listviews-->
            <ListView Name="lvListLeft" Margin="0,129.948,0,53.344" 
                      DisplayMemberPath="Cn" ItemsSource="{Binding}" 
                      IsSynchronizedWithCurrentItem="True"
                      Styles:GridViewSort.AutoSort="True"
                      ItemContainerStyleSelector="{DynamicResource ugmStyleSelector}">
                <ListView.Resources>
                    <DataTemplate x:Key="imgLvLeft">
                        <Image Width="12" Height="12" Margin="1" Source="{Binding Path=. , Converter={StaticResource UgmImgConverter}}" />
                    </DataTemplate>
                </ListView.Resources>
     
                <ListView.View>
                    <GridView >
                        <GridViewColumn  Width="30" CellTemplate="{StaticResource imgLvLeft}" />
                        <GridViewColumn  Header="Name"  Width="190"  DisplayMemberBinding="{Binding Cn}" Styles:GridViewSort.PropertyName="Cn"/>
                        <GridViewColumn>
                            <CheckBox Name="cbSelectAllLvLeft" Click="lvLeftSelAll_Clicked"></CheckBox>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox  IsChecked="False"  HorizontalAlignment="Center">
                                    </CheckBox>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
     
            <ListView Name="lvListRight" Margin="0,129.948,0,53.344" 
                      DisplayMemberPath="Cn" ItemsSource="{Binding}" 
                      IsSynchronizedWithCurrentItem="True"
                      Styles:GridViewSort.AutoSort="True"
                      ItemContainerStyleSelector="{DynamicResource ugmStyleSelector}"
                      Grid.Column="2">
                <ListView.Resources>
                    <DataTemplate x:Key="imgLvRight">
                        <Image Width="12" Height="12" Margin="1" Source="{Binding Path=. , Converter={StaticResource UgmImgConverter}}" />
                    </DataTemplate>
                </ListView.Resources>
                <ListView.View>
                    <GridView >
                        <GridViewColumn  Width="30" CellTemplate="{StaticResource imgLvRight}" />
                        <GridViewColumn   Header="Name"  Width="190"  DisplayMemberBinding="{Binding Cn}" Styles:GridViewSort.PropertyName="Cn"/>
                        <GridViewColumn>
                            <CheckBox Name="cbSelectAllLvRight" Click="lvRightSelAll_Clicked"></CheckBox>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox IsChecked="False"  HorizontalAlignment="Center">
                                    </CheckBox>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
     
            <!--Actions Buttons-->
            <Button Name="btCompare" Grid.Column="1" Height="23" Margin="35.006,175.035,27.992,0"  VerticalAlignment="Top" Click="btCompare_Click">&lt;&lt; Compare &gt;&gt;</Button>
            <Button Name="btMoveToLeft" Grid.Column="1" Margin="35.007,0,27.992,175.035"  Click="btMoveToLeft_Click"  Height="22.199" VerticalAlignment="Bottom">&lt;&lt;</Button>
            <Button Name="btMoveToRight" Margin="35.007,0,27.992,223.75"  Grid.Column="1" Height="22.199" VerticalAlignment="Bottom" Click="btMoveToRight_Click">&gt;&gt;</Button>
            <Button Name="btHide" Height="23" Margin="35.006,223.378,27.992,0" VerticalAlignment="Top" Grid.Column="1" Click="btHide_Click" Tag="hide">Hide similar</Button>
            <Button Name="btRemSelect" Grid.Column="1" Height="23" Margin="35.006,0,27.993,53.344"  VerticalAlignment="Bottom" Click="btRemSelect_Click">Remove Selected</Button>
        </Grid>
     
    </UserControl>

  2. #2
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    C'est quoi le code de UgmProvider ?

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut
    Hello
    Merci pour la réponse. Suite à celle-ci j'ai fait un peu de ménage dans mon UGM Provider (code ci dessous). Maintenant l'erreur reste au même endroit mais est devenue.
    Type Not Found In config file
    Mais je n'ai pas d'autres indications et le projet compile toujours
    Merci pour ton aide.

    UGM Provider
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
     
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Text;
    using Rcb.ActiveDirectory;
    using Rcb.ActiveDirectory.Objects;
    using System.DirectoryServices;
    using ADManagementRemotInterface;
    using ADManagementIHM.Common;
    using System.Runtime.Remoting.Lifetime;
    using System.Runtime.Remoting;
     
     
    namespace ADManagementIHM.ODP
    {
        public class UgmProvider : ObservableCollection<ADObject>
        {
            private IADMADSearcher _remoteADSearcher;
            static Dictionary<string, ObservableCollection<ADObject>> _lstCbUserResult;
            static Dictionary<string, ObservableCollection<ADObject>> _lstCbUserGroupsResult;
            private ObservableCollection<ADOrganizationalUnit> _CbOuResult;
            //Constructor
            public UgmProvider()
            {            
                //_remoteADSearcher.Hub = ADManagementIHM.Properties.Settings.Default.HubName;
                _remoteADSearcher = (IADMADSearcher)ADMRemoting.GetRemoteObject(typeof(IADMADSearcher));
                _remoteADSearcher.Module = "Ugm";
     
                //This dictionnary is  shared . It avoids to  request the AD Everytime we switch The OU
                if (_lstCbUserResult == null) 
                    _lstCbUserResult = new Dictionary<string, ObservableCollection<ADObject>>();
                if (_lstCbUserGroupsResult == null)
                    _lstCbUserGroupsResult = new Dictionary<string, ObservableCollection<ADObject>>();
     
                _CbOuResult = new ObservableCollection<ADOrganizationalUnit>();
            }
     
            //Method to populate the combobox after "Mode" and the "OU" have been selected
            public ObservableCollection<ADObject> GetDirectoryEntryAdObject(string subOUName, DirectoryEntry entry, Type objectTypeSearched)
            {
     
                    if (objectTypeSearched == typeof(ADUser))
                    {
                        //To avoid reloading the content of the combobox for a specified OU we put the result in a shared list.
                        if (!(_lstCbUserResult.Keys.Contains(subOUName)))
                        {
                            _lstCbUserResult.Add(subOUName, new ObservableCollection<ADObject>());
                            foreach (ADObject adObj in _remoteADSearcher.GetUsers(entry.Path))
                            {
                                _lstCbUserResult[subOUName].Add(adObj);
                            }
                        }
                            return _lstCbUserResult[subOUName];
                    }
     
     
                    if (objectTypeSearched == typeof(ADUserGroup))
                    {
     
                        if (!(_lstCbUserGroupsResult.Keys.Contains(subOUName)))
                        {
                            _lstCbUserGroupsResult.Add(subOUName, new ObservableCollection<ADObject>());
                            foreach (ADObject adObj in _remoteADSearcher.GetUsersGroups(entry.Path))
                            {
                                _lstCbUserGroupsResult[subOUName].Add(adObj);
                            }
                        }
     
                        return _lstCbUserGroupsResult[subOUName];
                    }
                    return null;
            }
     
     
     
            //Overloaded for a list of DirectoryEntries
            public ObservableCollection<ADObject> GetDirectoryEntryAdObject(string subOUName, List<DirectoryEntry> lstEntry, Type objectTypeSearched)
            {
                foreach (DirectoryEntry entry in lstEntry) { GetDirectoryEntryAdObject(subOUName, entry, objectTypeSearched); };
                // Based ont he type searched, We return the corresponding list (ADUser or ADUserGroup)
                if (objectTypeSearched == typeof(ADUser))
                    return _lstCbUserResult[subOUName];
                else if (objectTypeSearched == typeof(ADUserGroup))
                    return _lstCbUserGroupsResult[subOUName];
                else return null;
            }
     
            //Methode to retreive the memberOf the Object selected in the combobox
            public ObservableCollection<ADObject> GetObjectMemberOf(DirectoryEntry entry, ADObject adObj)
            {
                ObservableCollection<ADObject> colResults = new ObservableCollection<ADObject>();
                // If the adObj is an UserGroup we have to retreived the potential users members as well
                if (adObj.IsUserGroup())
                {
                    ADUserGroup castedAdUserGroup = (ADUserGroup)adObj;
                    foreach (ADObject user in _remoteADSearcher.GetUsers(castedAdUserGroup))
                        colResults.Add(user);
     
                    foreach (ADObject group in _remoteADSearcher.GetGroups(castedAdUserGroup))
                        colResults.Add(group);
                }
     
     
     
                // If the adObj is an user we have to retreived the groups he's memberOf
                if (adObj.IsUser())
                {
                    ADUser castedUser = (ADUser)adObj;
                    foreach (ADObject user in _remoteADSearcher.GetGroups(castedUser))
                        colResults.Add(user);
                }
                return colResults;
            }
     
            //Methode of the objectDataProvider to retreive a list of UserGroups to populate the listbox
            public ObservableCollection<ADOrganizationalUnit> GetAllOU()
            {
                ObservableCollection<ADOrganizationalUnit> colResults = new ObservableCollection<ADOrganizationalUnit>();
                foreach (ADOrganizationalUnit obj in _remoteADSearcher.GetAllOU())
                    colResults.Add(obj);
                return colResults;
            }
     
     
            //Method to retreived the Template Groups
            public ObservableCollection<ADUserGroup> GetTemplateGroups()
            {
                ObservableCollection<ADUserGroup> colResults = new ObservableCollection<ADUserGroup>();
                foreach (ADUserGroup obj in _remoteADSearcher.GetUgmTemplateGroups())
                    colResults.Add(obj);
                return colResults;
            }
     
        }
    }

  4. #4
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Cela viendrait de cette ligne là que cela ne m'étonnerais pas:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    _remoteADSearcher = (IADMADSearcher)ADMRemoting.GetRemoteObject(typeof(IADMADSearcher));
    C'est quoi ces objets:
    - ADMRemoting.GetRemoteObject
    - IADMADSearcher

    ?

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2005
    Messages
    192
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2005
    Messages : 192
    Par défaut
    Hello
    Bien IADMADSearcher c'est une interface.
    Vu que mon projet utilise le .Net remoting, j'utilise cette IADMADSearcher pour me connecter à mon serveur qui me crée un objet proxy. Ce qui me permet ensuite d'instancier mes méthodes.
    Cependant j'utilisai déjà cet objet avant que cela plante.

  6. #6
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Et si tu met le code qui est dans le constructeur en commentaire ?

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Débutant] index was outside of the bounds of the array
    Par labib23dz dans le forum C#
    Réponses: 1
    Dernier message: 09/04/2012, 12h53
  2. Réponses: 0
    Dernier message: 25/01/2012, 15h34
  3. Réponses: 1
    Dernier message: 22/04/2010, 12h24
  4. ERREUR : Index was outside the bounds of the array
    Par maxwel56 dans le forum Linq
    Réponses: 1
    Dernier message: 06/02/2010, 10h40
  5. [VB.NET] Tableau "index was outside of bound array"
    Par guillaume1998 dans le forum VB.NET
    Réponses: 1
    Dernier message: 11/11/2005, 14h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo