Reputation: 349
I have a CLR project that references an external assembly. I created the referenced assembly first as follows:
CREATE ASSEMBLY [GraphClient]
FROM 'C:\Users\rknight\Desktop\GraphServerClientProject\GraphServerClient\GraphClient\GraphClient\bin\Debug\GraphClient.dll'
WITH PERMISSION_SET = UNSAFE
Then in my CLR project I was able to reference it just fine under the "SQL Server" tab. Built the CLR project and it compiles with no errors. But when I create the new assembly I get an error:
CREATE ASSEMBLY [GraphCLR]
FROM 'C:\Users\rknight\Desktop\GraphServerClientProject\GraphServerClient\GraphClient\GraphCLR\bin\Debug\GraphCLR.dll'
WITH PERMISSION_SET = UNSAFE
Msg 10301, Level 16, State 1, Line 1
Assembly 'GraphCLR' references assembly 'graphclient, version=0.0.0.0, culture=neutral, publickeytoken=null.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.
Upvotes: 2
Views: 3091
Reputation: 19595
I had this problem and I eventually worked it out. I was referencing an x86 assembly on a 64 bit server. I rebuilt the referenced assembly as Any CPU, installed in on the server, re-added the reference to the project, rebuilt my project as Any CPU, and then SQL Server could resolve the reference and install the assembly.
A message along the lines of "You're referencing an assembly that's built for the wrong platform" would have been rather useful :)
Upvotes: 2
Reputation: 9282
This should work. Are you positive GraphClient is successfully loaded before the GraphCLR deployment is attempted? Instead of relying on the database project to deploy correctly I would first manually load the dlls in the right order, then if that works go back and mess with the project to ensure the dependencies are correct and deployment is ordered correctly.
If that doesnt help, have you tried setting trustworthy on to eliminate any obscure permissions issues?
Upvotes: 1