loading assembly and createInstance

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daylor

    #1

    loading assembly and createInstance

    hi.

    im loading assembly from my computer and createInstance from it.
    till now it worked ok.

    now, im changing the path from :

    c:\myfolder\mya ssembly.dll

    to

    \\mycomputer\my folder\myasseml y.dll


    and i get the next exception when CreateInstance:
    -------------
    A first chance exception of type 'System.Securit y.SecurityExcep tion'
    occurred in mscorlib.dll

    Additional information: Request for the permission of type
    System.Security .Permissions.Se curityPermissio n, mscorlib,
    Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9 failed.
    --------------

    the exception occur when, the code in that assembly is accessed to unmanged
    code ( com class).

    why is that ? the only diffrence is i change the path like i said from
    c:\myfolder\mya ssembly.dll to \\mycomputer\my folder\myasseml y.dll

    i try alots of flags and security permissions, but i dont know where to make
    the change.
    i have feeling is somthing to the evidence parameter in the assembly.load .


    hope someone can help
    have a nice day.


  • Rob Teixeira [MVP]

    #2
    Re: loading assembly and createInstance

    Now your code is running with the Intranet permission set. The permission
    set zones (local, intranet, internet, etc) are determined by the path of the
    assembly.
    Do a few searches on Permission Sets and Code Permissions. You can modify
    the target machine's config to alter permissions for intranet zone (not
    recommended), or you can sign your assembly and give any assembly with that
    signing key more permission (recommended).

    -Rob Teixeira [MVP]


    "Daylor" <ronixnow@hotma il.com> wrote in message
    news:brilrt$gkh $1@news2.netvis ion.net.il...[color=blue]
    > hi.
    >
    > im loading assembly from my computer and createInstance from it.
    > till now it worked ok.
    >
    > now, im changing the path from :
    >
    > c:\myfolder\mya ssembly.dll
    >
    > to
    >
    > \\mycomputer\my folder\myasseml y.dll
    >
    >
    > and i get the next exception when CreateInstance:
    > -------------
    > A first chance exception of type 'System.Securit y.SecurityExcep tion'
    > occurred in mscorlib.dll
    >
    > Additional information: Request for the permission of type
    > System.Security .Permissions.Se curityPermissio n, mscorlib,
    > Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9[/color]
    failed.[color=blue]
    > --------------
    >
    > the exception occur when, the code in that assembly is accessed to[/color]
    unmanged[color=blue]
    > code ( com class).
    >
    > why is that ? the only diffrence is i change the path like i said from
    > c:\myfolder\mya ssembly.dll to \\mycomputer\my folder\myasseml y.dll
    >
    > i try alots of flags and security permissions, but i dont know where to[/color]
    make[color=blue]
    > the change.
    > i have feeling is somthing to the evidence parameter in the assembly.load[/color]
    ..[color=blue]
    >
    >
    > hope someone can help
    > have a nice day.
    >
    >[/color]


    Comment

    • Daylor

      #3
      Re: loading assembly and createInstance

      ok,but i know my problem is permission.
      where i can read about setting permissions to assembly ?

      im searching for code samples.
      or somthing that helps to understand how to change permissions in c#
      assembly.
      "Rob Teixeira [MVP]" <RobTeixeira@@m sn.com> wrote in message
      news:O5hA77pwDH A.2568@TK2MSFTN GP09.phx.gbl...[color=blue]
      > Now your code is running with the Intranet permission set. The permission
      > set zones (local, intranet, internet, etc) are determined by the path of[/color]
      the[color=blue]
      > assembly.
      > Do a few searches on Permission Sets and Code Permissions. You can modify
      > the target machine's config to alter permissions for intranet zone (not
      > recommended), or you can sign your assembly and give any assembly with[/color]
      that[color=blue]
      > signing key more permission (recommended).
      >
      > -Rob Teixeira [MVP]
      >
      >
      > "Daylor" <ronixnow@hotma il.com> wrote in message
      > news:brilrt$gkh $1@news2.netvis ion.net.il...[color=green]
      > > hi.
      > >
      > > im loading assembly from my computer and createInstance from it.
      > > till now it worked ok.
      > >
      > > now, im changing the path from :
      > >
      > > c:\myfolder\mya ssembly.dll
      > >
      > > to
      > >
      > > \\mycomputer\my folder\myasseml y.dll
      > >
      > >
      > > and i get the next exception when CreateInstance:
      > > -------------
      > > A first chance exception of type 'System.Securit y.SecurityExcep tion'
      > > occurred in mscorlib.dll
      > >
      > > Additional information: Request for the permission of type
      > > System.Security .Permissions.Se curityPermissio n, mscorlib,
      > > Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9[/color]
      > failed.[color=green]
      > > --------------
      > >
      > > the exception occur when, the code in that assembly is accessed to[/color]
      > unmanged[color=green]
      > > code ( com class).
      > >
      > > why is that ? the only diffrence is i change the path like i said from
      > > c:\myfolder\mya ssembly.dll to \\mycomputer\my folder\myasseml y.dll
      > >
      > > i try alots of flags and security permissions, but i dont know where to[/color]
      > make[color=green]
      > > the change.
      > > i have feeling is somthing to the evidence parameter in the[/color][/color]
      assembly.load[color=blue]
      > .[color=green]
      > >
      > >
      > > hope someone can help
      > > have a nice day.
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Ignacio Machin \( .NET/ C#  MVP \)

        #4
        Re: loading assembly and createInstance

        Hi,

        The entity that needs permission is not the readed assembly but the running
        code.

        Take a look at these links:
        Code Access Security:
        http://msdn.microsoft.com/library/de...ssSecurity.asp

        Configuring Security Policy Using the .NET Framework Configuration Tool
        (Mscorcfg.msc)
        http://msdn.microsoft.com/library/de...ritypolicy.asp

        Hope this help,

        --
        Ignacio Machin,
        ignacio.machin AT dot.state.fl.us
        Florida Department Of Transportation

        "Daylor" <ronixnow@hotma il.com> wrote in message
        news:brjrrr$p6r $1@news2.netvis ion.net.il...[color=blue]
        > ok,but i know my problem is permission.
        > where i can read about setting permissions to assembly ?
        >
        > im searching for code samples.
        > or somthing that helps to understand how to change permissions in c#
        > assembly.
        > "Rob Teixeira [MVP]" <RobTeixeira@@m sn.com> wrote in message
        > news:O5hA77pwDH A.2568@TK2MSFTN GP09.phx.gbl...[color=green]
        > > Now your code is running with the Intranet permission set. The[/color][/color]
        permission[color=blue][color=green]
        > > set zones (local, intranet, internet, etc) are determined by the path of[/color]
        > the[color=green]
        > > assembly.
        > > Do a few searches on Permission Sets and Code Permissions. You can[/color][/color]
        modify[color=blue][color=green]
        > > the target machine's config to alter permissions for intranet zone (not
        > > recommended), or you can sign your assembly and give any assembly with[/color]
        > that[color=green]
        > > signing key more permission (recommended).
        > >
        > > -Rob Teixeira [MVP]
        > >
        > >
        > > "Daylor" <ronixnow@hotma il.com> wrote in message
        > > news:brilrt$gkh $1@news2.netvis ion.net.il...[color=darkred]
        > > > hi.
        > > >
        > > > im loading assembly from my computer and createInstance from it.
        > > > till now it worked ok.
        > > >
        > > > now, im changing the path from :
        > > >
        > > > c:\myfolder\mya ssembly.dll
        > > >
        > > > to
        > > >
        > > > \\mycomputer\my folder\myasseml y.dll
        > > >
        > > >
        > > > and i get the next exception when CreateInstance:
        > > > -------------
        > > > A first chance exception of type 'System.Securit y.SecurityExcep tion'
        > > > occurred in mscorlib.dll
        > > >
        > > > Additional information: Request for the permission of type
        > > > System.Security .Permissions.Se curityPermissio n, mscorlib,
        > > > Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9[/color]
        > > failed.[color=darkred]
        > > > --------------
        > > >
        > > > the exception occur when, the code in that assembly is accessed to[/color]
        > > unmanged[color=darkred]
        > > > code ( com class).
        > > >
        > > > why is that ? the only diffrence is i change the path like i said from
        > > > c:\myfolder\mya ssembly.dll to \\mycomputer\my folder\myasseml y.dll
        > > >
        > > > i try alots of flags and security permissions, but i dont know where[/color][/color][/color]
        to[color=blue][color=green]
        > > make[color=darkred]
        > > > the change.
        > > > i have feeling is somthing to the evidence parameter in the[/color][/color]
        > assembly.load[color=green]
        > > .[color=darkred]
        > > >
        > > >
        > > > hope someone can help
        > > > have a nice day.
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...