i am trying to change the count attribute within instances, the xml is below
<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>
I have tried the following that i saw in another question, but i get the error “Object reference not set to an instance of an object.”
changeConfigXDoc.Root.Element("ServiceConfiguration").Element("Role").Element("Instances").Attribute("count").Value=ChangeInstanceText.Text;
You should take the namespace into consideration
Or