我试图改变情境中的计数属性的属性值,则XML如下设置在XML
<ServiceConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" serviceName="" osFamily="1" osVersion="*"
xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
<Role name="WebRole1">
<ConfigurationSettings>
<Setting name="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
</ConfigurationSettings>
<Instances count="1" />
<Certificates />
</Role>
</ServiceConfiguration>
我已经试过,我在另一个问题看见下面的,但我得到的错误“对象引用未设置为对象的实例“。
changeConfigXDoc.Root.Element("ServiceConfiguration").Element("Role").Element("Instances").Attribute("count").Value=ChangeInstanceText.Text;
我想你可以摆脱'.Root.Element( “ServiceConfiguration”)'的,假设你的'changeConfigXDoc'代表上述XML的。或者试试删除'.Root'。 – 2012-03-26 21:15:07
尝试了两种方法,并且我继续得到错误“对象引用未设置为对象的实例”。 – StevenR 2012-03-26 21:57:16
试着将你的Root.Element链分离出来分离变量,以帮助确定Object未设置引用的位置。这可能会帮助您识别错误? – dreza 2012-03-26 22:06:45