0

I was created one CLR assembly in SQL server 2012. It shows the below error.. Please advise on the below error

Assembly 'ElasticSearchCLR' references assembly 'system.data.linq, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', 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.

thanks in advance Kirupa

Solomon Rutzky
  • 46,688
  • 9
  • 128
  • 171
Kirupananthan.G.S
  • 265
  • 1
  • 3
  • 9
  • It looks like you need to copy 'system.data.linq` v4.0 into the same folder where your 'ElasticSearchCLR' assembly is located. Then try re-creating the CLR assembly and CLR function. You may "fix" one error and find another. You'll have to keep repeating the steps until all "missing references" errors are resolved. – Dave Mason Aug 04 '14 at 12:17
  • thanks... i have added the Linq and another Assembly.. after that it show the below error.. Assembly 'ElasticSearchCLR' references assembly 'smdiagnostics, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', 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. – Kirupananthan.G.S Aug 04 '14 at 12:23
  • Yep. As I mentioned in the first comment, you may "fix" one error and find another. You'll have to keep repeating the steps until all "missing references" errors are resolved. Good luck. – Dave Mason Aug 04 '14 at 13:14
  • I have resolved all the error But it shows the below... i can't able to resolve it CREATE ASSEMBLY for assembly 'ElasticPatent_CLR' failed because assembly 'System.ServiceModel.Internals' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message – Kirupananthan.G.S Aug 04 '14 at 13:43
  • Take a look at this [Failed to CREATE AN ASSEMBLY in SQL](http://stackoverflow.com/questions/7968068/failed-to-create-an-assembly-in-sql) – Dave Mason Aug 04 '14 at 13:48

1 Answers1

0

Instead of copying system DLLs into your project folder, just import the first library that it says is missing (i.e. use CREATE ASSEMBLY ...). Since it imports related libraries in the same folder, any libraries related to the first .NET Framework library will most likely be in that same .NET Framework version folder. So you should only need to manually import the libraries that you added as references, and their dependencies, if any, will in most cases be resolved automatically.

With regards to the final error stated in the comments on the question, assuming that you are trying to import the correct version (including 64 bit vs 32 bit) of the System.ServiceModel.Internals library, then you might just need to specify WITH PERMISSION_SET = UNSAFE when you are importing it: Failed to create assembly 'System.ServiceModel.Internals' in SQL.

Community
  • 1
  • 1
Solomon Rutzky
  • 46,688
  • 9
  • 128
  • 171