我用下面的库,引用我的COM +组件:为什么通过C#interop获取COM +组件需要这么长时间?
using System;
using System.Runtime.InteropServices;
namespace ServiceLib
{
[ClassInterface(0)]
[Guid("9DA56255-697A-11D4-935C-00105AD43C9D")]
[TypeLibType(2)]
public class ServiceClass : IServiceManager, ServiceManager
{
public ServiceClass();
...
}
}
在我的代码,我引用它,像这样:
ServiceClass serviceClass = new ServiceLib.ServiceClass();
但是,它可能需要长达5分钟搞定物体。我的COM +组件是服务包装器,围绕着Windows服务。所以,基本上,当某些东西创建COM +引用时,我希望Windows服务启动它,但它不会。与它关联的任何.exe进程都没有。所以从字面上看,没有什么能够说我的系统正在发生5分钟,直到上面的行返回COM +对象。
延迟通常与网络超时有关。使用[Mark Russinovich的博客](http://blogs.technet.com/b/markrussinovich/)中演示的故障排除技术来找出潜在原因。 –
@HansPassant它的所有地方。 – Alexandru