我的任务是现代化2009年开发的Web应用程序。它是用VB.NET编写并使用ASP.NET WebForms编写的。我想在VB.NET中使用最新的语言构造。
我得到了有用的提示,说“ Visual Basic 10.0不允许字符串插值”,这是我试图使用的方法,但是我没有找到提高语言水平的方法。
我在此相关问题中有技巧,如何在Visual Studio 2015中更改VB.NET语言版本,但在这种情况下没有帮助。
在ReSharper属性中,我可以将四个不同项目中的每个项目的“ VB语言级别”设置为“ Visual Basic .NET 15”。这更改了项目的.DotSetting文件中的XML行,并且此设置更改了ReSharper分析代码的方式,但是,可惜,这并没有消除编译错误。
如何在Visual Studio 2017中启用对ASP.NET网站或Web应用程序项目中最新版本的VB.NET的支持?
vb.net asp.net aspnet-compiler visual-studio visual-studio-2017
我是WPF的新手.在我们当前的项目中,我们为所有需要验证的数据输入字段添加了验证规则.我们还复制了代码(也在stackoverflow的其他地方发布),它们递归循环遍历所有绑定及其验证规则,以便在保存数据之前知道所有数据是否有效.
这是我们的代码,我认为是解决我们问题的地方:
Public Function ValidateBindings(ByVal parent As DependencyObject) As Boolean
Dim valid As Boolean = True
Dim localValues As LocalValueEnumerator = parent.GetLocalValueEnumerator
While localValues.MoveNext
Dim entry As LocalValueEntry = localValues.Current
If BindingOperations.IsDataBound(parent, entry.Property) Then
Dim binding As Binding = BindingOperations.GetBinding(parent, entry.Property)
For Each rule In binding.ValidationRules
Dim result As ValidationResult = rule.Validate(parent.GetValue(entry.Property), Nothing)
If Not result.IsValid Then
Dim expression As BindingExpression = BindingOperations.GetBindingExpression(parent, entry.Property)
Validation.MarkInvalid(expression, New ValidationError(rule, expression, result.ErrorContent, Nothing))
valid = False
End If
Next
End If
End While …Run Code Online (Sandbox Code Playgroud)