How to grant the database owner (DBO) the EXTERNAL ACCESS ASSEMBLY permission?

后端 未结 7 1310
执笔经年
执笔经年 2020-12-23 09:59

When I try to create assembly in SQL 2008 from .Net assembly (.Net 3.5) I am getting the below error, error says that I have to set either of the below properties as true, h

相关标签:
7条回答
  • 2020-12-23 10:39

    This works for:

    • Visual Studio 2015 Update 2.
    • Visual Studio 2017.
    • Visual Studio 2017 and SQL Server 2019 (thanks @Ramkumar Sambandam).

    In your project settings, select "External Access":

    On publish, the error message says that it cannot accept "EXTERNAL_ACCESS" unless the assembly is set to "Trustworthy".

    So, in the project settings, set the assembly to "Trustworthy":

    This meant that I was able to run a sample user defined function that listed files on the local hard drive.

    If the security is still too restrictive, add the attribute DataAccess = DataAccessKind.Read to your UDF, e.g.:

    [Microsoft.SqlServer.Server.SqlFunction(FillRowMethodName = "FindFiles", DataAccess = DataAccessKind.Read, TableDefinition = "FileName nvarchar(500), FileSize bigint, CreationTime datetime")]
    

    Update 2017-07-02

    On SQL Server 2016 + Visual Studio 2015, you might also have to do the following:

    • use master;grant unsafe assembly to [Domain\Username];
    • Run any programs (such as Visual Studio or any C# utilities) in Administrator mode to give them sufficient permissions to publish UNSAFE assemblies.

    If nothing works, try connecting using username sa and your administrator password. This will always work, regardless of whether Visual Studio is run in Administrator mode or not.

    Update 2020-01-17

    Updated list of compatible VS + SQL Server combinations.

    0 讨论(0)
提交回复
热议问题