Quantcast
Channel: Rebex Q&A Forum - Recent questions and answers
Viewing all articles
Browse latest Browse all 3862

Object reference not set to an instance of an object.

$
0
0

So I know this is a pretty common problem and but it's showing itself in a very unique way. I have built a program that basically retrieves emails via IMAP and then resends them. I build the program originally in test format under a windows console program. It works perfect. I built a windows service project and have installed it successfully and have it running the code starting fine. The issue is the exact same code in windows service gives me the Object ref not set. I have tried everything that i can think of. Added right, installed the dlls in the GAC, put the files with the EXE. Below is the sample code. Any help would be greatly appreciated. The error code I'm catching is "Object reference not set to an instance of an object"

using imap As New Rebex.Net.Imap()

    Dim mydb As New mySqlDB
        mydb.executeDMLSQL("insert into o365pocdb.poc_log (server, type, data, POC) values ('"& Server & "','Perf-Log','POC Started','"& Username & "')", sresult)

        Try
            mydb.executeDMLSQL("insert into o365pocdb.poc_log (server, type, data, poc) values ('"& Server & "','error','connected fine',' ')", sresult)
            imap.Connect(hostname, SslMode.Implicit)
            imap.Login(Username, Password)
            imap.SelectFolder("Inbox")

        Catch ex As Exception
        'mydb.executeDMLSQL("insert into o365pocdb.poc_log (server, type, data, poc) values ('"& Server & "','error','"& ex.Message & "',' ')", sresult)
        mydb.executeDMLSQL("insert into o365pocdb.poc_log (server, type, data, poc) values ('"& Server & "','error','Going to exit sub - cant connct','"& ex.Message & "')", sresult)
        Exit Sub
    End Try

Viewing all articles
Browse latest Browse all 3862

Trending Articles