2

我已经为这个简单的错误尝试了许多解决方案,但我找不到真正导致它的错误。

这里有一些代码供参考。

GP控制器

[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;
            }
        }

eConn.cs调用 GetEntity 方法时,我收到此错误。

{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}

我指的是这个程序员指南。

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

4

0 回答 0