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
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL 2005 CLR trigger and TCPClient [modified]

SQL 2005 CLR trigger and TCPClient [modified]

Scheduled Pinned Locked Moved Database
databasecsharpdotnetsecurityquestion
4 Posts 2 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.
  • N Offline
    N Offline
    Nico Patitz
    wrote on last edited by
    #1

    Hi, I´m trying ot get a CLR-Trigger running. I Created the trigger, its insert correctly in the database, but when the SQLTrigger tries to open a tcpclient Connection, I get a Security Exception: "{System.Security.SecurityException: Request for the permission of type 'System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port) at Triggers.Trigger1() The action that failed was: Demand The type of the first permission that failed was: System.Net.DnsPermission" How / Where can I give the Trigger the needed Permissions? -- modified at 10:58 Wednesday 28th February, 2007

    M 1 Reply Last reply
    0
    • N Nico Patitz

      Hi, I´m trying ot get a CLR-Trigger running. I Created the trigger, its insert correctly in the database, but when the SQLTrigger tries to open a tcpclient Connection, I get a Security Exception: "{System.Security.SecurityException: Request for the permission of type 'System.Net.DnsPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port) at Triggers.Trigger1() The action that failed was: Demand The type of the first permission that failed was: System.Net.DnsPermission" How / Where can I give the Trigger the needed Permissions? -- modified at 10:58 Wednesday 28th February, 2007

      M Offline
      M Offline
      Mark J Miller
      wrote on last edited by
      #2

      The permissions referred to are Code Access Security permissions. If you created your assembly with the default settings in Visual Studio then the assembly is set to SAFE. In order to access external resources you need to increase the assembly to EXTERNAL_ACCESS. If you are using Visual Studio this is done using the project properties. Otherwise, if you are scripting the creation of your assembly use WITH EXTERNAL_ACCESS instead of WITH SAFE (or nothing - default)

      N 1 Reply Last reply
      0
      • M Mark J Miller

        The permissions referred to are Code Access Security permissions. If you created your assembly with the default settings in Visual Studio then the assembly is set to SAFE. In order to access external resources you need to increase the assembly to EXTERNAL_ACCESS. If you are using Visual Studio this is done using the project properties. Otherwise, if you are scripting the creation of your assembly use WITH EXTERNAL_ACCESS instead of WITH SAFE (or nothing - default)

        N Offline
        N Offline
        Nico Patitz
        wrote on last edited by
        #3

        I´m using standard .Net assembly... the Exception occures when the trigger tries to execute the line TcpClient client = new TcpClient("127.0.0.1",13000); The TcpClient is Part of the System.dll assembly, and this assembly should be usaly registered correctly?

        M 1 Reply Last reply
        0
        • N Nico Patitz

          I´m using standard .Net assembly... the Exception occures when the trigger tries to execute the line TcpClient client = new TcpClient("127.0.0.1",13000); The TcpClient is Part of the System.dll assembly, and this assembly should be usaly registered correctly?

          M Offline
          M Offline
          Mark J Miller
          wrote on last edited by
          #4

          The system.dll assembly isn't "registered" with Sql Server, it's part of the hosted CLR. Certain classes w/in the CLR have attributes called Host Protection attributes which indicate the type of functionality the class and it's methods expose. SQL Server restricts access to some these classes based upon how your assembly is created. In order for your assembly to access (it will compile fine, but it won't run) these classes you must create (register) your assembly using WITH EXTERNAL_ACCESS instead of WITH SAFE.

          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