We migrated our codes from .Net Framework 2.0 to .Net Framework 4.0, but when we tested it we encountered an error which is about "Object reference not set to an instance object".
We tried to look for possible solution for this and saw this article about obsolete types and members of .Net Framework 4.0 https://msdn.microsoft.com/en-us/library/ee471421(v=vs.100).aspx. One of the members that was listed there is being used in one of our class namely "System.Xml.Serialization.XmlSerializer" but still even though that we keep building our solution no errors are being found. Is this really the behavior of an obsolete member/type? Or do you think that the error regarding "Object reference not set to an instance object" is related to these obsolete member/type?
#region Variables Setup
//Declare Variables
string orderUID = string.Empty;
string input = string.Empty;
APSArchitecture.Tools.APSLogData logData = null;
XmlDocument bodyDoc = null;
IBaseMessagePart bodyPart = null;
const string APSHEADER_PARTNAME = "APSHeader";
APSArchitecture.Tools.Serialization.APSHeader apsHeader = null;
APSArchitecture.Pipelines.NonSeekMemoryStream APSHdrStream = null;
APSArchitecture.Pipelines.NonSeekMemoryStream copyOfBodyStream = null;
**XmlSerializer serializer** = null;
Microsoft.BizTalk.Message.Interop.IBaseMessagePart part = null;
string partname = string.Empty;
XmlNamespaceManager nsmgr = null;
Stream originalBodyStream = null;
#endregion
#region Init Variables
//Initial Variables
try
{
logData = new APSArchitecture.Tools.APSLogData();
logData.SrcSystem = "AssignOrderUID.Execute";
bodyDoc = new XmlDocument();
bodyPart = pInMsg.BodyPart;
originalBodyStream = bodyPart.Data;
copyOfBodyStream = new NonSeekMemoryStream();
//
// Copy the original message to the copy stream for reading of the xml.
//
const int ONE_K = 1024;
byte[] buffer = new byte[ONE_K];
int readSize = 0;
while((readSize = originalBodyStream.Read(buffer,0,ONE_K)) != 0)
{
copyOfBodyStream.Write(buffer,0,readSize);
}
copyOfBodyStream.Seek(0,SeekOrigin.Begin);
}
catch(System.Exception ex)
{
string error = ex.Message;
if(ex.InnerException != null)
error = error + " Inner Exception Details: " + ex.InnerException.Message;
throw new ApplicationException("Error initilalizing AssignOrderUID Execute method. Exception Details: " + error, ex);
}