I hope you can help. I am doing some work with the Land Registry Business Gateway in the UK. I have a reference.cs file from them with code added from a web service reference. I have managed to reference all parts of the module except one. I am having issues instantiating the object as it is an implied array and will not take () at the end of the call but requires [2] (where 2 is the number of elements in the array. The code from the module is here:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3056.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.oscre.org/ns/eReg-Final/2011/RequestTitleKnownOfficialCopyV2_1")]
public partial class Q1ContactType : object, System.ComponentModel.INotifyPropertyChanged {
private Q3TextType nameField;
private Q1CommunicationType communicationField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=0)]
public Q3TextType Name {
get {
return this.nameField;
}
set {
this.nameField = value;
this.RaisePropertyChanged("Name");
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order=1)]
public Q1CommunicationType Communication {
get {
return this.communicationField;
}
set {
this.communicationField = value;
this.RaisePropertyChanged("Communication");
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName) {
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null)) {
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
My code is here:
request.Product.Contact = new Q1ContactType[2];
request.Product.Contact[0].Name = new LROfficialCopyTitleKnownV2_1.Q3TextType();
request.Product.Contact[0].Name.Value = "Allen Jones";
If I use () after the Q1ContactType it throws an error saying it needs []. If I put [] without a number it throws an error saying the array must be initialised. If I run it as it appears above I get the error Object reference not set to an instance of an object as the object has not been instantiated. The request.Product refers to the first parts of an xml document.