Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Replication (2005)
 64-bit Assembly in Publication with 32-bit Subs

Author  Topic 

KevinKembel
Starting Member

11 Posts

Posted - 2010-03-04 : 11:15:23
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?

SreenivasBora
Posting Yak Master

164 Posts

Posted - 2010-03-04 : 14:05:10
Try like this and let us know if you get same error ....

Drop the Function

Run below script

ALTER DATABASE TESTDB SET TRUSTWORTHY ON
Go
CREATE ASSEMBLY StaffingInfo
from 'C:\Assembly\StaffingInfo.dll'
WITH PERMISSION_SET = EXTERNAL_ACCESS;

create the function

Select * from FN('foo')



With Regards
SR
Go to Top of Page
   

- Advertisement -