简体   繁体   English

如果在IE中运行的ActiveX控件调用其他库,那么这些库是否需要实现IObjectSafety?

[英]If an ActiveX control running in IE calls other libraries, do those libraries need to implement IObjectSafety?

I have a .NET ActiveX control running in the browser (IE.) It calls other libraries (also passed through the site) to perform features such as logging, which requires writing to disk. 我有一个在浏览器(IE)中运行的.NET ActiveX控件。它调用其他库(也通过站点)来执行诸如日志记录之类的功能,这需要写入磁盘。 Do these other libraries also need to implement IObjectSafety? 这些其他库是否也需要实现IObjectSafety?

The short answer is no. 最简洁的答案是不。 Appears that only the publicly exposed assembly needs this. 似乎只有公开显示的程序集需要此功能。

It turned out after much debugging that the real problem I had was due to the ActiveX library not properly resolving .NET dependency paths when instantiated as an ActiveX using the class ID. 经过大量调试后发现,我遇到的真正问题是由于ActiveX库在使用类ID实例化为ActiveX时无法正确解析.NET依赖路径。 I resolved this by adding the following to my ActiveX library's constructor, and it works fine now: 我通过将以下内容添加到ActiveX库的构造函数中来解决了该问题,现在可以正常使用:

public YourActiveXLibrary()
{
    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LoadInstallDependency);
}

private static Assembly LoadInstallDependency(object sender, ResolveEventArgs args)
{
    string installPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    string dependencyPath = Path.Combine(installPath, new AssemblyName(args.Name).Name + ".dll");
    return File.Exists(dependencyPath) ? Assembly.LoadFrom(dependencyPath) : null;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM