CLR Assemblies in Replication

  • I have a 64-bit assembly in my publication, and a function that accesses it.

    ex.

    USE [MyPublication]

    GO

    CREATE ASSEMBLY MyTestAssembly

    FROM 'C:\MyTestAssembly.dll'

    GO

    CREATE FUNCTION [dbo].[MyTestFunction](@text nvarchar(MAX))

    RETURNS nvarchar(MAX)

    AS EXTERNAL NAME MyTestAssembly.TestFunction

    GO

    Each subscriber has its own "C:\MyTestAssembly.dll", if it's a 32-bit subscriber, they have a 32-bit version of the assembly, if they're a 64-bit subscriber, they have a 64-bit version of the assembly.

    When I initialize a subscriber, it initializes correctly, but when I run "SELECT [dbo].[MyTestFunction]('foo')", I get:

    Msg 10314, Level 16, State 11, Line 1

    An error occurred in the Microsoft .NET Framework while trying to load assembly id 65537. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. 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 'mytestassembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

    System.IO.FileLoadException:

    at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

    at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

    at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

    at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

    at System.Reflection.Assembly.Load(String assemblyString)

    I'm assuming that this problem is because the target assembly on the subscriber is not the same 64-bit version that's on the publisher. Is that correct? Is there any way to have this working without requiring a custom script to run on each subscriber after they're initialized?

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply