Reputation: 1543
Here is an issue that has bogged my mind for a while now. I have searched the breadths of the internet to no avail, and have at last come to ask SO for assistance.
I have a full .NET stack assembly project in VS2015 in which I have implemented RIA domain services. The RIA service is exposed to a Silverlight 5.0 client project over WCF (HTTP), where it is referenced as service reference. This triggers an automated code generation for the RIA proxy classes at the Silverlight project, which happens at build-time. This Silverlight project is the only location where I have this WCF RIA service referenced. The Silverlight project itself is referenced by two separate Silverlight applications.
This Silverlight project also contains partial classes that extend the RIA proxy classes. When building one of the Silverlight solutions, it often (but not always) throws errors for the partial classes that extend the RIA proxy classes. The generated code file with the proxy classes has disappeared (I assume because VS deletes it before recreating it), and the references in the partial class are broken.
As an example, this is a RIA generated proxy class (only showing the ExaminationResult
property, as it would otherwise become too lengthy):
public sealed partial class VCtp_DetailedResults : Entity
{
// ... more properties here
/// <summary>
/// Gets or sets the 'ExaminationResult' value.
/// </summary>
[DataMember()]
[Editable(false, AllowInitialValue=true)]
[Key()]
[Required()]
[RoundtripOriginal()]
[StringLength(11)]
public string ExaminationResult
{
get
{
return this._examinationResult;
}
set
{
if ((this._examinationResult != value))
{
this.OnExaminationResultChanging(value);
this.ValidateProperty("ExaminationResult", value);
this._examinationResult = value;
this.RaisePropertyChanged("ExaminationResult");
this.OnExaminationResultChanged();
}
}
}
}
And this is the partial extension:
namespace Apss.Data.Reports.Models
{
public partial class VCtp_DetailedResults : IRow, IRowCtp, IRowCustomer
{
public bool IsVisible { get; set; }
public bool IsSelected { get; set; }
public string ExaminationResultLocalized
{
get { return LocalisationHelper.GetString(ExaminationResult); }
}
}
}
The build error is:
As you can see in this screenshot:
My assumption is that VS goes through at least two iterations of compilation during a build, one where the local code is compiled, and another where the RIA proxy code is generated and compiled.
My question: how do I ensure that the build does not break with these partial proxy classes?
Upvotes: 0
Views: 153
Reputation: 5574
One approach is to take the generated code .g.cs
and check it into source, and then turn off RIA Service.
You can turn on RIA Service when your services change, much like how one would regenerate proxies if services changed.
Upvotes: 1