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. Web Development
  3. ASP.NET
  4. Problem with my windows service [modified]

Problem with my windows service [modified]

Scheduled Pinned Locked Moved ASP.NET
helpquestion
6 Posts 2 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.
  • G Offline
    G Offline
    gottimukkala
    wrote on last edited by
    #1

    Hi I am developing an windows service that sends email notifications to all not activated members and not published users. I tested my email notifications with a sample windows application but the same notifications are failing in my service. But I put all of the dlls in the same directory as my service exe file. Here is the piece that fails: SMPTServer = this.gs.SMTPServer; if (userEmail != "" && userEmail != null) { //Send Email Notification doXtop.Framework.Messaging.Message msg = new doXtop.Framework.Messaging.Message(); -- it fails here, but this works with my windows test application. } The service logged with "Object reference not set to an instance of an object." Can any give me ideas, how can I solve this.

    modified on Wednesday, March 18, 2009 12:47 PM

    H 1 Reply Last reply
    0
    • G gottimukkala

      Hi I am developing an windows service that sends email notifications to all not activated members and not published users. I tested my email notifications with a sample windows application but the same notifications are failing in my service. But I put all of the dlls in the same directory as my service exe file. Here is the piece that fails: SMPTServer = this.gs.SMTPServer; if (userEmail != "" && userEmail != null) { //Send Email Notification doXtop.Framework.Messaging.Message msg = new doXtop.Framework.Messaging.Message(); -- it fails here, but this works with my windows test application. } The service logged with "Object reference not set to an instance of an object." Can any give me ideas, how can I solve this.

      modified on Wednesday, March 18, 2009 12:47 PM

      H Offline
      H Offline
      Herman T Instance
      wrote on last edited by
      #2

      You might get the NUll reference because you first check if userEmail = "" It is more wise to create the next IF if (null != userEmail && !userEmail.Equals(String.Empty))

      G 1 Reply Last reply
      0
      • H Herman T Instance

        You might get the NUll reference because you first check if userEmail = "" It is more wise to create the next IF if (null != userEmail && !userEmail.Equals(String.Empty))

        G Offline
        G Offline
        gottimukkala
        wrote on last edited by
        #3

        Hi I checked it, it was not problem in the line of code that I posted but its the problem with doXtop.Framework.Messaging.Message msg = new doXtop.Framework.Messaging.Message(); This is strange. For me the following line of code is working but the above one is not working: doXtop.Framework.Messaging.Message.SendEmail("info@doXtop.com", userEmail, subject, message, SMTPServer);

        H 1 Reply Last reply
        0
        • G gottimukkala

          Hi I checked it, it was not problem in the line of code that I posted but its the problem with doXtop.Framework.Messaging.Message msg = new doXtop.Framework.Messaging.Message(); This is strange. For me the following line of code is working but the above one is not working: doXtop.Framework.Messaging.Message.SendEmail("info@doXtop.com", userEmail, subject, message, SMTPServer);

          H Offline
          H Offline
          Herman T Instance
          wrote on last edited by
          #4

          can/will you show the code of the messaging class?

          G 1 Reply Last reply
          0
          • H Herman T Instance

            can/will you show the code of the messaging class?

            G Offline
            G Offline
            gottimukkala
            wrote on last edited by
            #5

            Here is the code of my messaging class: public class Message : IDisposable { public Hashtable HtEmails; public HttpContext Context; public bool ThreadExecution = false; public string From; public string Subject; public string SmtpClient; public string Body; public string EmailProvider; public string Username; public string FullName; public string ActivationMessage; public Guid UserId; public GlobalSettings gs; public Uri Url; public string ApplicationPath; public enum Box { Inbox, Outbox } DataAccess _da; DataSource _ds; public Message() { _da = new DataAccess(); _ds = new DataSource(_da); ConfigurationProvider cp = new ConfigurationProvider(); gs = cp.GlobalSettings; } public bool InsertMessage(string from, string to, string subject, string body, string senderIPAddress) { try { SqlParameter[] _params = { new SqlParameter("@MessageId", Guid.NewGuid()), new SqlParameter("@From", from), new SqlParameter("@To", to), new SqlParameter("@Subject", subject), new SqlParameter("@Body", body), new SqlParameter("@SenderIPAddress", senderIPAddress) }; _ds.ExecuteNonQueryProcedureProxy("InsertMessage", _params); return true; } catch (Exception e) { EventLog.WriteEntry("WideDocs", e.ToString(), EventLogEntryType.Error); return false; } } }

            H 1 Reply Last reply
            0
            • G gottimukkala

              Here is the code of my messaging class: public class Message : IDisposable { public Hashtable HtEmails; public HttpContext Context; public bool ThreadExecution = false; public string From; public string Subject; public string SmtpClient; public string Body; public string EmailProvider; public string Username; public string FullName; public string ActivationMessage; public Guid UserId; public GlobalSettings gs; public Uri Url; public string ApplicationPath; public enum Box { Inbox, Outbox } DataAccess _da; DataSource _ds; public Message() { _da = new DataAccess(); _ds = new DataSource(_da); ConfigurationProvider cp = new ConfigurationProvider(); gs = cp.GlobalSettings; } public bool InsertMessage(string from, string to, string subject, string body, string senderIPAddress) { try { SqlParameter[] _params = { new SqlParameter("@MessageId", Guid.NewGuid()), new SqlParameter("@From", from), new SqlParameter("@To", to), new SqlParameter("@Subject", subject), new SqlParameter("@Body", body), new SqlParameter("@SenderIPAddress", senderIPAddress) }; _ds.ExecuteNonQueryProcedureProxy("InsertMessage", _params); return true; } catch (Exception e) { EventLog.WriteEntry("WideDocs", e.ToString(), EventLogEntryType.Error); return false; } } }

              H Offline
              H Offline
              Herman T Instance
              wrote on last edited by
              #6

              I believe your problem is this: public Hashtable HtEmails; public HttpContext Context; public bool ThreadExecution = false; public string From; public string Subject; public string SmtpClient; public string Body; public string EmailProvider; public string Username; public string FullName; public string ActivationMessage; public Guid UserId; public GlobalSettings gs; public Uri Url; public string ApplicationPath; they are mostly null. Havent you forget the { get; set; } to use them as properties? You do not use any of these publics in your class and you cannot set them from outside.

              In Word you can only store 2 bytes. That is why I use Writer.

              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