• Windows Communication Fundation(WCF)的安装和一些疑惑


    Windows Communication Fundation(WCF)的版本一直未有最终的版本,估计要在Vista的正式版出来才会确定(也包括WPF,即avalon)。由于没有和Visual Studio 2005一起发布,如果需要写WCF(即indigo)的程序必须另外获得WCF的版本。

    WCF的版本是在不断的更新的,这也为我们开发WCF的程序带来一定的困难。在WCF的官方主页(http://windowscommunication.net/)上,提供了January CTP的下载(Download the Windows Communication Foundation Go-Live Release
    )。得到的安装包版本是Runtime Component 3.0 Beta2,但实际上安装后的程序集版本为2.0.0.0。在Visual Studio 2005下,可以正常添加System.ServiceModel程序集,程序集版本为2.0.0.0,并被添加到GAC中。我写了一个Hello World程序,Service是可以运行的,但我却无法找到SvcUtil.exe,这样就无法自动生成相应的配置文件以及服务的Proxy。这显然是缺少SDK的原因,在下载页面中有如下说明:

    This CTP release supports Visual Studio 2005 RTM and the .NET Framework 2.0 RTM.  The Microsoft® WinFX® SDK contains documentation, samples, and tools designed to help you develop managed applications and libraries using WinFX. You can install the SDK that corresponds to this release here.

    然而点击下载SDK,却提示“The download you requested is unavailable. ”下载失败。

    事实上,微软已经推出了February 2006 CTP。下载页面是:

    http://www.microsoft.com/downloads/details.aspx?FamilyId=F51C4D96-9AEA-474F-86D3-172BFA3B828B&displaylang=en

    这个页面下同样可以下载Runtime Component 3.0 Beta2。在安装该版本之前,需要将之前安装的相关版本卸载。此外提供了SDK的链接http://www.microsoft.com/downloads/details.aspx?FamilyId=9BE1FC7F-0542-47F1-88DD-61E3EF88C402&displaylang=en

    我们可以通过该链接下载SDK。安装SDK可以选择网络安装或本地安装。如果是本地安装,文件大小为1.1G左右,是ISO文件。安装了SDK后,在program files目录下,有microsoft SDK目录。在microsoft SDK\windows\v1.0\bin目录下,我们可以找到SvcUtil.exe工具。仔细检查该文件的信息,版本是v3.0.50727.357。如果我们用SvcUtil.exe生成Proxy类,可以发现它引用的System.ServiceModel版本是3.0.0.0。例如GeneratedCodeAttribute:
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]

    此外,2.0版本和3.0版本的System.ServiceModel在类的定义及方法和属性是有区别的,例如Binding。在2.0下,Binding类是在System.ServiceModel namespace下,而到了3.0,则放在了System.ServiceModel.Channels Namespace下。此外,生成的config也和2.0版本的不一致。也就是说,如果利用3.0的SvcUtil生成的文件,在原来的2.0版本,也就是Jan 2006 CTP下,是无法通过编译的。

    我安装了Feb 2006 CTP的Runtime Component后,此时的版本应该和我下载的SDK是一致的。然而当我使用Visual Studio 2005创建项目,添加对System.ServiceModel的引用后,却在添加引用对话框中找不到该程序集。如果察看GAC,该程序集是存在的,版本信息是3.0.0.0。检查Machine.Config文件,有如下节的配置:
    <sectionGroup name="system.serviceModel" type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

    但为何却无法添加引用呢?

    如果我卸载Feb 2006的版本,重新安装Jan 2006,版本信息是2.0.0.0,添加引用则是正常的。奇怪的是,如果此时保留该引用,重新卸载Jan 2006,再安装Feb 2006。打开该项目后,发现原来添加的对System.ServiceModel的引用仍然存在,虽然显示Assembly Property时,显示版本信息是0.0.0.0。但编译却是成功的,也能正常地运行。显然此时引用的确实是3.0.0.0版本。再通过Visual Studio 2005添加引用,还是无法找到System.ServiceModel程序集。

    莫非是我的Visual Studio 2005版本的问题?或者这本身就是Feb 2006 CTP的一个bug?存疑!

  • 相关阅读:
    HDU
    HDU-1166 敌兵布阵 (基础线段树)
    Matrices with XOR property (暴力)
    CF-825E Minimal Labels (反向拓扑)
    CodeForces-1144E Median String (模拟)
    操作文件和目录
    文件读写
    装饰器
    数据结构和算法
    Scrapy shell调试返回403错误
  • 原文地址:https://www.cnblogs.com/wayfarer/p/345331.html
Copyright © 2020-2023  润新知