c# - VS2019 - Attempting to Publish an SQLCLR Class Library - System.Drawing' is not trusted
问题描述
When I attempt to Publish my SQLCLR program, I get the following error:
(47,1): SQL72014: .Net SqlClient Data Provider: Msg 10327, Level 14, State 1, Line 1 CREATE ASSEMBLY for assembly 'SqlClassLibrary' failed because assembly 'System.Drawing' is not trusted. The assembly is trusted when either of the following is true: the assembly is signed with a certificate or an asymmetric key that has a corresponding login with UNSAFE ASSEMBLY permission, or the assembly is trusted using sp_add_trusted_assembly.
System.Drawing IS in sys.trusted_assemblies. It was added using sp_add_trusted_assembly.
However, VS2019 still seems to think it is not.
permission-set-desc: UNSAFE_ACCESS
解决方案
I resolved this by creating an Asymmetric key using System.Drawing and a login for it with Unsafe Assembly permissions:
USE master; GO CREATE ASYMMETRIC KEY SQLCLRTestKey FROM EXECUTABLE FILE = 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Drawing.dll'; CREATE LOGIN
SQLCLRTestLogin FROM ASYMMETRIC KEY SQLCLRTestKey ; GRANT UNSAFE ASSEMBLY TO
SQLCLRTestLogin ; GO
推荐阅读
- node.js - 这种类型的查询对 sql 注入安全吗?
- reactjs - 如何将 React 中的类型用于我自己组件的道具?
- python - ImportError:无法从“时间”(未知位置)导入名称“时钟” - 从时间导入时钟作为刻度
- javascript - 使用 javascript 或 jquery 创建粘性侧边栏
- machine-learning - 分类器的数据集必须完美平衡吗?
- sql - 我如何对连接到一个 ID 的唯一值求和,该 ID 连接到需要基于该总和的不同 ID?
- java - 从同一个包中编译两个类
- android - 基于日期和年龄标头缓存响应
- webrtc - 如何加快音频连接
- python - Tkinter:删除活动按钮突出显示