Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • jeeshna 6 posts 26 karma points
    Sep 05, 2012 @ 09:07
    jeeshna
    0

    Object reference not set to an instance of an object

    Hi,

    Due to performance issue , i have added the publishing code in thread

     try

                        {

                            HttpontextforMailSending gethttpcontextforpublish2 = new HttpontextforMailSending()

                            {

                                HttpContextReference = HttpContext.Current,

                                courseDocument = shortCourseDocument,

                                createdUser = new User(0)

                            };

                            Thread t2 = new Thread(PublishDocument);

                            t2.Start(gethttpcontextforpublish2);

                        }

                        catch

                        {

                        }

     

     private void PublishDocument(object input)

            {

                HttpontextforMailSending httpcontextformail = (HttpontextforMailSending)input;

                Document course = httpcontextformail.courseDocument;

                User createduser = httpcontextformail.createdUser;

                if (course != null && createduser != null)

                {

                    course.Publish(createduser);

                    umbraco.library.UpdateDocumentCache(course.Id);

                }

     

            }

     

    public class HttpontextforMailSending

        {

            public HttpContext HttpContextReference { get; set; }       

            public Document courseDocument { get; set; }

            public User createdUser { get; set; }

        }

     

    but i got "Object reference not set to an instance of an object" error on "course.Publish(createduser);"

     

    Please anyone help me to solving this.

     

    Thanks

    Jeeshna

  • jeeshna 6 posts 26 karma points
    Sep 05, 2012 @ 12:11
    jeeshna
    0

    Hi,

    May be this error is due to course.HttpContext. It  has null value. When i set it as "course.HttpContext = httpcontextformail.HttpContextReference;" it shows a warning

    "umbraco.cms.businesslogic.web.document.HttpContext  is obsolute. Do not use this . Get httpContext via regular ASP.Net methods instead". When i debug this code , i got HttpContext on httpcontextformail.HttpContextReference. But after executing  "course.HttpContext = httpcontextformail.HttpContextReference;",

    "course.HttpContext" still have null value.

     

    Please help me

  • jeeshna 6 posts 26 karma points
    Sep 07, 2012 @ 10:33
    jeeshna
    0

    At last done. The idea is call webservice from thread.

Please Sign in or register to post replies

Write your reply to:

Draft