我正在尝试调用一个.net程序集,该程序集封装了来自Server的几个COM调用(对第三方dll)。程序集注册良好(我尝试使用不安全的外部访问注册),但当我运行该过程时,会得到以下错误:
.NET框架错误发生在执行用户定义的例程或聚合"ManagedCodeCallTest":System.UriFormatException:无效URI: URI为空。System.ComponentModel.Design.RuntimeLicenseContext.GetLocalPath(String (System.UriFormatException):at System.Uri.CreateThis(String uri,Boolean,UriKind uriKind) at System.Uri..ctor(String uriString) at System.Uri..ctor(String UriString) at System.ComponentModel.Design.RuntimeLicenseContext.GetSavedLicenseKey(Type type,Assembly resourceAssembly) at System.ComponentModel.LicenseManager.LicenseInteropHelper.GetCurrentContextInfo(Int32& fDesignTime,IntPtr& bstrKey,RuntimeTypeHandle rth) at ManagedCode.MyClass.ArielComponentCall()
有什么想法吗?我想做的事有可能吗?我读到了一些关于授权dll的内容,但是信息非常模糊。
编辑: CLR代码,以防有帮助:
[SqlProcedure]
public static void ArielComponentCall()
{
Ariel.ApplicationClass application = new Ariel.ApplicationClass();
object arielDoc = application.OpenDocument(@"P:\Projects\COAT\Ariel1.run");
}包含该类的项目具有对com对象的引用。
发布于 2012-10-25 08:43:39
Server上的SqlClr实现包含“受祝福”的.net组装方法的一份清单,这些方法将在Server中工作。这是通过主机保护属性管理的。更准确地说
Server不允许使用具有HostProtectionAttribute的类型或成员,该类型或成员指定HostProtectionResource值为SharedState、同步、MayLeakOnAbort或ExternalProcessMgmt。这样可以防止程序集调用启用共享状态、执行同步、在终止时可能导致资源泄漏或影响Server进程完整性的成员。
取决于程序集Server的“访问”设置,Server将引发错误(当安全时),或者对阻塞的方法(UNSAFE和EXTERNAL ACCESS)不做任何操作。
不幸的是,System.ComponentModel.LicenseContext类具有SharedState主机保护属性,是不允许的代码的一部分。因此,在代码中的某个地方调用了LicenseManager中的一个方法,该方法将不会进行任何静默操作。
无论哪种方式,在Server进程中运行com组件都不是一个好主意,因为com组件中的崩溃会使整个Server崩溃。
https://stackoverflow.com/questions/6524322
复制相似问题