0
是VS2010,我分析我的代码,并得到这个错误:代码分析错误:声明类型的命名空间
Warning 64 CA1050 : Microsoft.Design : 'ApplicationVariables' should be declared inside a namespace. C:\My\Code\BESI\BESI\App_Code\ApplicationVariables.vb 10 C:\...\BESI\
Here是错误一些参考信息。本质上,我尝试创建一个类,用于以类型化的方式访问Application对象中的数据。
警告消息说,除非我把我的(ApplicationVariables)类放在名称空间中,我无法使用它。但我正在使用它,所以给了什么?
此外,here是另一个StackOverflow文章的链接,它介绍了如何在VS2008中禁用此警告,但是如何禁用它在2010年? VS2010没有GlobalSuppressions.vb文件。
这里是它抱怨一个回合代码:
Public Class ApplicationVariables
'Shared Sub New()
'End Sub 'New
Public Shared Property PaymentMethods() As PaymentMethods
Get
Return CType(HttpContext.Current.Application.Item("PaymentMethods"), PaymentMethods)
End Get
Set(ByVal value As PaymentMethods)
HttpContext.Current.Application.Item("PaymentMethods") = value
End Set
End Property
'Etc, Etc...
End Class