Re: Value/Reference Types - Oooooops!

From: Jerry Morton (JerryMorton233_at_mail.com)
Date: 10/10/04

  • Next message: Richard L Rosenheim: "Re: Saving dataset as nested XML"
    Date: 10 Oct 2004 11:01:37 -0700
    
    

    Hi Martin,
    I would prefer that the node returned from my function had no
    relationship to the private XmlDocument. Can XmlNodes even exist in
    isolation like this? i.e. without a parent XmlDocument? I appreciate
    that a CLONED node may not cause the same problems (like setting
    objNode.InnerXml=string.empty!) however this "cloning" does sound like
    a "memory leak waiting to happen"? This object persists for a long
    time too...

    The purpose of all this is to completely encapsulate a PRIVATE
    XmlDocument so that it can't be modified by code outside the class. I
    can't be the first person who want to do this :-)

    I still can't believe that a private member variable behaves this way.
    However, if it does then I can live with making "copies" of the
    document to pass back from functions. But does this mean that when I
    only want to pass one node of the document, I actually have to pass
    back an XmlDocument containing only that node?

    Martin Honnen <mahotrash@yahoo.de> wrote in message news:<eO5mqDfrEHA.3172@TK2MSFTNGP10.phx.gbl>...
    > Jerry Morton wrote:
    >
    >
    > > public XmlNode GetNodeByID(string sID)
    > > {
    > > //How do I return a "copy" of an XmlNode - The following line gets a
    > > compiler error: "Cannot create an instance of the abstract class or
    > > interface 'System.Xml.XmlNode'"
    > > XmlNode objNewNode = new XmlNode();
    >
    > You can clone nodes in the DOM e.g.
    > node.CloneNode(true)
    > to create a clone. However that cloned node still belongs to the same
    > ownerDocument as node so I can currently not assess whether that is of
    > any help to you.
    > Maybe you can explain in more detail how you want to consume the node
    > returned by that method.


  • Next message: Richard L Rosenheim: "Re: Saving dataset as nested XML"

    Relevant Pages

    • Access Denied to assembly.
      ... XmlDocument xmlDocument = new XmlDocument; ... HttpWebRequest request = ... Policy not being applied to reference at this time (private, custom, ...
      (microsoft.public.dotnet.framework)
    • Assembly access denied.
      ... XmlDocument xmlDocument = new XmlDocument; ... HttpWebRequest request = ... Policy not being applied to reference at this time (private, custom, ...
      (microsoft.public.biztalk.general)
    • Assembly acess denied
      ... XmlDocument xmlDocument = new XmlDocument; ... HttpWebRequest request = ... Policy not being applied to reference at this time (private, custom, ...
      (microsoft.public.dotnet.framework.aspnet)
    • Value/Reference Types - Oooooops!
      ... originally took from the documentation that as long as I didn't use ... XmlDocument are always passed by reference in method calls? ... I was writing a "wrapper" class around a PRIVATE XmlDocument but ... MyClass objMyClass = new MyClass; ...
      (microsoft.public.dotnet.xml)

    Loading