0

I am running SSIS Packages through an Agent job and getting error 0x80131904:

Message:

Executed as user: NT Service\SQLSERVERAGENT.
Microsoft (R) SQL Server Execute Package Utility
Version 14.0.3023.8 for 64-bit
Copyright (C) 2017 Microsoft. All rights reserved.

Started: 1:00:00 PM
Failed to execute IS server package because of error 0x80131904. Description:
An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not be trusted. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:

System.IO.FileLoadException: Could not load file or assembly 'microsoft.sqlserver.integrationservices.server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A)

System.IO.FileLoadException:
      at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
      at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
      at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
      at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
      at System.Reflection.Assembly.Load(String assemblyString)

Source: .Net SqlClient Data Provider
Started: 1:00:00 PM
Finished: 1:00:00 PM
Elapsed: 0.328 seconds.

The package execution failed.
The step failed.

I researched and found that I should enable CLR and set TRUSTWORTHY to ON for the DB. I did that and in addition checked the database owner account; it's enabled and not orphaned. Still getting the error. I would highly appreciate any help on this.

4
  • Why did you mark this azure sql database and sql server 2017? Commented Sep 7, 2018 at 17:40
  • Is there any more text to the error message besides the error #? Please post the entire error message. Also, what is the SQLCLR method doing? Anything requiring EXTERNAL_ACCESS or UNSAFE? If so, is the PERMISSION_SET of the Assembly set to either EXTERNAL_ACCESS? From what I am seeing, "0x80131904" indicates an error when trying to connect to SQL Server. Does your SQLCLR method use SqlClient to connect to SQL Server using a regular / external connection (i.e. not "context connection=true")? Commented Sep 8, 2018 at 13:56
  • Thanks @Solomon I have posted the complete message in the Answer section as I was not able to post here. Please find it below in this thread.
    – user160248
    Commented Sep 10, 2018 at 8:49
  • @user160248 Hi there. You don't need to add comments or answers in order to provide more info. You can (and should) simply edit the question and add / change whatever. What DB is the Assembly loaded into? Did you set that DB to TRUSTWORTHY ON and change the owner of that DB? The error you are getting, which is really 0x8013150A, has been corrected in all cases that I could find by those 2 actions. Also, did you check the PERMISSION_SET for the assembly? It should be set to EXTERNAL_ACCESS. Can you execute this same package using DTExec.exe at a command prompt? Commented Sep 10, 2018 at 19:24

2 Answers 2

3

Have you tried this:

USE <DATABASE>;
EXEC sp_configure 'clr enabled' ,1
GO

RECONFIGURE
GO
EXEC sp_configure 'clr enabled'   -- make sure it took
GO

First Enable Trustworthy database property

ALTER DATABASE [DatabaseName] SET TRUSTWORTHY ON;
GO

And change the database owner to ‘sa’

USE [DatabaseName]
GO

EXEC sp_changedbowner 'sa'
GO
2
  • Yes I have tried these all three steps, enabling CLR, setting trustworthy on and changing the db owner to sa. Commented Sep 7, 2018 at 21:54
  • @IftekharIlm If you are the same person who asked the question, please see about getting your accounts merged. Then, you should be able to comment on your own question, as well as answers to the question.
    – RDFozz
    Commented Sep 7, 2018 at 23:17
0

Message:

Executed as user: NT Service\SQLSERVERAGENT. Microsoft (R) SQL Server Execute Package Utility Version 14.0.3023.8 for 64-bit Copyright (C) 2017 Microsoft. All rights reserved. Started: 1:00:00 PM Failed to execute IS server package because of error 0x80131904. Description: An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not be trusted. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error: System.IO.FileLoadException: Could not load file or assembly 'microsoft.sqlserver.integrationservices.server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A) System.IO.FileLoadException: at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) Source: .Net SqlClient Data Provider Started: 1:00:00 PM Finished: 1:00:00 PM Elapsed: 0.328 seconds. The package execution failed. The step failed.

1
  • Hi there. I have edited the question to add this content. Please delete this answer. In the future, you can just update the question with new info or changes. You don't need to add comments below the question. Thanks :) Commented Sep 10, 2018 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.