Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Object reference not set to an instance of an object.

Object reference not set to an instance of an object.

Scheduled Pinned Locked Moved C#
helpquestioncsharpxmljson
12 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pierre besquent
    wrote on last edited by
    #1

    Hi guys, I have the above exception that appears to me when executing my code:

    protected void Page_Load (object sender, EventArgs e)
    {
    //Génération du fichier XML.
    if (this.Request ["ActionButton"] == "Generate")
    {
    string Json = "";
    // Initiation de la collection
    SLSalariesCollection salaries = new SLSalariesCollection (this._Session);
    salaries.Init ();
    // Création du fichier xml.
    string fileName = @"D:\New Folder\MyXmlff.xml";
    // Si le fichier existe effacer,
    if (System.IO.File.Exists (fileName))
    {
    System.IO.File.Delete (fileName);
    }
    XmlTextWriter myXmlTextWriter = new XmlTextWriter ("D:/New Folder/MyXmlff.xml",System.Text.Encoding.UTF8);
    myXmlTextWriter.Formatting = Formatting.Indented;
    myXmlTextWriter.WriteStartDocument(false);
    myXmlTextWriter.WriteStartElement("root");
    myXmlTextWriter.WriteAttributeString("xmlns","urn:iso:std:iso:20022:tech:xsd:pain.001.001.02");
    myXmlTextWriter.WriteStartElement("pain.001.001.02");
    int j = 0;
    // Récupérer la date d'Aujourd'huit de virement.
    DateTime Now = DateTime.UtcNow;
    string datevir = Now.ToString();
    // Attribut Batch booking
    Boolean batch = true;
    //formatter la collection de salariés.
    foreach (SLSalarie salari in salaries)
    {
    j++;
    Json = Json + "{succeed : 1}";
    myXmlTextWriter.WriteStartElement("Salarié", salari.Matricule);

    	    }
    		myXmlTextWriter.Flush();
                        myXmlTextWriter.WriteEndElement();
                        myXmlTextWriter.WriteEndElement();
    		myXmlTextWriter.Close();
    	    this.Response.ClearContent();
    	    this.Response.Write(Json);
    	    this.Response.End();
    			
    		}
    

    the problem that the code is sometimes excuting very well,sometimes no and appear to me this fatal EXCEPTION. I think that it is problem of refreshing my references.i did this.The first time, ok running very well,the second time EXCEPTION appears. when doing breakpoints,the problem appears in the collection'initiation.How can I solve that? also when reading about the class xmltextwriter,i know that i should treat that in my code c#.So do i should to add to my code to solve that? Thank u very much for u help hugs

    OriginalGriffO _ A L P 5 Replies Last reply
    0
    • P Pierre besquent

      Hi guys, I have the above exception that appears to me when executing my code:

      protected void Page_Load (object sender, EventArgs e)
      {
      //Génération du fichier XML.
      if (this.Request ["ActionButton"] == "Generate")
      {
      string Json = "";
      // Initiation de la collection
      SLSalariesCollection salaries = new SLSalariesCollection (this._Session);
      salaries.Init ();
      // Création du fichier xml.
      string fileName = @"D:\New Folder\MyXmlff.xml";
      // Si le fichier existe effacer,
      if (System.IO.File.Exists (fileName))
      {
      System.IO.File.Delete (fileName);
      }
      XmlTextWriter myXmlTextWriter = new XmlTextWriter ("D:/New Folder/MyXmlff.xml",System.Text.Encoding.UTF8);
      myXmlTextWriter.Formatting = Formatting.Indented;
      myXmlTextWriter.WriteStartDocument(false);
      myXmlTextWriter.WriteStartElement("root");
      myXmlTextWriter.WriteAttributeString("xmlns","urn:iso:std:iso:20022:tech:xsd:pain.001.001.02");
      myXmlTextWriter.WriteStartElement("pain.001.001.02");
      int j = 0;
      // Récupérer la date d'Aujourd'huit de virement.
      DateTime Now = DateTime.UtcNow;
      string datevir = Now.ToString();
      // Attribut Batch booking
      Boolean batch = true;
      //formatter la collection de salariés.
      foreach (SLSalarie salari in salaries)
      {
      j++;
      Json = Json + "{succeed : 1}";
      myXmlTextWriter.WriteStartElement("Salarié", salari.Matricule);

      	    }
      		myXmlTextWriter.Flush();
                          myXmlTextWriter.WriteEndElement();
                          myXmlTextWriter.WriteEndElement();
      		myXmlTextWriter.Close();
      	    this.Response.ClearContent();
      	    this.Response.Write(Json);
      	    this.Response.End();
      			
      		}
      

      the problem that the code is sometimes excuting very well,sometimes no and appear to me this fatal EXCEPTION. I think that it is problem of refreshing my references.i did this.The first time, ok running very well,the second time EXCEPTION appears. when doing breakpoints,the problem appears in the collection'initiation.How can I solve that? also when reading about the class xmltextwriter,i know that i should treat that in my code c#.So do i should to add to my code to solve that? Thank u very much for u help hugs

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Where does the exception happen? The message should tell you which line...

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      P 1 Reply Last reply
      0
      • P Pierre besquent

        Hi guys, I have the above exception that appears to me when executing my code:

        protected void Page_Load (object sender, EventArgs e)
        {
        //Génération du fichier XML.
        if (this.Request ["ActionButton"] == "Generate")
        {
        string Json = "";
        // Initiation de la collection
        SLSalariesCollection salaries = new SLSalariesCollection (this._Session);
        salaries.Init ();
        // Création du fichier xml.
        string fileName = @"D:\New Folder\MyXmlff.xml";
        // Si le fichier existe effacer,
        if (System.IO.File.Exists (fileName))
        {
        System.IO.File.Delete (fileName);
        }
        XmlTextWriter myXmlTextWriter = new XmlTextWriter ("D:/New Folder/MyXmlff.xml",System.Text.Encoding.UTF8);
        myXmlTextWriter.Formatting = Formatting.Indented;
        myXmlTextWriter.WriteStartDocument(false);
        myXmlTextWriter.WriteStartElement("root");
        myXmlTextWriter.WriteAttributeString("xmlns","urn:iso:std:iso:20022:tech:xsd:pain.001.001.02");
        myXmlTextWriter.WriteStartElement("pain.001.001.02");
        int j = 0;
        // Récupérer la date d'Aujourd'huit de virement.
        DateTime Now = DateTime.UtcNow;
        string datevir = Now.ToString();
        // Attribut Batch booking
        Boolean batch = true;
        //formatter la collection de salariés.
        foreach (SLSalarie salari in salaries)
        {
        j++;
        Json = Json + "{succeed : 1}";
        myXmlTextWriter.WriteStartElement("Salarié", salari.Matricule);

        	    }
        		myXmlTextWriter.Flush();
                            myXmlTextWriter.WriteEndElement();
                            myXmlTextWriter.WriteEndElement();
        		myXmlTextWriter.Close();
        	    this.Response.ClearContent();
        	    this.Response.Write(Json);
        	    this.Response.End();
        			
        		}
        

        the problem that the code is sometimes excuting very well,sometimes no and appear to me this fatal EXCEPTION. I think that it is problem of refreshing my references.i did this.The first time, ok running very well,the second time EXCEPTION appears. when doing breakpoints,the problem appears in the collection'initiation.How can I solve that? also when reading about the class xmltextwriter,i know that i should treat that in my code c#.So do i should to add to my code to solve that? Thank u very much for u help hugs

        _ Offline
        _ Offline
        _Erik_
        wrote on last edited by
        #3

        Pierre besquent wrote:

        the problem appears in the collection'initiation

        Then show us the collection constructor (and/or maybe its Init method) and show us when you create the _Session object.

        P 1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          Where does the exception happen? The message should tell you which line...

          Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

          P Offline
          P Offline
          Pierre besquent
          wrote on last edited by
          #4

          Hello, The exception appears when initiating my collection always:

          SLSalariesCollection salariers = new SLSalariesCollection (this._Session);
          salariers.Init ();

          also xmltextwriter,as I read in msdn it provides also an exception but i don't know how to treat it ty

          OriginalGriffO 1 Reply Last reply
          0
          • P Pierre besquent

            Hello, The exception appears when initiating my collection always:

            SLSalariesCollection salariers = new SLSalariesCollection (this._Session);
            salariers.Init ();

            also xmltextwriter,as I read in msdn it provides also an exception but i don't know how to treat it ty

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #5

            Then either the problem is in the constructor (which you don't show) or in the _Session class variable. We would need the code for the constructor and / or the variable load.

            Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            P 1 Reply Last reply
            0
            • _ _Erik_

              Pierre besquent wrote:

              the problem appears in the collection'initiation

              Then show us the collection constructor (and/or maybe its Init method) and show us when you create the _Session object.

              P Offline
              P Offline
              Pierre besquent
              wrote on last edited by
              #6

              Hi, I create a class library for my application that contains (_Session). Tha init method is very good built not have matter.It is seems in xmltextwriter exception

              _ 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                Then either the problem is in the constructor (which you don't show) or in the _Session class variable. We would need the code for the constructor and / or the variable load.

                Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

                P Offline
                P Offline
                Pierre besquent
                wrote on last edited by
                #7

                hi, this is the code of my load :

                protected override void OnLoad (EventArgs e)
                {
                try
                {
                // Ne pas inclure la page dans le cache client (Par défaut).
                _ApplyCacheStrategy ();
                // Titre.
                string pageTitle = this.PageTitle;

                			if (pageTitle != null && (
                				this.Title == null || this.Title == this.SessionData.PageTitleToOverride))
                			{
                				this.Title = pageTitle;
                			}
                			// Inclure le script pour la vérification des erreurs coté serveur.
                			\_AddCheckServerErrorScript ();
                			// Inclure le script pour la gestion des erreurs coté client.
                			\_AddJsReportingScript ();
                			// Avoir le jeton de l'application racine.
                			if (this.RootToken == null)
                				this.RootToken = \_GetRootToken ();
                			// Fixer la tâche en cours.
                			this.\_PageTask = new WEAppPageTask (this.PageTaskString);
                			// Vérifier l'accès à la page.
                			WEAppPageAccess						pageAccess;
                			// Récupérer en cours de la page - Récupération 1.
                			pageAccess = GetAccess ();
                			// Vérifier l'accès.
                			WEAppCheckingAccessResult			checkResult = \_CheckPageAccess (pageAccess);
                			// Récupérer à nouveau l'accès - Récupération 2.
                			pageAccess = GetAccess ();
                			// 1. Accès réfusé. Essayer de résoudre l'autorisation.
                			if (checkResult != WEAppCheckingAccessResult.AUTHORIZED\_ACCESS && !\_TryChangePageAccess (pageAccess, checkResult))
                			{
                				// Récupérer à nouveau l'accès - Récupération 3.
                				pageAccess = GetAccess ();
                				// Exécution du code de l'autorisation.
                				\_PageAccessDenied (pageAccess, checkResult);
                				// Générer une exception.
                				throw new BSCInvalidOperationException ("Method \_PageAccessDenied must throws exception or aborts current thread");
                			}
                			// Récupérer à nouveau l'accès - Récupération 4.
                			pageAccess = GetAccess ();
                			// Vérifier que l'accès est fourni.
                			if (pageAccess == null)
                				throw new BSCInvalidOperationException ("Null access");
                			// 2. Accès autorisé.
                			if (pageAccess.AccessWeight > -1)
                				pageAccess.AccessWeight --;
                			// Status de l'accès de la page.
                			pageAccess.PageAccessState = WEAppPageAccess.GetPageAccessState ();
                			this.PageAccessState = pageAccess.PageAccessState;
                			// Remplir la méthode de nettoyage d'accès si elle n'est pas renseignée.
                			if (pageAccess.PageAccessClean == null)
                				pageAccess.PageAccessClean = new WEAppPageAccessClean (PageAccessClean);
                			// Imposer la culture francaise au Thread en cours.
                			Thread.CurrentThread.CurrentCulture = this.AppCultureInfo;
                
                OriginalGriffO 1 Reply Last reply
                0
                • P Pierre besquent

                  hi, this is the code of my load :

                  protected override void OnLoad (EventArgs e)
                  {
                  try
                  {
                  // Ne pas inclure la page dans le cache client (Par défaut).
                  _ApplyCacheStrategy ();
                  // Titre.
                  string pageTitle = this.PageTitle;

                  			if (pageTitle != null && (
                  				this.Title == null || this.Title == this.SessionData.PageTitleToOverride))
                  			{
                  				this.Title = pageTitle;
                  			}
                  			// Inclure le script pour la vérification des erreurs coté serveur.
                  			\_AddCheckServerErrorScript ();
                  			// Inclure le script pour la gestion des erreurs coté client.
                  			\_AddJsReportingScript ();
                  			// Avoir le jeton de l'application racine.
                  			if (this.RootToken == null)
                  				this.RootToken = \_GetRootToken ();
                  			// Fixer la tâche en cours.
                  			this.\_PageTask = new WEAppPageTask (this.PageTaskString);
                  			// Vérifier l'accès à la page.
                  			WEAppPageAccess						pageAccess;
                  			// Récupérer en cours de la page - Récupération 1.
                  			pageAccess = GetAccess ();
                  			// Vérifier l'accès.
                  			WEAppCheckingAccessResult			checkResult = \_CheckPageAccess (pageAccess);
                  			// Récupérer à nouveau l'accès - Récupération 2.
                  			pageAccess = GetAccess ();
                  			// 1. Accès réfusé. Essayer de résoudre l'autorisation.
                  			if (checkResult != WEAppCheckingAccessResult.AUTHORIZED\_ACCESS && !\_TryChangePageAccess (pageAccess, checkResult))
                  			{
                  				// Récupérer à nouveau l'accès - Récupération 3.
                  				pageAccess = GetAccess ();
                  				// Exécution du code de l'autorisation.
                  				\_PageAccessDenied (pageAccess, checkResult);
                  				// Générer une exception.
                  				throw new BSCInvalidOperationException ("Method \_PageAccessDenied must throws exception or aborts current thread");
                  			}
                  			// Récupérer à nouveau l'accès - Récupération 4.
                  			pageAccess = GetAccess ();
                  			// Vérifier que l'accès est fourni.
                  			if (pageAccess == null)
                  				throw new BSCInvalidOperationException ("Null access");
                  			// 2. Accès autorisé.
                  			if (pageAccess.AccessWeight > -1)
                  				pageAccess.AccessWeight --;
                  			// Status de l'accès de la page.
                  			pageAccess.PageAccessState = WEAppPageAccess.GetPageAccessState ();
                  			this.PageAccessState = pageAccess.PageAccessState;
                  			// Remplir la méthode de nettoyage d'accès si elle n'est pas renseignée.
                  			if (pageAccess.PageAccessClean == null)
                  				pageAccess.PageAccessClean = new WEAppPageAccessClean (PageAccessClean);
                  			// Imposer la culture francaise au Thread en cours.
                  			Thread.CurrentThread.CurrentCulture = this.AppCultureInfo;
                  
                  OriginalGriffO Offline
                  OriginalGriffO Offline
                  OriginalGriff
                  wrote on last edited by
                  #8

                  That code doesn't set your _Session variable...

                  Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                  1 Reply Last reply
                  0
                  • P Pierre besquent

                    Hi, I create a class library for my application that contains (_Session). Tha init method is very good built not have matter.It is seems in xmltextwriter exception

                    _ Offline
                    _ Offline
                    _Erik_
                    wrote on last edited by
                    #9

                    The problem might be that _Session object is null when you create the collection, so you would be passing a null reference to it, and the null reference exception is thrown into that constructor when you try to access one of the _Session members.

                    1 Reply Last reply
                    0
                    • P Pierre besquent

                      Hi guys, I have the above exception that appears to me when executing my code:

                      protected void Page_Load (object sender, EventArgs e)
                      {
                      //Génération du fichier XML.
                      if (this.Request ["ActionButton"] == "Generate")
                      {
                      string Json = "";
                      // Initiation de la collection
                      SLSalariesCollection salaries = new SLSalariesCollection (this._Session);
                      salaries.Init ();
                      // Création du fichier xml.
                      string fileName = @"D:\New Folder\MyXmlff.xml";
                      // Si le fichier existe effacer,
                      if (System.IO.File.Exists (fileName))
                      {
                      System.IO.File.Delete (fileName);
                      }
                      XmlTextWriter myXmlTextWriter = new XmlTextWriter ("D:/New Folder/MyXmlff.xml",System.Text.Encoding.UTF8);
                      myXmlTextWriter.Formatting = Formatting.Indented;
                      myXmlTextWriter.WriteStartDocument(false);
                      myXmlTextWriter.WriteStartElement("root");
                      myXmlTextWriter.WriteAttributeString("xmlns","urn:iso:std:iso:20022:tech:xsd:pain.001.001.02");
                      myXmlTextWriter.WriteStartElement("pain.001.001.02");
                      int j = 0;
                      // Récupérer la date d'Aujourd'huit de virement.
                      DateTime Now = DateTime.UtcNow;
                      string datevir = Now.ToString();
                      // Attribut Batch booking
                      Boolean batch = true;
                      //formatter la collection de salariés.
                      foreach (SLSalarie salari in salaries)
                      {
                      j++;
                      Json = Json + "{succeed : 1}";
                      myXmlTextWriter.WriteStartElement("Salarié", salari.Matricule);

                      	    }
                      		myXmlTextWriter.Flush();
                                          myXmlTextWriter.WriteEndElement();
                                          myXmlTextWriter.WriteEndElement();
                      		myXmlTextWriter.Close();
                      	    this.Response.ClearContent();
                      	    this.Response.Write(Json);
                      	    this.Response.End();
                      			
                      		}
                      

                      the problem that the code is sometimes excuting very well,sometimes no and appear to me this fatal EXCEPTION. I think that it is problem of refreshing my references.i did this.The first time, ok running very well,the second time EXCEPTION appears. when doing breakpoints,the problem appears in the collection'initiation.How can I solve that? also when reading about the class xmltextwriter,i know that i should treat that in my code c#.So do i should to add to my code to solve that? Thank u very much for u help hugs

                      A Offline
                      A Offline
                      Abhinav S
                      wrote on last edited by
                      #10

                      Make sure this._Session is not null. This could be throwing the error.

                      The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.

                      1 Reply Last reply
                      0
                      • P Pierre besquent

                        Hi guys, I have the above exception that appears to me when executing my code:

                        protected void Page_Load (object sender, EventArgs e)
                        {
                        //Génération du fichier XML.
                        if (this.Request ["ActionButton"] == "Generate")
                        {
                        string Json = "";
                        // Initiation de la collection
                        SLSalariesCollection salaries = new SLSalariesCollection (this._Session);
                        salaries.Init ();
                        // Création du fichier xml.
                        string fileName = @"D:\New Folder\MyXmlff.xml";
                        // Si le fichier existe effacer,
                        if (System.IO.File.Exists (fileName))
                        {
                        System.IO.File.Delete (fileName);
                        }
                        XmlTextWriter myXmlTextWriter = new XmlTextWriter ("D:/New Folder/MyXmlff.xml",System.Text.Encoding.UTF8);
                        myXmlTextWriter.Formatting = Formatting.Indented;
                        myXmlTextWriter.WriteStartDocument(false);
                        myXmlTextWriter.WriteStartElement("root");
                        myXmlTextWriter.WriteAttributeString("xmlns","urn:iso:std:iso:20022:tech:xsd:pain.001.001.02");
                        myXmlTextWriter.WriteStartElement("pain.001.001.02");
                        int j = 0;
                        // Récupérer la date d'Aujourd'huit de virement.
                        DateTime Now = DateTime.UtcNow;
                        string datevir = Now.ToString();
                        // Attribut Batch booking
                        Boolean batch = true;
                        //formatter la collection de salariés.
                        foreach (SLSalarie salari in salaries)
                        {
                        j++;
                        Json = Json + "{succeed : 1}";
                        myXmlTextWriter.WriteStartElement("Salarié", salari.Matricule);

                        	    }
                        		myXmlTextWriter.Flush();
                                            myXmlTextWriter.WriteEndElement();
                                            myXmlTextWriter.WriteEndElement();
                        		myXmlTextWriter.Close();
                        	    this.Response.ClearContent();
                        	    this.Response.Write(Json);
                        	    this.Response.End();
                        			
                        		}
                        

                        the problem that the code is sometimes excuting very well,sometimes no and appear to me this fatal EXCEPTION. I think that it is problem of refreshing my references.i did this.The first time, ok running very well,the second time EXCEPTION appears. when doing breakpoints,the problem appears in the collection'initiation.How can I solve that? also when reading about the class xmltextwriter,i know that i should treat that in my code c#.So do i should to add to my code to solve that? Thank u very much for u help hugs

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        ..and loose the hugging.

                        I are Troll :suss:

                        1 Reply Last reply
                        0
                        • P Pierre besquent

                          Hi guys, I have the above exception that appears to me when executing my code:

                          protected void Page_Load (object sender, EventArgs e)
                          {
                          //Génération du fichier XML.
                          if (this.Request ["ActionButton"] == "Generate")
                          {
                          string Json = "";
                          // Initiation de la collection
                          SLSalariesCollection salaries = new SLSalariesCollection (this._Session);
                          salaries.Init ();
                          // Création du fichier xml.
                          string fileName = @"D:\New Folder\MyXmlff.xml";
                          // Si le fichier existe effacer,
                          if (System.IO.File.Exists (fileName))
                          {
                          System.IO.File.Delete (fileName);
                          }
                          XmlTextWriter myXmlTextWriter = new XmlTextWriter ("D:/New Folder/MyXmlff.xml",System.Text.Encoding.UTF8);
                          myXmlTextWriter.Formatting = Formatting.Indented;
                          myXmlTextWriter.WriteStartDocument(false);
                          myXmlTextWriter.WriteStartElement("root");
                          myXmlTextWriter.WriteAttributeString("xmlns","urn:iso:std:iso:20022:tech:xsd:pain.001.001.02");
                          myXmlTextWriter.WriteStartElement("pain.001.001.02");
                          int j = 0;
                          // Récupérer la date d'Aujourd'huit de virement.
                          DateTime Now = DateTime.UtcNow;
                          string datevir = Now.ToString();
                          // Attribut Batch booking
                          Boolean batch = true;
                          //formatter la collection de salariés.
                          foreach (SLSalarie salari in salaries)
                          {
                          j++;
                          Json = Json + "{succeed : 1}";
                          myXmlTextWriter.WriteStartElement("Salarié", salari.Matricule);

                          	    }
                          		myXmlTextWriter.Flush();
                                              myXmlTextWriter.WriteEndElement();
                                              myXmlTextWriter.WriteEndElement();
                          		myXmlTextWriter.Close();
                          	    this.Response.ClearContent();
                          	    this.Response.Write(Json);
                          	    this.Response.End();
                          			
                          		}
                          

                          the problem that the code is sometimes excuting very well,sometimes no and appear to me this fatal EXCEPTION. I think that it is problem of refreshing my references.i did this.The first time, ok running very well,the second time EXCEPTION appears. when doing breakpoints,the problem appears in the collection'initiation.How can I solve that? also when reading about the class xmltextwriter,i know that i should treat that in my code c#.So do i should to add to my code to solve that? Thank u very much for u help hugs

                          P Offline
                          P Offline
                          PrimeCoder
                          wrote on last edited by
                          #12

                          With: [ when doing breakpoints,the problem appears in the collection'initiation.How can I solve that? ] I think you meen this part of you code: [ // Initiation de la collection SLSalariesCollectio salaries = new SLSalariesCollection (this._Session); salaries.Init (); ] Did you check the value of 'this._Session' before initializing your collection?

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups