Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Required permissions cannot be acquired

Required permissions cannot be acquired

Scheduled Pinned Locked Moved C#
helpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Daniel Zaharia
    wrote on last edited by
    #1

    I want to access a class (TestClass) that is in a given assembly(Test.dll) on my machine. I use activator : ObjectHandle objH=null; objH=Activator.CreateInstanceFrom(@"\\Daniel\SharedDocs\Test.dll","TestClass"); TestClass tc=(TestClass)objH.Unwrap(); MessageBox.Show(tc.GetCompName()); But I get this error : "Required permissions cannot be acquired." What should I do? Thanks, Daniel.

    J 1 Reply Last reply
    0
    • D Daniel Zaharia

      I want to access a class (TestClass) that is in a given assembly(Test.dll) on my machine. I use activator : ObjectHandle objH=null; objH=Activator.CreateInstanceFrom(@"\\Daniel\SharedDocs\Test.dll","TestClass"); TestClass tc=(TestClass)objH.Unwrap(); MessageBox.Show(tc.GetCompName()); But I get this error : "Required permissions cannot be acquired." What should I do? Thanks, Daniel.

      J Offline
      J Offline
      Jochen Kalmbach MVP VC
      wrote on last edited by
      #2

      You should not load the DLL from a network path... instead use a local copy. Or change the default security settings in "Control Panel".

      D 2 Replies Last reply
      0
      • J Jochen Kalmbach MVP VC

        You should not load the DLL from a network path... instead use a local copy. Or change the default security settings in "Control Panel".

        D Offline
        D Offline
        Daniel Zaharia
        wrote on last edited by
        #3

        The exception type is : System.Security.Policy.PolicyException I think it has somthing to do with SecurityPermission and ReflectionPermission...

        J H 2 Replies Last reply
        0
        • D Daniel Zaharia

          The exception type is : System.Security.Policy.PolicyException I think it has somthing to do with SecurityPermission and ReflectionPermission...

          J Offline
          J Offline
          Jochen Kalmbach MVP VC
          wrote on last edited by
          #4

          Daniel Zaharia wrote: The exception type is : System.Security.Policy.PolicyException I think it has somthing to do with SecurityPermission and ReflectionPermission... No, it has something to do with the Policy!!! So either change your policy to allow executiong ffrom network shares or change the way you load your assembly!

          1 Reply Last reply
          0
          • J Jochen Kalmbach MVP VC

            You should not load the DLL from a network path... instead use a local copy. Or change the default security settings in "Control Panel".

            D Offline
            D Offline
            Daniel Zaharia
            wrote on last edited by
            #5

            I get the same error even if i try to load the assembly from the same directory with the executing assembly. objH=Activator.CreateInstanceFrom("Test.dll","TestClass");

            1 Reply Last reply
            0
            • D Daniel Zaharia

              The exception type is : System.Security.Policy.PolicyException I think it has somthing to do with SecurityPermission and ReflectionPermission...

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              You need to add a code group with a URL or Site membership condition with the necessary privileges (or simply FullTrust permissions) for the directory (or any parent directory) to allow execution from that directory. For example, using a URL membership condition, use file://MYSERVER/SHARE/* or something like that. Be sure to add the asterisk at the end as a wildcard unless you only want to apply the policy to only one assembly (which, of course, you should include the assembly name). You should read Understanding .NET Code Access Security[^] here on CodeProject for more information. It's a good read and a comprehensive resource of what you can find scattered throughout the .NET Framework SDK.

              Microsoft MVP, Visual C# My Articles

              D 1 Reply Last reply
              0
              • H Heath Stewart

                You need to add a code group with a URL or Site membership condition with the necessary privileges (or simply FullTrust permissions) for the directory (or any parent directory) to allow execution from that directory. For example, using a URL membership condition, use file://MYSERVER/SHARE/* or something like that. Be sure to add the asterisk at the end as a wildcard unless you only want to apply the policy to only one assembly (which, of course, you should include the assembly name). You should read Understanding .NET Code Access Security[^] here on CodeProject for more information. It's a good read and a comprehensive resource of what you can find scattered throughout the .NET Framework SDK.

                Microsoft MVP, Visual C# My Articles

                D Offline
                D Offline
                Daniel Zaharia
                wrote on last edited by
                #7

                Thanks! Daniel.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups