组件服务COM + C#的东西不太对劲? [英] Component Services COM+ C# Something not quite right?

查看:94
本文介绍了组件服务COM + C#的东西不太对劲?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个C#COM +串门另一个COM + DLL。它有一个非常简单的界面,我已经成功地测试了下降。

I am writing a C# COM+ drop in for another COM+ dll. It has a very simple interface and I have successfully tested the drop in.

我使用组件服务部分原因是因为旧的系统做部分是因为它觉得不对劲。

I am using 'component services' partly because the old system did and partly because it feel right.

我的问题是,当我注册了传统的DLL中所含属性的路径的dll是实际的dll,也很好用。

Problem I have is when I register the legacy dll the path to the dll in the properties is the ACTUAL dll, also it just works.

当我登记我的路径的dll降MSCorEE.dll中没有我的DLL,它似乎碰运气,以我是否有我的DLL添加到GAC?我曾尝试code将其自动添加到缓存中,但它不工作?

When I register my drop in the path to the dll is mscoree.dll not my dll, and it seems hit and miss as to whether I have to add my dll to the GAC? I have tried code to add it to a cache automatically but it doesn't work?

另外,我使用的是WCF电话与我的COM +叫我遇到一个问题,到配置的dll目前它似乎是在寻找C语言设置:\ WINDOWS \ SYSTEM32 \ dllhost.exe.config

Also, as I am using a WCF call with my COM+ call I am running into an issue as to where the configuration dll is currently it appears to be looking for settings in C:\Windows\system32\dllhost.exe.config

我想是因为它看起来沿侧的实际的dll?我失去了一些东西?

What I'd like is for it to look along side the actual dll? Am I missing something?

推荐答案

COM / COM +是一个非托管的技术。它知道任何有关.NET托管code,所以直接在COM注册表不可能工作,注册您的.NET程序集。 MSCorEE.dll中是加载托管运行时和presents非托管接口的COM的COM注册表需要.NET托管库。当你的程序集实现COM组件类的一个实例被激活,COM +负载mscoree,再mscoree已加载程序集挂钩您的实现的COM,调用包装其中mscoree presents到COM +。

COM/COM+ is an unmanaged technology. It knows nothing about .NET managed code, so registering your .NET assembly directly in the COM registry could not possibly work. mscoree.dll is the .NET hosting library which loads the managed runtime and presents the unmanaged interfaces to COM which the COM registry requires. When an instance of the COM coclass that your assembly implements is activated, COM+ loads mscoree first, then mscoree has to load your assembly to hook up your implementation to the COM-callable wrapper which mscoree presents to COM+.

在哪里mscoree查找程序集,以加载它取决于你如何注册它。由此可见,除非你指定了codeBase的注册过程(例如使用regasm命令行参数的正常路径探测.NET融合装载机,这意味着它通常会看在GAC规则 / codeBase的)。

Where mscoree looks for your assembly in order to load it depends on how you registered it. It follows the normal path probing rules of the .NET Fusion loader, which means it will usually be looking in the GAC unless you have specified a codebase during registration (e.g. using the regasm command line argument /codebase).

配置设置由应用程序域范围,并默认为一个AppDomain的配置文件名后面加后缀的.config 的路径获得的的承载的AppDomain过程的可执行文件。您的组件托管在COM +,所以会在过程中是DLLHOST.EXE的一个实例执行。因此,在默认情况下为您的组件的应用程序域配置文件将是DllHost.exe.config。但是,如果指定为COM +应用程序,这将改变那里的AppDomain中寻找它的配置,以 [COM +应用程序根目录] \ [COM +应用程序名称]的.config

Configuration settings for managed code are scoped by AppDomain, and by default the configuration file name for an AppDomain is obtained by adding the suffix .config to the path of the executable of the process hosting the AppDomain. Your component is hosted in COM+, so will execute in process which is an instance of DllHost.exe. So by default the configuration file for your component's AppDomain is going to be DllHost.exe.config. However, if you specify an Application Root directory for the COM+ application this will change the location where the AppDomain looks for its configuration, to [COM+ Application Root Directory]\[COM+ Application Name].config.

这篇关于组件服务COM + C#的东西不太对劲?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆