我认为这是一个奇怪的问题,我有,我在服务器端定义了几个类,然后通过服务引用引用,其中两个正在工作,因为他们应该是。我已经指定了已知类型的服务接口:从WCF服务返回服务器端类
[ServiceKnownType(typeof(Obj))]
[ServiceKnownType(typeof(DigitalObject))]
[ServiceKnownType(typeof(AnalogueObject))]
[ServiceKnownType(typeof(AttributeType))]
[ServiceKnownType(typeof(AttributeData))]
从Silverlight应用程序,然后我通过引用类:
private ServiceReference.AttributeData commonData = new ServiceReference.AttributeData();
这是工作正常,但是我这样做究竟有同样的事情另一类,唯一的区别是名为AnalogueObject
和DigitalObject
的类是从Obj
类型的类派生的。你有什么想法发生了什么?命名空间都是一样的,我已经重建了Web解决方案并更新了服务参考。
Example类:
using System.ComponentModel;
namespace CapCon2
{
public class Obj : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private string _Description;
public string ID { get; set; }
public string Description
{
get { return _Description; }
set
{
_Description = value;
NotifyPropertyChanged("Description");
}
}
public void NotifyPropertyChanged(string name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
}
}
public class AttributeData : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private string _Description;
public string ID { get; set; }
public string Description
{
get { return _Description; }
set
{
_Description = value;
NotifyPropertyChanged("Description");
}
}
public string Attribute { get; set; }
public string DataType { get; set; }
public string Input_InputSource { get; set; }
public string Output_OutputDest { get; set; }
public void NotifyPropertyChanged(string name)
{
if (PropertyChanged!= null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
}
什么是错误或问题?你不清楚问题是什么? – SliverNinja
对不起!问题在于,'Obj'上面的类不能从silverlight项目中引用,并且从它派生的类也不能。然而,两个不同的类可以,但我不能看到它们之间的任何区别。 –
请分享示例代码('AttributeData' /'AttributeType')作为比较 – SliverNinja