Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

made some library and want to use it as CLR assembly in MSSQL. The point is that my lib have the reference to 'iAnywhere.Data.SQLAnywhere' lib which I cannot install. The error is:

Assembly 'iAnywhere.Data.SQLAnywhere' could not be installed because existing policy would keep it from being used.

I have implemented the recommendations and now my SQL looks like:

USE DB_Control GO

ALTER DATABASE DB_Control SET TRUSTWORTHY ON WITH ROLLBACK IMMEDIATE
GO

ALTER DATABASE DB_Control SET TRUSTWORTHY ON
GO

exec sp_configure 'show advanced options', 1;
GO

RECONFIGURE;
GO

exec sp_configure 'clr enabled', 1;
GO

RECONFIGURE;
GO

IF EXISTS (
SELECT 1
FROM sys.assemblies a
WHERE a.name = 'ClrSqlMediator'
)
    EXEC sp_executesql N'DROP ASSEMBLY ClrSqlMediator'
GO

CREATE ASSEMBLY [iAnywhere.Data.SQLAnywhere]
AUTHORIZATION sa
FROM '~\Debug\iAnywhere.Data.SQLAnywhere.dll'
WITH PERMISSION_SET = UNSAFE
GO

CREATE ASSEMBLY ClrSqlMediator
AUTHORIZATION sa
FROM '~\Debug\SQLMediator.dll'
WITH PERMISSION_SET = UNSAFE
GO

Does anybody know how to fix this?

asked 19 Dec '13, 05:55

Andrii%20Horda's gravatar image

Andrii Horda
1111
accept rate: 0%


This is probably closer to a Microsoft SQL Server question than a SQL Anywhere question, so you may want to check out other Microsoft SQL Server resources for further assistance.


The deployment requirements for the SQL Anywhere ADO.NET assembly are noted in the documentation - ensuring that the native DLLs can be located via the SQL Server's PATH environment variable is likely the most important point for deploying the unmanaged DLLs.

There is a stackoverflow question that seems to suggest this might be due to a mismatch of CLR versions. It seems that there's an open question of which CLR version currently runs on SQL Server, depending on environment configuration - to determine your current configuration, you will need to run the SQL:

select * from sys.dm_clr_properties

Perhaps you need to load the 4.0 CLR ADO.NET provider (iAnywhere.Data.SQLAnywhere.v4.0.dll) to match the 4.0 CLR version loaded in Microsoft SQL Server...?

permanent link

answered 19 Dec '13, 11:25

Jeff%20Albion's gravatar image

Jeff Albion
10.8k171175
accept rate: 25%

I am no expert on SQL Server but the message you quoted mentioned "policy". There is a policy file that accompanies easch release of the provider that indicates that the new version can satisfy earlier versions. Perhaps your "Debug" version is too new or too old.

I'd try running "setupvspackage /ua" in the SQL Anywhere Assembly\V2 folder from an admin command prompt and then "setupvspackage /i". Repeat for Assembly\V4. Then make sure that the provider referenced in your "FROM" clause is that same version.

This might help.

permanent link

answered 20 Dec '13, 09:23

JBSchueler's gravatar image

JBSchueler
3.3k41564
accept rate: 19%

edited 20 Dec '13, 09:24

Maybe this is the obstacle: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\OnlyUseLatestCLR is it set to 1?

permanent link

answered 19 Dec '13, 08:06

Martin's gravatar image

Martin
9.0k130169257
accept rate: 14%

edited 19 Dec '13, 08:07

nope, that doesn't help. Same error

(19 Dec '13, 09:20) Andrii Horda
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×41
×19
×11

question asked: 19 Dec '13, 05:55

question was seen: 6,533 times

last updated: 20 Dec '13, 09:24