Code Analysis Error: Declare types in namespaces
        Posted  
        
            by George
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by George
        
        
        
        Published on 2010-05-04T03:18:46Z
        Indexed on 
            2010/05/04
            3:28 UTC
        
        
        Read the original article
        Hit count: 363
        
Is VS2010, I analyzed my code and got this error:
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 is some reference info on the error. Essentially, I tried to create a class to be used to access data in the Application object in a typed way.
The warning message said unless I put my (ApplicationVariables) class in a Namespace, that I wouldn't be able to use it. But I am using it, so what gives?
Also, here is a link to another StackOverflow article that talks about how to disable this warning in VS2008, but how would you disable it for 2010? There is no GlobalSuppressions.vb file for VS2010.
Here is the code it is complaining a bout:
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
        © Stack Overflow or respective owner