SQLCLR - COM Call Packing

I am trying to call a .net assembly that wraps several COM calls (to a third-party dll) from Sql Server. The assembly is registered in order (I tried to register with insecure and external access), but when I run the procedure, I get this error:

A .NET Framework error occurred while executing a user routine or aggregate "ManagedCodeCallTest": System.UriFormatException: Invalid URI: URI is empty. System.UriFormatException: in System.Uri.CreateThis (String uri, Boolean dontEscape, UriKind uriKind) in System.Uri..ctor (String uriString) in System.ComponentModel.Design.RuntimeLicenseContext.GetLocalPath (String fileName) in System.ComponentMl. Design.RuntimeLicenseContext.GetSavedLicenseKey (type type, assembly AssemblyAssembly) in System.ComponentModel.LicenseManager.LicenseInteropHelper.GetCurrentContextInfo (Int32 & fDesignTime, IntPtr & bstrKey, RuntimeTypeHentleMleClassRenMentleMl

Any ideas? Is what I'm trying to do even possible? I read something about licensed DLLs, but the information was very vague.

EDIT: CLR code if it helps:

[SqlProcedure] public static void ArielComponentCall() { Ariel.ApplicationClass application = new Ariel.ApplicationClass(); object arielDoc = application.OpenDocument(@"P:\Projects\COAT\Ariel1.run"); } 

The project containing this class references the com object.

+4
source share
1 answer

The SQL Server SqlClr implementation contains a list of blessed .net build methods that will work in SQL Server. This is managed through Host Security Attributes . More accurately

SQL Server prohibits the use of a type or member that has a HostProtectionAttribute that specifies the value of HostProtectionResource SharedState, Synchronization, MayLeakOnAbort, or ExternalProcessMgmt. This prevents the collection of calls from members that provide sharing, perform synchronization, may leak resources at completion, or affect the integrity of the SQL Server process.

Depending on the “Access” settings of your assembly, SQL Server throws an error (when SAFE) or does nothing with the locked method ( UNSAFE and EXTERNAL ACCESS ).

Unfortunately, for you, the System.ComponentModel.LicenseContext class has a SharedState host security attribute and is part of the code that is not allowed. As a result, somewhere in your code there is a method call in LicenseManager that will silently do nothing.

In any case, the components launched by the lump in the SQL Server process are not a good idea, since a failure in the lump component will cause the failure of your entire SQL Server.

+2
source

All Articles