简体   繁体   English

WCF服务参考覆盖标准类型

[英]WCF service reference overrides standard types

I created windows service hosted WCF as it described here: http://msdn.microsoft.com/en-us/library/ff649818.aspx 我创建了Windows服务托管的WCF,如此处所述: http : //msdn.microsoft.com/zh-cn/library/ff649818.aspx

Interface used as ServiceContract looks as follows: 用作ServiceContract的接口如下所示:

[ServiceContract]
public interface IUIService
{
    [OperationContract]
    void MoveToPosition(double dblNum1, double dblNum2, double dblNum3);

    [OperationContract]
    void AutoFocus();

    [OperationContract]
    double GetStatus();

    [OperationContract]
    string ScanRegion(Point startPoint, Size size);
    [OperationContract]
    ImageData GetImage(string processId); 
}

Now the problem is that when I call method from Service, let's say ScanRegion from a solution which has a service reference on hosting win service, it requires not System.Drawing.Point and System.Drawing.Size, but UIServiceReference.Point and UIServiceReference.Size. 现在的问题是,当我从Service调用方法时,假设某个解决方案的ScanRegion具有托管Win服务的服务引用,它不需要System.Drawing.Point和System.Drawing.Size,而是需要UIServiceReference.Point和UIServiceReference。尺寸。 And when I go to reference class, I see that there are fully implemented objects of the corresponding types. 当我去参考类时,我看到有相应类型的完全实现的对象。 What's the matter? 怎么了? And how to fix it? 以及如何解决?

When you go to add the service refrence in the client program you must have System.Drawing referenced by the project for the client before you create the reference to the service. 当您要在客户端程序中添加服务引用时,在创建对服务的引用之前 ,项目必须为客户端引用System.Drawing If that refrence is not there it will "create its own" because your project did not know System.Drawing existed so it had to re-create its own types. 如果不存在该引用,它将“创建自己的”,因为您的项目不知道System.Drawing存在,因此必须重新创建自己的类型。

If System.Drawing was already part of the project and it still is making its own type check the advanced screen for the service and be sure that either "Reuse types in all referenced assemblies" is selected or if specified assemblies is selected that the box for System.Drawing is checked. 如果System.Drawing已经成为项目的一部分,并且仍在进行其自身的类型检查,请检查服务的高级屏幕,并确保选择了“在所有引用的程序集中重用类型”,或者如果选择了指定的程序集,则该框为System.Drawing已检查。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM