VS2017 assembly Reference error occurred while generating SQL Server 2017 project

Source: Internet
Author: User

one, when using vs2017 to generate SQL Server 2017 project, because of the added assembly (CLR integration, you can refer to the following links to understand)

, the following issues are raised because the security permissions are configured incorrectly:

 SQL72014:. Net SqlClient Data provider:msg 10343, Level 1, and Line 1 for assembly "XXX" with SAFE or external_access option The CREATE or ALTER ASSEMBLY failed because the sp_configure "CLR strict security" option is set to 1. Microsoft recommends signing the assembly with a certificate or asymmetric key with UNSAFE assembly permissions for its corresponding login. Alternatively, you can use sp_add_trusted_assembly to trust the assembly. Causes-excerpt from msdn:https://docs.microsoft.com/zh-cn/sql/database-engine/whats-new-in-sql-server-2017?view= In sql-server-2017sqlserver2017, the CLR uses code access security (CAS) in the. NET Framework (no longer as a security boundary). CLR assemblies created with Permission_set = SAFE can access External system resources, invoke unmanaged code, and obtain sysadmin privileges. Starting with SQL Server (14.x), the sp_configure option named CLR strict security was introduced to enhance the security of CLR assemblies. The CLR strict security is enabled by default, and the SAFE and external_access assemblies are treated in the same way as assemblies that are marked UNSAFE. You can disable the CLR strict security option for post compatibility, but this is not recommended. Microsoft recommends that all assemblies be signed with a certificate or asymmetric key, and that the certificate or asymmetric key has the appropriate login name that has been granted the UNSAFE ASSEMBLY permission in the primary database. You can now add CLR assemblies to the whitelist as a workaround for the CLR strict security feature. Add sp_add_trusted_assembly, sp_drop_trusted_assembly, and sys.trusted_asssemblies to support the white list of trusted assemblies. For more information, see CLR Strict security. 
Second, the solution: Http://usingprogramming.com/category/Blog
采用 sp_add_trusted_assembly的方式添加信任到数据库里去.DECLARE @hash AS BINARY(64) = (SELECT HASHBYTES(‘SHA2_512‘, (SELECT * FROM OPENROWSET (BULK ‘XXX.dll‘, SINGLE_BLOB) AS [Data])))EXEC sp_add_trusted_assembly @hash然后可以通过:select * from sys.trusted_asssemblies 视图查看已经添加的信任的程序集至此就解决了. 希望有所帮助.

VS2017 assembly Reference error occurred while generating SQL Server 2017 project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.