Results 1 to 5 of 5

Thread: Error - "Operator '|' cannot be applied to operands of type...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Location
    Oshawa
    Posts
    214

    Error - "Operator '|' cannot be applied to operands of type...

    I'm getting this error for some reason....

    "Operator '|' cannot be applied to operands of type 'WindowsService.ACCESS_MASK' and 'int' "

    Code:
    	private const Int32 SC_MANAGER_QUERY_LOCK_STATUS = 0x00010;
    	private const Int32 SC_MANAGER_CONNECT = 0x00001;
    	private const Int32 SC_MANAGER_CREATE_SERVICE = 0x00002;
    	private const Int32 SC_MANAGER_ENUMERATE_SERVICE = 0x00004;
    	private const Int32 SC_MANAGER_LOCK = 0x00008;
        private const Int32 SC_MANAGER_MODIFY_BOOT_CONFIG = 0x00020;
        private const Int32 SC_MANAGER_ALL_ACCESS = ACCESS_MASK.STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG;
    Code:
    	[Flags()]
    	private enum ACCESS_MASK : uint
    	{		
    		DELETE = 0x10000,
    		READ_CONTROL = 0x20000,
    		WRITE_DAC = 0x40000,
    		WRITE_OWNER = 0x80000,
    		SYNCHRONIZE = 0x100000,
    
    		STANDARD_RIGHTS_REQUIRED = 0xf0000,
    
    		STANDARD_RIGHTS_READ = 0x20000,
    		STANDARD_RIGHTS_WRITE = 0x20000,
    		STANDARD_RIGHTS_EXECUTE = 0x20000,
    
    		STANDARD_RIGHTS_ALL = 0x1f0000,
    
    		SPECIFIC_RIGHTS_ALL = 0xffff,
    
    		ACCESS_SYSTEM_SECURITY = 0x1000000,
    
    		MAXIMUM_ALLOWED = 0x2000000,
    
    		GENERIC_READ = 0x80000000,
    		GENERIC_WRITE = 0x40000000,
    		GENERIC_EXECUTE = 0x20000000,
    		GENERIC_ALL = 0x10000000,
    
    		DESKTOP_READOBJECTS = 0x1,
    		DESKTOP_CREATEWINDOW = 0x2,
    		DESKTOP_CREATEMENU = 0x4,
    		DESKTOP_HOOKCONTROL = 0x8,
    		DESKTOP_JOURNALRECORD = 0x10,
    		DESKTOP_JOURNALPLAYBACK = 0x20,
    		DESKTOP_ENUMERATE = 0x40,
    		DESKTOP_WRITEOBJECTS = 0x80,
    		DESKTOP_SWITCHDESKTOP = 0x100,
    
    		WINSTA_ENUMDESKTOPS = 0x1,
    		WINSTA_READATTRIBUTES = 0x2,
    		WINSTA_ACCESSCLIPBOARD = 0x4,
    		WINSTA_CREATEDESKTOP = 0x8,
    		WINSTA_WRITEATTRIBUTES = 0x10,
    		WINSTA_ACCESSGLOBALATOMS = 0x20,
    		WINSTA_EXITWINDOWS = 0x40,
    		WINSTA_ENUMERATE = 0x100,
    		WINSTA_READSCREEN = 0x200,
    
    		WINSTA_ALL_ACCESS = 0x37f
    	}
    If I remove the ACCESS_MASK.STANDARD_RIGHTS_REQUIRED, the error goes away. Why is this occuring?

  2. #2
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: Error - "Operator '|' cannot be applied to operands of type...

    Code:
    private enum ACCESS_MASK : int
    Does this fix it?
    Delete it. They just clutter threads anyway.

  3. #3
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: Error - "Operator '|' cannot be applied to operands of type...

    Instead of Int32's in the first code section, you should probably try using uint's.

    Then you should be able to OR them.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Location
    Oshawa
    Posts
    214

    Re: Error - "Operator '|' cannot be applied to operands of type...

    I tried changing to private enum ACCESS_MASK : int but this didn't work.

    I also changed all the datatypes from int32 to uint including SC_MANAGER_ALL_ACCESS but then the error changes to "Operator '|' cannot be applied to operands of type 'WindowsService.ACCESS_MASK' and 'uint' "

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Location
    Oshawa
    Posts
    214

    Re: Error - "Operator '|' cannot be applied to operands of type...

    Ok, nevermind. LoL. I fixed it.

    Code:
    private const Int32 SC_MANAGER_ALL_ACCESS = (Int32)ACCESS_MASK.STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width