{"id":878,"date":"2006-02-09T08:03:00","date_gmt":"2006-02-09T08:03:00","guid":{"rendered":"\/blogs\/bobb\/post\/Using-SystemConfigurationdll-in-NET-sprocs-and-UDFs.aspx"},"modified":"2006-02-09T08:03:00","modified_gmt":"2006-02-09T08:03:00","slug":"using-system-configuration-dll-in-net-sprocs-and-udfs","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/","title":{"rendered":"Using System.Configuration.dll in .NET sprocs and UDFs"},"content":{"rendered":"<p>\nSystem.Configuration.dll&nbsp;was the last assembly added to the &quot;SQL Server 2005 approved assembly&quot; list, that is, the list of BCL assemblies approved for SQL Server consumption. These are loaded from the GAC, rather than having to be explicitly added to the database by the user. System.Configuration was added SO late that it doesn&#39;t show up in a Visual Studio Database assembly project in the &quot;Add References&quot; dialog with all of its collegues. You have to use a normal Visual Studio Class Library project (or other means)&nbsp;to reference it.\n<\/p>\n<p>\nWhen students in my beta classes would try and fiddle with the config file information used to determine which version of an assembly should be loaded by putting these settings in a file aptly named sqlservr.exe.config, these would be ignored. I&#39;d thought that the entire config file was discarded, and rebuilt so that SQL Server would have its own version configuration information. Just before SQL Server 2005 shipped, the ability to run CREATE ASSEMBLY on multiple versions of the same user assembly was dropped (you can still have multiple language-specific resource sattelite assemblies cataloged).\n<\/p>\n<p>\nSo what do these two things have to do with one another?\n<\/p>\n<p>\nSomeone asked me recently if you could access configuration strings by making a sqlservr.exe.config unrelated to assembly loading I didn&#39;t think so, but if not, what is System.Configuration doing on the approved list? Let&#39;s try it in a .NET user-defined function&#8230;\n<\/p>\n<p>\npublic static string GetConfigString()<br \/>\n{<br \/>\n&nbsp; \/\/ This statement requires referencing System.Configuration.dll<br \/>\n&nbsp; ConnectionStringSettings s = ConfigurationManager.ConnectionStrings[&quot;pubs&quot;];<br \/>\n&nbsp; if (s != null) <br \/>\n&nbsp;&nbsp;&nbsp; return s;<br \/>\n&nbsp; else<br \/>\n&nbsp;&nbsp;&nbsp; return &quot;no config&quot;;<br \/>\n}\n<\/p>\n<p>\nThis works fine. The .NET UDF can even be cataloged and run as SAFE. So now that we&#39;ve gone this far, a better question might be &quot;why do you want to put configuration strings in files&quot;? You&#39;re&nbsp;running IN A&nbsp;DATABASE after all, how &#39;bout storing them in a TABLE? Perhaps so that the same code would work inside SQL Server or in middle tier server? OK, I&#39;ll buy that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>System.Configuration.dll&nbsp;was the last assembly added to the &quot;SQL Server 2005 approved assembly&quot; list, that is, the list of BCL assemblies approved for SQL Server consumption. These are loaded from the GAC, rather than having to be explicitly added to the database by the user. System.Configuration was added SO late that it doesn&#39;t show up in [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[],"class_list":["post-878","post","type-post","status-publish","format-standard","hentry","category-sqlclr"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using System.Configuration.dll in .NET sprocs and UDFs - Bob Beauchemin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using System.Configuration.dll in .NET sprocs and UDFs - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"System.Configuration.dll&nbsp;was the last assembly added to the &quot;SQL Server 2005 approved assembly&quot; list, that is, the list of BCL assemblies approved for SQL Server consumption. These are loaded from the GAC, rather than having to be explicitly added to the database by the user. System.Configuration was added SO late that it doesn&#039;t show up in [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2006-02-09T08:03:00+00:00\" \/>\n<meta name=\"author\" content=\"Bob Beauchemin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bob Beauchemin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/\",\"name\":\"Using System.Configuration.dll in .NET sprocs and UDFs - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2006-02-09T08:03:00+00:00\",\"dateModified\":\"2006-02-09T08:03:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQLCLR\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sqlclr\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Using System.Configuration.dll in .NET sprocs and UDFs\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\",\"name\":\"Bob Beauchemin\",\"description\":\"SQL Server Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\",\"name\":\"Bob Beauchemin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"caption\":\"Bob Beauchemin\"},\"sameAs\":[\"http:\/www.sqlskills.com\/blogs\/bobb\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using System.Configuration.dll in .NET sprocs and UDFs - Bob Beauchemin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/","og_locale":"en_US","og_type":"article","og_title":"Using System.Configuration.dll in .NET sprocs and UDFs - Bob Beauchemin","og_description":"System.Configuration.dll&nbsp;was the last assembly added to the &quot;SQL Server 2005 approved assembly&quot; list, that is, the list of BCL assemblies approved for SQL Server consumption. These are loaded from the GAC, rather than having to be explicitly added to the database by the user. System.Configuration was added SO late that it doesn&#39;t show up in [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/","og_site_name":"Bob Beauchemin","article_published_time":"2006-02-09T08:03:00+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/","name":"Using System.Configuration.dll in .NET sprocs and UDFs - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2006-02-09T08:03:00+00:00","dateModified":"2006-02-09T08:03:00+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/using-system-configuration-dll-in-net-sprocs-and-udfs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"SQLCLR","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/sqlclr\/"},{"@type":"ListItem","position":3,"name":"Using System.Configuration.dll in .NET sprocs and UDFs"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/","name":"Bob Beauchemin","description":"SQL Server Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e","name":"Bob Beauchemin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","caption":"Bob Beauchemin"},"sameAs":["http:\/www.sqlskills.com\/blogs\/bobb\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/878","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/comments?post=878"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/878\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}