Com Visual Studio IDE在使用用于Excel.Application的IDispatch.GetTypeInfo()时崩溃

Com Visual Studio IDE在使用用于Excel.Application的IDispatch.GetTypeInfo()时崩溃,com,idispatch,createinstance,Com,Idispatch,Createinstance,我正在编写一个与COM组件接口的应用程序,在Visual Studio 10 IDE中运行应用程序时,在使用Excel.application组件时遇到了一个问题。我遇到了一个致命的内存不足错误。如果我只运行EXE,一切都会正常运行,但这严重限制了我的调试能力。我以这种方式访问的所有其他COM组件都可以正常工作,包括国产和商用组件 下面是一个控制台应用程序,演示了此崩溃。为了简单起见,我删除了所有错误处理。在有问题的代码周围放置try/catch块没有帮助。此项目需要对CustomMarshal

我正在编写一个与COM组件接口的应用程序,在Visual Studio 10 IDE中运行应用程序时,在使用Excel.application组件时遇到了一个问题。我遇到了一个致命的内存不足错误。如果我只运行EXE,一切都会正常运行,但这严重限制了我的调试能力。我以这种方式访问的所有其他COM组件都可以正常工作,包括国产和商用组件

下面是一个控制台应用程序,演示了此崩溃。为了简单起见,我删除了所有错误处理。在有问题的代码周围放置try/catch块没有帮助。此项目需要对CustomMarshalers.dll的引用

    class Program
    {
        static void Main(string[] args)
        {
            InstantiateCOMComponent("Excel.Application");
        }

        private static void InstantiateCOMComponent(string name)
        {
        Type typeInfo = Type.GetTypeFromProgID(name);
        object instance = Activator.CreateInstance(typeInfo);
        IDispatch dispatch = instance as IDispatch;

        // NOTE: THIS CALL FAILS WITH Excel.Application in the IDE
        // but succeeds at run-time!! (Out of Memory fatal error)
        Type comTypeInfo;
        dispatch.GetTypeInfo(0, 0, out comTypeInfo);
        }
    }

 [ComImport, 
  Guid("00020400-0000-0000-C000-000000000046"),
  InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDispatch
{
    void Reserved();
    [PreserveSig]
    int GetTypeInfo(uint nInfo, int lcid,
       [MarshalAs(
          UnmanagedType.CustomMarshaler,
          MarshalTypeRef = typeof(TypeToTypeInfoMarshaler))]
       out System.Type typeInfo);
}

我认为问题仅仅是因为Excel的大小

我的项目在codeplex(添加到.NETJS编译器的ActiveXObject)上有一些类似的目标。其中一些已经存在于Codeplex中(但还没有一套完整的反映COM类型的工具集)。如果这听起来很有趣,您可以尝试从这里复制它的功能:我的IDispatch接口声明在这里:如果它对您有效,也许我可以使用应答格式。这是非常多的WIP,我在家里的机器上可以提供更多。还有一个博客网站,我在那里获得了很多我的信息,但我想不起来,我把它放在家里的书签里。。。