Search code examples
sql-servervb.netclrsqlclrdirectoryservices

Assembly 'system.directoryservices.accountmanagement' was not found in the SQL catalog


I am using Visual Studio to write CLR Assembly in VB.NeT for an SQL database.

While I try to deploy my project I get this error:

Assembly 'system.directoryservices.accountmanagement' was not found in the SQL catalog

  • The correct version of system.directoryservices.accountmanagement and system.directoryservices are already added in the project's references.
  • If I build my project I don't get any errors
  • The error appears during the deploy process

Anyone any ideas?


Solution

  • That error means that the library is not one of the built-in .NET Framework libraries included in SQL Server's CLR host. The following documentation lists the small set of libraries that are included:

    Supported .NET Framework Libraries

    You will need to manually import that library via:

    CREATE ASSEMBLY [system.directoryservices.accountmanagement]
    FROM FILE .....
    WITH PERMISSION_SET = UNSAFE;
    

    The process will import any additional libraries that system.directoryservices.accountmanagement is dependent upon, if any.

    PLEASE NOTE: This is not guaranteed to be successful. If ANY of the libraries in this chain contain unmanaged code (i.e. are "mixed-mode" assemblies), then the import process will fail and there is no work-around outside of changing your code to not be dependent upon the initial Framework library you were using. You will find out when you import the first time.

    You can include this in a pre-release script for Visual Studio / SSDT to incorporate into the publish script. Be sure to do an existence check first so that it doesn't error after the first time.