2

I have tried many solutions for this simple error but I couldn't find bug what actually cause it.

Here is some code for reference.

GPController

[HttpPost("testConnection")]
        public bool TestConnection()
            {
            try
            {  
                var data = eConn.GetEntity();
                if (data)
                {
                    return true;
                } 
                return false;
            }
             catch(Exception ex)
            {
                throw ex;
            }
        }

eConn.cs

public static bool GetEntity()
        {
            try
            {
                string connString = DataAccess.ConnectionString;

                eConnectOut myRequest = new eConnectOut();
                myRequest.DOCTYPE = "Customer";
                myRequest.OUTPUTTYPE = 1;
                myRequest.INDEX1FROM = "Customer001";
                myRequest.INDEX1TO = "Customer001";
                myRequest.FORLIST = 1;
                // Create the eConnect requester XML document object
                RQeConnectOutType[] eConnectOutType =
                    new RQeConnectOutType[1] { new RQeConnectOutType()};
                eConnectOutType[0].eConnectOut = myRequest;
                eConnectType eConnectDoc = new eConnectType();
                eConnectDoc.RQeConnectOutType = eConnectOutType;
                // Serialize the object to produce an XML document
                MemoryStream memStream = new MemoryStream();
                XmlSerializer serializer = new XmlSerializer(typeof(eConnectType));
                serializer.Serialize(memStream, eConnectDoc);
                memStream.Position = 0;
                XmlDocument myDoc = new XmlDocument();
                myDoc.Load(memStream);
                eConnectMethods eConnCall = new eConnectMethods();
                eConnCall.RequireProxyService = false;
                // Retrieve the specified customer document
                string myCustomer = eConnCall.GetEntity(connString,  myDoc.OuterXml);
                return true;
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }

In eConn.cs calling GetEntity method I am getting this error.

{System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Dynamics.GP.eConnect.EventLogHelper.AddExceptionHeader(String action, Object[] inputParameters, StringBuilder errorString)
   at Microsoft.Dynamics.GP.eConnect.EventLogHelper.CreateEventLogEntry(Exception exception, String action, Object[] inputParameters)
   at Microsoft.Dynamics.GP.eConnect.eConnectMethods.GetEntity(String connectionString, String sXML)
   at AP.GPServices.Helper.eConn.GetEntity() in D:\projects\APSystem SM\Source Code\AP.GPServices\Helper\eConn.cs:line 46}

I am referring this Programmer guide.

http://www.mypurelogic.com/files/purelogic/files/manuals/econnectprogrammersguide.pdf

Cœur
  • 37,241
  • 25
  • 195
  • 267
Aarsh
  • 2,555
  • 1
  • 14
  • 32

0 Answers0