Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 作为WebService使用的WCF是否添加了布尔参数?_C#_Visual Studio 2008_Wcf_.net 3.5_.net 2.0 - Fatal编程技术网

C# 作为WebService使用的WCF是否添加了布尔参数?

C# 作为WebService使用的WCF是否添加了布尔参数?,c#,visual-studio-2008,wcf,.net-3.5,.net-2.0,C#,Visual Studio 2008,Wcf,.net 3.5,.net 2.0,我已经在VS2008中创建了默认的WCF服务。它叫“服务1” 工作正常,接口为IService1: [ServiceContract] public interface IService1 { [OperationContract] string GetData( int value ); [OperationContract] CompositeType GetDataUsingDataContract( CompositeType composite );

我已经在VS2008中创建了默认的WCF服务。它叫“服务1”

工作正常,接口为IService1:

[ServiceContract]
public interface IService1
{

    [OperationContract]
    string GetData( int value );

    [OperationContract]
    CompositeType GetDataUsingDataContract( CompositeType composite );

    // TODO: Add your service operations here
}
这都是默认的;VisualStudio2008创建了所有这些

然后我创建了一个简单的Winforms应用程序来“测试”这个。我将服务引用添加到了我的服务中,并使用了上述服务,一切正常。我可以实例化并调用myservice1.GetData(100);我得到了结果

但有人告诉我,Winforms.NET 2.0应用程序必须通过Web服务使用此服务,因此我继续添加对从头创建的新Winforms.NET 2.0应用程序的引用(只有一个winform称为form1)。这一次,在添加“web引用”时,它添加了属于webservices的典型“localhost”引用;向导看到WCF服务(在后台运行)并添加了它

当我尝试使用它时,我发现GetData(int)方法现在是GetData(int,bool)

这是密码

    private void button1_Click( object sender, EventArgs e )
    {
        localhost.Service1 s1 = new WindowsFormsApplication2.localhost.Service1();
        Console.WriteLine(s1.GetData(100, false));
    }
注意GetData调用中的false吗

我不知道这个参数是什么,也不知道它来自哪里,它被称为“bool valueSpecified”


有人知道这是从哪里来的吗?要从.NET2.0将WCF服务作为Web服务使用,我还应该做些什么?(winforms)。

好吧……很明显,答案和可能的解决方案或解决办法。

与XML序列化一样的警告:)如果我能再次投票反对你的答案和问题,我会的。我花了两个小时想知道为什么我会得到我正在设置的参数的“虚无”版本,并将其传递给一个从.NET 2.0到.NET 4 WCF服务的服务-我见过这些任意的布尔值,对它们一无所知。非常感谢!
    private void button1_Click( object sender, EventArgs e )
    {
        localhost.Service1 s1 = new WindowsFormsApplication2.localhost.Service1();
        Console.WriteLine(s1.GetData(100, false));
    }