sqlclr

CLR Strict Security on SQL Server 2017

拜拜、爱过 提交于 2019-11-30 06:46:49
MSDN on this article says: CLR uses Code Access Security (CAS) in the .NET Framework, which is no longer supported as a security boundary. A CLR assembly created with PERMISSION_SET = SAFE may be able to access external system resources, call unmanaged code, and acquire sysadmin privileges. Beginning with SQL Server 2017, an sp_configure option called clr strict security is introduced to enhance the security of CLR assemblies. clr strict security is enabled by default, and treats SAFE and EXTERNAL_ACCESS assemblies as if they were marked UNSAFE. The clr strict security option can be disabled

Security risks of setting trustworthy = on in sql server 2012

◇◆丶佛笑我妖孽 提交于 2019-11-30 03:53:13
问题 I get the following errors in my development database: A .NET Framework error occurred during execution of user-defined routine or aggregate "SpCreateTable": System.Security.HostProtectionException: Attempted to perform an operation that was forbidden by the CLR host. The protected resources (only available with full trust) were: All The demanded resources were: Synchronization, ExternalThreading Is the correct solution to set trustworthy = on? What are security concerns with this? 回答1: The

Is it possible to create an asymmetric key for a .NET framework assembly in SQL Server 2014?

不打扰是莪最后的温柔 提交于 2019-11-30 03:11:10
问题 I am developping an SQL Server Database Project in Visual Studio which is in fact a User Defined Function. In this project, I included Json.NET as a reference (using NuGet). I managed to publish (and make work) my assembly and the UDF to my SQL Server instance by first turning the database TRUSTWORTHY ON (since my project is UNSAFE) and then running this: CREATE ASSEMBLY [System.Runtime.Serialization] FROM 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.Serialization.dll' WITH

Does or does not SQL Azure support CLR assemblies?

随声附和 提交于 2019-11-30 01:25:34
问题 We've got a couple of on-premises dbs and we're seeing if we can migrate them to SQL Azure. Some of those dbs have a couple of user defined functions written in C# in an assembly (SAFE). After running a search, I've found a couple of posts which contradict each other. Some say that v12 supports CLR code. Others say it doesn't. So, here are my questions: Does V12 supports embedding clr assemblies? How can we export the generation script for azure with the assembly? Whenever we set the export

Difference between scalar, table-valued, and aggregate functions in SQL server?

两盒软妹~` 提交于 2019-11-29 22:41:43
What is the difference between scalar-valued, table-valued, and aggregate functions in SQL server? And does calling them from a query need a different method, or do we call them in the same way? Scalar Functions Scalar functions (sometimes referred to as User-Defined Functions / UDFs) return a single value as a return value, not as a result set, and can be used in most places within a query or SET statement, except for the FROM clause (and maybe other places?). Also, scalar functions can be called via EXEC , just like Stored Procedures, though there are not many occasions to make use of this

Extracting a .NET Assembly from SQL Server 2005

China☆狼群 提交于 2019-11-29 22:29:49
I am trying to help a personal friend (who now also is a client) with a SQL CLR related problem. He has a SQL Server with a database that has 3 .NET assemblies embeded in it. He asked me to help him extract the assemblies from within the database and save them as .dll files on the disk. Is this even possible? Yes, this is possible. The actual binary representation of the assemblies live in the SQL catalog for your server. Namely, if you run a join between sys.assembly_files and sys.assemblies you can get to all the information you need. The assemblies binary is in the content column of the sys

SQL Server custom CLR fails with error “Could not load file or assembly or one of its dependencies. The system cannot find the file specified.”

走远了吗. 提交于 2019-11-29 17:10:26
I have created a SQL CLR that references the Windows DLL, WindowsBase. For the most part my CLR works just fine but if WindowsBase gets updated in the GAC then I get the error " Assembly in host store has a different signature than assembly in GAC. ". To address this I built my CLR to reference a version of WindowsBase that is not in the GAC. Now when I run my CLR i get the error " Could not load file or assembly 'WindowsBase, Version=4.0.0.0, ...' or one of its dependencies. The system cannot find the file specified. " I set up FusLogVw to see what's going on and get the following output The

The type or namespace name 'DataSetExtensions' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

北慕城南 提交于 2019-11-29 13:53:04
I know this is a common error but I have the correct reference to the System.Data.DataSetExtensions.dll added to the project and my project is a SQL CLR project built for .net 4.5 and I'm getting the error at the following line: using System.Data.DataSetExtensions; I also checked the properties for the dll and it is referencing the correct version for the 4.5 dll so what else could possibly be causing this issue? Is this an issue with SQL CLR projects? System.Data.DataSetExtensions is an assembly, not a namespace. You just need to add a reference to System.Data.DataSetExtensions.dll (as you

SQL Server: “CREATE ASSEMBLY for assembly 'Test' failed because assembly 'Test' is malformed or not a pure .NET assembly.”

余生长醉 提交于 2019-11-29 11:47:15
I get this error when I attempt to load a mixed mode C++/CLI assembly into SQL Server 2012: CREATE ASSEMBLY [Test] AUTHORIZATION [dbo] from 'H:\test.dll' WITH PERMISSION_SET = SAFE Msg 6544, Level 16, State 1, Line 1 CREATE ASSEMBLY for assembly 'Test' failed because assembly 'Test.dll' is malformed or not a pure .NET assembly. Unverifiable PE Header/native stub. Solomon Rutzky Mixed-mode Assemblies are not allowed in SQLCLR Assemblies; only pure MSIL Assemblies are allowed. This is implied in the MSDN documentation for CREATE ASSEMBLY in the Remarks section: Assembly Validation SQL Server

How does one use TimeZoneInfo in a SQLCLR assembly in SQL Server 2012

一曲冷凌霜 提交于 2019-11-29 11:06:29
I want to implement time zone conversion within SQL Server 2012. However, TimeZoneInfo is marked with the MayLeakOnAbort attribute. This causes a runtime error when the SQL function I defined (which uses TimeZoneInfo) is invoked. The error is reported as follows System.Security.HostProtectionException: Attempted to perform an operation that was forbidden by the CLR host. The protected resources (only available with full trust) were: All The demanded resources were: MayLeakOnAbort Documentation hints that I can use "SafeHandle" to get around this leakage issue but I do not see how. So, how does