我完成了我的申请编码.但是,当我点击开始按钮时,我的应用程序引发了一个例外..:'(
A first chance exception of type 'System.Runtime.Serialization.InvalidDataContractException' occurred in System.Runtime.Serialization.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
A first chance exception of type 'System.Runtime.Serialization.InvalidDataContractException' occurred in System.Runtime.Serialization.dll
Run Code Online (Sandbox Code Playgroud)
所以我看到'Application_UnhandledException'的参数e,我可以知道原因."'Type'GPACalculator.Subject'无法序列化.请考虑使用DataContractAttribute属性对其进行标记,并使用DataMemberAttribute属性标记要序列化的所有成员."
我只是使用默认数据类型来创建我的类.
public class Subject : INotifyPropertyChanged
{
private string name;
private GradePoint gradePoint;
private int credit;
public Subject(string name)
{
Name = name;
GradePoint = new GradePoint();
}
public string Name
{
get { return name; }
set
{
Debug.WriteLine("Name: " + value);
if (name != value)
{ …Run Code Online (Sandbox Code Playgroud)