VB.NET WCF代码在VS2017中引发“属性说明符不是完整的语句”错误

时间:2018-09-27 21:17:42

标签: vb.net wcf visual-studio-2017

我需要支持一些用VB.NET编写的旧代码。这是WCF解决方案,目前正在生产中。但是,当我克隆存储库并将其加载到VS2017 Build 15.8.5中时,我没有看到任何语法问题。没有红色的波浪线。但是,当我重建解决方案时,在“输出”窗口中出现了构建错误,但在“错误列表”中没有出现错误。

这是我的“输出”窗口的一部分。

3>Building directory '/App_Code/'.
3>
3>..\ICDI_WCFService.vb(20,0): error BC32035: Attribute specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement.
3>..\ICDI_WCFService.vb(29,0): error BC30604: Statement cannot appear within an interface body. End of interface assumed.
3>..\ICDI_WCFService.vb(30,0): error BC30001: Statement is not valid in a namespace.
3>..\ICDI_WCFService.vb(44,0): error BC30289: Statement cannot appear within a method body. End of method assumed.

这是错误消息中引用的源代码示例

<ServiceContract()>
Public Interface IIMb
    ''' <summary>
    ''' Used only to expose unused types. 
    ''' <para>WCF does not pass through any classes/enums/etc. that are not explicitly used as either input or ouput of a method</para>
    ''' <para>So, to expose those types, this method was created.</para>
    ''' </summary>
    ''' <param name="imbMailClasses"></param>
    ''' <remarks></remarks>
    <OperationContract()>
    Sub ExposesUnusedTypes(ByVal imbMailClasses As MAILPiece.IMb.MailClasses)

    ''' <summary>
    ''' Creates IMb PICs for Basic Confirm.
    ''' <para>NOTE: Removes one Address_Only Transaction Count per PIC generated.</para>
    ''' </summary>
    ''' <param name="authHeader"></param>
    ''' <param name="userID"></param>
    ''' <param name="amount"></param>
    ''' <param name="barcodeIdentifier"></param>
    ''' <param name="classAndAddressCorrectionOption"></param>
    ''' <returns>Array [String]</returns>
    ''' <remarks></remarks>
    <OperationContract()>
    Function CreatePICs_BasicConfirm(ByVal authHeader As AuthHeader, ByVal userID As Integer, ByVal amount As Integer,
                                     ByVal barcodeIdentifier As MAILPiece.IMb.BarcodeIdentifiers,
                                     ByVal classAndAddressCorrectionOption As MAILPiece.IMb.ClassAndAddressCorrectionOptions_Basic_Confirm) As String()

它的行为类似于,并且未正确使用,但是就像我说的那样,这段代码已经运行了很长时间,所以我不得不怀疑VS2017是否没有问题

一个同事将相同的存储库克隆到VS2017内部版本15.4.0中,并且存在相同的问题。

它最后一次在VS2017上工作是在今年春天,所以它已经从VS2015转换为VS2017,但我必须假定它是VS2017 build 15.4.0之前的版本

但是,此后,我已经在DEV笔记本电脑上安装了.NET Core 2.x SDK。

在经历使用VS2017 Build 15.0设置干净笔记本电脑的痛苦之前,我想看看是否有人遇到过此问题。

有什么想法吗?

更新1

此旧解决方案将VB网站项目用于WCF服务(包装程序?),并且没有vbproj文件。

此网站项目引用的解决方案中还有其他项目,它们确实具有vbproj文件(并且它们没有LangVersion设置),而这个没有。但是,我可以右键单击项目名称,然后选择“编辑项目项属性”,并且可以看到VB语言级别设置为“默认”。我尝试将其设置为Visual Basic .NET 15,但在错误方面没有任何影响。

如果我尝试在属性后添加下划线(用于行继续),则在移开该行后,该符号就会消失。

Screenshot of project right-click menu

更新2

上面的解决方案资源管理器图像中突出显示的CDI_WCFService3项看起来像它应该是一个具有vbproj文件的项目,但实际文件夹中没有vbproj文件。有一个web.config文件,该web.config文件中的部分如下所示;

                                                     

这是唯一提到VB的东西。

这是文件夹结构的屏幕截图。

project folder

1 个答案:

答案 0 :(得分:0)

错误看上去像是该版本正在使用VS 2008中的编译器,该编译器不支持隐式的行连续。或至少设置了langversion编译器选项的当前编译器。参考文档指出这是仅命令行选项,但在MSBuild文件(ProjectName.vbproj)中包含以下内容将在VS 2017中重现您的问题:

  <PropertyGroup>
    <LangVersion>9.0</LangVersion>
  </PropertyGroup>

因此,检查vbproj文件以查看是否已将上述内容添加到该文件中。另外,如果您有“ Directory.Build.props”文件(请参阅:Customize your build),也请签入该文件。