Telerik
Skip Navigation LinksHome / Community / Forums / Silverlight > Window > Exception: Value does not fall within the expected range

Answered Exception: Value does not fall within the expected range

Feed from this thread
  • Carlos Rodriguez avatar

    Posted on Nov 10, 2009 (permalink)

    I have two RadWindow, the first opens the RadWindow to click on an button, and the second RadWindow opens when you click at a button within the first RadWindow and finally close the two RadWindow.

    When I want to reopen the first RadWindow I get the exception: " Value does not fall within the expected range"

    Heeeelp!!! =(

    Reply

  • Carlos Rodriguez avatar

    Posted on Nov 10, 2009 (permalink)

    I forgot to tell that in the first several textBlock RadWindow, there is a RadToolBar and RadTreeView, and the second RadWindow and several texbox textblock.

    Thanks

    Reply

  • Carlos Rodriguez avatar

    Posted on Nov 10, 2009 (permalink)

    Hello, I've found the error.
    The error is caused by the RadTreeView that was within the first RadWindow when select an item, close the window, when you reopen the window caused the error, because he had left an Item selected in the RadTreeView.

    I tried to give the value "false" RadTreeViewItem.IsSelected property did not work.

    Thank you!

    P.D. Excuse my English, I'm just learning.
     =)

    Reply

  • Telerik Admin admin's avatar

    Posted on Nov 13, 2009 (permalink)

    Hello Carlos,

    This seems like a bug in the TreeView.

    Can you please send us the CallStack when the exception happens?

    Please uncheck "Tools -> Options -> Debugging -> Enable Just My Code".

    Thank you for helping us identify this issue.

    Regards,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • Carlos Rodriguez avatar

    Posted on Jan 6, 2010 (permalink)

    System.ArgumentException:Value does not fall within the expected range 

    en MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
       en MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)
       en MS.Internal.XcpImports.Collection_Add[T](PresentationFrameworkCollection`1 collection, Object value)
       en System.Windows.PresentationFrameworkCollection`1.AddImpl(Object value)
       en System.Windows.Controls.ItemCollection.AddImpl(Object value)
       en System.Windows.Controls.ItemCollection.AddInternal(Object value)
       en System.Windows.PresentationFrameworkCollection`1.Add(T value)
       en ReqMaterial.Presentacion.Silverlight.Views.formSolicitud.consSolReqMaterial.cliente_consulta_PartidasAutorizarCompleted(Object sender, consulta_PartidasAutorizarCompletedEventArgs e)

    Reply

  • Telerik Admin admin's avatar

    Posted on Jan 11, 2010 (permalink)

    Hello Carlos Rodriguez,

    The exception "Value does not fall within the expected range" is thrown when an object that already exists in the visual tree of the appellation is added to it again. From your callstack it seems that this is what is happening, i.e. this method:

    ReqMaterial.Presentacion.Silverlight.Views.formSolicitud.consSolReqMaterial.cliente_consulta_PartidasAutorizarCompleted(Object sender, consulta_PartidasAutorizarCompletedEventArgs e)

    adds something to the visual tree that has not been removed from its previous parent:

    System.Windows.PresentationFrameworkCollection`1.Add(T value)

    Unfortunately I cannot guess what this may be. What happens in your code when all items in the TreeView are deselected? It seems that it is related to the error.

    If you could send us a project where the exception occurs, I will be happy to help you.

    All the best,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • Carlos Rodriguez avatar

    Posted on Jan 11, 2010 (permalink)

    Hi Miroslav!

    The exception and occurs when the tree is loaded first. I've been seeing that in executing the application, load normally, other occasions that exception occurs.

    Unfortunately I can not send the project, because I have no privileges on my account even send the projects.

    Thanks and greetings!

    Reply

  • Telerik Admin admin's avatar

    Posted on Jan 12, 2010 (permalink)

    Hello Carlos Rodriguez,

    Could you share the code in this method?

    ReqMaterial.Presentacion.Silverlight.Views.formSolicitud.consSolReqMaterial.cliente_consulta_PartidasAutorizarCompleted(Object sender, consulta_PartidasAutorizarCompletedEventArgs e)

    It seems that something there is causing the exception.

    All the best,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • Carlos Rodriguez avatar

    Posted on Jan 12, 2010 (permalink)

    This same method you ask:

    void

     

    cliente_consulta_PartidasAutorizarCompleted(object sender, consulta_PartidasAutorizarCompletedEventArgs e)

     

    {

     

        try
        
    {

     

     

            for (int i = 0; i < e.Result.Count; i++)

     

            {

                radTreVieParProgramacion.Items.Add(Agregar_TreVieItem(e.Result[i]));

            }

        }

     

        catch (Exception parException)

     

        {

        }

    }

    This is the method that creates the TreeViewItem:

     

    RadTreeViewItem

     

    Agregar_TreVieItem(object parObjGenerico)

     

    {

     

        try

     

        {

     

            RadTreeViewItem newRadItem = new RadTreeViewItem();

     

     

            Type TypObjeto = parObjGenerico.GetType();

     

     

            if (TypObjeto.Name == "objEntSolicitud")

     

            {

     

                objEntSolicitud objGenerico = (objEntSolicitud)parObjGenerico;

     

                newRadItem.Header =

    "Sol." + objGenerico.numIdeParEncabezado + " " + objGenerico.carDesBodega + " [" + objGenerico.carNomUsuario + "]";

     

                newRadItem.Name = objGenerico.numIdeParEncabezado.ToString();

                newRadItem.Tag = objGenerico;

                newRadItem.SetValue(

    ToolTipService.ToolTipProperty, newRadItem.Header);

     

                newRadItem.DefaultImageSrc =

    "../../Imagen/Button/folder_solicitud.png";

     

     

                return newRadItem;

     

            }

     

            else if (TypObjeto.Name == "objEntSolicitudDetalle")

     

            {

     

    objEntSolicitudDetalle objGenerico = (objEntSolicitudDetalle)parObjGenerico;

     

    newRadItem.Header = objGenerico.carDesProducto +

    " [" + objGenerico.numCanSolicitada + " " + objGenerico.carDesUniMedida + "]";

     

    newRadItem.Name = objGenerico.numIdeParDetalle.ToString();

    newRadItem.Tag = objGenerico;

    newRadItem.SetValue(

    ToolTipService.ToolTipProperty, newRadItem.Header);

     

    newRadItem.DefaultImageSrc =

    "../../Imagen/Button/partida.png";

     

     

    return newRadItem;

     

    }

     

    else if (TypObjeto.Name == "objEntParProgramacion")

     

    {

     

    objEntParProgramacion objGenerico = (objEntParProgramacion)parObjGenerico;

     

    newRadItem.Header = objGenerico.carDesProducto +

    " [" + objGenerico.numCanProgramada + "]";

     

    newRadItem.Name = objGenerico.numIdeParProgramacion.ToString();

    newRadItem.Tag = objGenerico;

    newRadItem.SetValue(

    ToolTipService.ToolTipProperty, newRadItem.Header);

     

    newRadItem.DefaultImageSrc =

    "../../Imagen/Button/partida.png";

     

     

    return newRadItem;

     

    }

     

    else if (TypObjeto.Name == "objEntTransMaterial")

     

    {

     

    objEntTransMaterial objGenerico = (objEntTransMaterial)parObjGenerico;

     

    newRadItem.Header = objGenerico.carDescripcion;

    newRadItem.Name = objGenerico.numIdeTransMaterial.ToString();

    newRadItem.Tag = objGenerico;

    newRadItem.SetValue(

    ToolTipService.ToolTipProperty, newRadItem.Header);

     

    newRadItem.DefaultImageSrc =

    "../../Imagen/Button/carpeta.png";

     

     

    return newRadItem;

     

    }

     

    return new RadTreeViewItem();

     

    }

     

    catch (Exception parException)

     

    {

     

    return new RadTreeViewItem();

     

    }

    }

    Reply

  • Carlos Rodriguez avatar

    Posted on Jan 12, 2010 (permalink)

    he problem is that causes the exception to add a first RadTrieeViewItem.

    Reply

  • Answer Telerik Admin admin's avatar

    Posted on Jan 12, 2010 (permalink)

    Hi Carlos Rodriguez,

    This line here may be the reason for the problem:

    newRadItem.Name = objGenerico.numIdeParEncabezado.ToString();

    it appears to me that quite possibly two items with the same name could be created in the same namescope. Namescopes can be surprising in Silverlight, even if an object is not visible (like a closed window) it may still be part of the current namescope.

    Could you try commenting the line to check whether the error is resolved. If it indeed is so, you may have to make sure that items with equal names are not added and that items are removed from their namescope before adding items with the same names.

    Does this work for you?

    Regards,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • Carlos Rodriguez avatar

    Posted on Jan 12, 2010 (permalink)

    Yes, there are two nodes that has the same name, but everyone is in different RadTreeView

    Reply

  • Telerik Admin admin's avatar

    Posted on Jan 12, 2010 (permalink)

    Hello Carlos Rodriguez,

    Quite possibly the two windows share the same namescope.

    Do you see the exception if the names are not set?

    We have no control over the namescopes in Silverlight, they are determined by the visual tree and whether the item is a part of a Template (DataTemplate or ControlTemplate), possibly other rules that I am not aware of.

    Regards,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • Carlos Rodriguez avatar

    Posted on Jan 12, 2010 (permalink)

    Agree, the only solution is to not assign a value to the parameter name, as you say is what runs the exception and that is the problem. Delete the line that assign values to the Name parameter and the exception no longer occurs.
    I think it's better that way and better to store the value in the Tag parameter.
    Miroslav'd appreciate your help, I was going crazy = P.
    thanks =)

    Reply

Back to Top

Skip Navigation LinksHome / Community / Forums / Silverlight > Window > Exception: Value does not fall within the expected range
Related resourses for "Exception: Value does not fall within the expected range"

Silverlight Window Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2010 Telerik. All rights reserved.