Udostępnij za pośrednictwem


Error “.NET property is write-only because it does not have a get accessor” throw when using System.Xml.XmlDocument().InnerText in BizTalk application running under .NET Framework 4.0

Error “.NET property
is write-only because it does not have a get accessor” throw when using System.Xml.XmlDocument().InnerText
in BizTalk application running under .NET Framework 4.0

Symptoms

Consider the
following scenario:

- You have a BizTalk application using Microsoft .NET 4.0 Framework.

You  
generate two variables which defined as System.Xml.XmlDocument type in this  
application.
  • You
    add a BizTalk Expression and write code in BizTalk
    Expression Editor in an orchestration as :

var1=new System.Xml.XmlDocument();

var2=var1.InnerText;

In this
scenario, an error message that resembles the following is logged:

   
  
  
 
  
  
  
  

Cause

The same code
worked well in previous BizTalk version which target .NET Framework
2.0/3.0/3.5. System.Xml.XmlDocument.InnerText property of .NET Framework 2.0 is
inherited from its base class System.Xml.XmlNode which defined as {set; get; }.
Please refer to this article for more information: https://msdn.microsoft.com/en-US/library/system.xml.xmldocument_properties(v=vs.80).aspx .

But for .NET
Framework 4.0, the {set;} has been overridden in System.Xml.XmlDocument. As
{get;} is still inherited from its base class System.Xml.XmlNode,  you can still call XmlDocument.InnerText in
C# project without any error in .NET Framework 4.0. It is not appropriate that
BTS XLANG compiler complains that InnerText property is write-only, because it
does have the {get;} accessor which is inherited from the parent.

======================================================================

public override string
InnerText

{

    set

    {

       
throw new
InvalidOperationException(Res.GetString("Xdom_Document_Innertext"));

    }

}

======================================================================

Microsoft has
confirmed this is a problem in BTS XLANG compiler.

Solution

If you need the
solution for this problem, please contact Microsoft Support: https://support.microsoft.com/contactus/ .

 

Best regards,

Rachel Huang