Sum*_*Guy 5 c# wcf return-value derived-class
当我在我的WCF Web服务上使用我的一个webmethods时,我收到了奇怪的模糊错误消息.因为该错误消息没有提供任何解释允许我发表我的理论.
我相信它可能与我正在使用的返回类型有关
我有一个类型DLL,它在Web服务和客户端都被引用.在这个DLL中是基类ExceptionMessages.这个类的一个孩子叫做DrawingExcepions.
这是一些代码:
public class ExceptionMessages
{
public object[] ReturnValue { get; set; }
}
public class DrawingExceptions : ExceptionMessages
{
private List<DrawingException> des = new List<DrawingException>();
}
public class DrawingException
{
public Exception ExceptionMsg { get; set; }
public List<object> Errors { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
使用代码:
[OperationContract]
ExceptionMessages createNewBom(Bom bom, DrawingFiles dfs);
public ExceptionMessages createNewBOM(Bom bom, DrawingFiles dfs)
{
return insertAssembly(bom, dfs);
}
public DrawingExceptions insertAssembly(Bom bom, DrawingFiles dfs)
{
DrawingExceptions des = new DrawingExceptions();
foreach (DrawingFile d in dfs.drawingFiles)
{
DrawingException temp = insertNewDrawing(bom, d);
if (temp != null)
des.addDrawingException(temp);
if (d.Child != null)
des.addDrawingException(insertAssembly(bom, d.Child));
}
return des;
}
Run Code Online (Sandbox Code Playgroud)
返回:
ExceptionMessages ems = client.createNewBom(bom, currentDFS);
if (ems is DrawingExceptions) { }
Run Code Online (Sandbox Code Playgroud)
基本上,webmethod的返回类型是ExceptionMessages,但我通常会改回子类.
我唯一的想法是,这是导致错误的孩子,但据我所知,这应该没有效果.有没有人有任何想法在这里可能会出错?
如果需要更多信息,请问:)
谢谢.
| 归档时间: |
|
| 查看次数: |
21499 次 |
| 最近记录: |