VB.Net 迭代器函数突然无法编译?
几个月来,使用异步 CTP 成功编译了以下内容:
Public Shared Iterator Function FindVisualChildren(Of T As DependencyObject)(ByVal depObj As DependencyObject) As IEnumerable(Of T)
If depObj IsNot Nothing Then
For i As Integer = 0 To VisualTreeHelper.GetChildrenCount(depObj) - 1
Dim child As DependencyObject = VisualTreeHelper.GetChild(depObj, i)
If child IsNot Nothing AndAlso TypeOf child Is T Then
Yield CType(child, T)
End If
For Each childOfChild As T In FindVisualChildren(Of T)(child)
Yield childOfChild
Next childOfChild
Next i
End If
End Function
突然之间,情况不再如此。 Visual Studio 似乎不再识别具有“预期语句结束”的语法和曲线函数。
最近,我的机器在 Visual Studio 打开的情况下一直保持打开状态(真丢脸),并且自动关闭以安装一些 Winows 更新。从那时起,我就无法编译解决方案。我查看了两周前解决方案的备份副本,只是为了确保我没有搞砸,而且我也遇到了同样的问题。
我也尝试卸载并重新安装 .Net Framework Async CTP。
据我所知,最近我收到了几个 >net Framework 4 更新和安全更新。
我希望其他人能够对此有所了解,并让我节省与 MS 通话的时间。
For months now, using the Async CTP Ithe following compiled successfully:
Public Shared Iterator Function FindVisualChildren(Of T As DependencyObject)(ByVal depObj As DependencyObject) As IEnumerable(Of T)
If depObj IsNot Nothing Then
For i As Integer = 0 To VisualTreeHelper.GetChildrenCount(depObj) - 1
Dim child As DependencyObject = VisualTreeHelper.GetChild(depObj, i)
If child IsNot Nothing AndAlso TypeOf child Is T Then
Yield CType(child, T)
End If
For Each childOfChild As T In FindVisualChildren(Of T)(child)
Yield childOfChild
Next childOfChild
Next i
End If
End Function
Suddenly, this is no longer the case. Visual Studio no longer appears to recognise the syntax and squiggles Function with 'End of Statement Expected'.
Recently, my machine was left on (shame on me) with Visual Studio open and it was shutdown automatically to install some Winows Updates. SInce then, I have been unable to compile the solution. I went to a backup copy of my solution as of 2 weeks ago just to make sure I didn't goof something up and I'm seeing the same issue.
I tried uninstalling and re-installing the .Net Framework Async CTP as well.
From what I can tell, recently, I received several >net Framework 4 Updates and Security Updates.
I'm hoping that someone else ay be able to shed some light on this and save me a wasted day on the phone with MS.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的函数定义中,您有一个错误。请查看有关在 VB 中声明函数的文档。我猜您已经将它与 C# 或其他编程语言混淆了。
http://msdn.microsoft.com/en-gb/library/sect4ck6.aspx
不应在 Shared 和 Function 之间使用“迭代器”一词,因为 Function 的返回值是在 Function 末尾用 ... As IEnumerable(Of T) 给出的。
迭代器过程修饰符仅适用于 Visual Studio 11,因此通常无法使用 VS 10 或更低版本进行编译:
迭代器过程修饰符
In your Function definition you have an error. Please check the documentation for declaring Functions in VB. I guess you have got it mixed up with C# or some other programming language.
http://msdn.microsoft.com/en-gb/library/sect4ck6.aspx
The word Iterator should not be used between Shared and Function because the Function's return value is given at the end of the Function with ... As IEnumerable(Of T).
The Iterator proceduremodifiers is only available for Visual Studio 11 and hence will normally not compile with VS 10 or lower:
Iterator Proceduremodifier