我的代码如下:
string str="72E42A61-6AA1-45ad-BA21-73065A897F5C";
Guid guid = new Guid(str);
Type t = Type.GetTypeFromCLSID(guid, true);
object obj = Activator.CreateInstance(t);t都是成功的,能够显示是System.__ComObject,但为何一到创建object的时候就报错呢,错误内容是:
检索 COM 类工厂中 CLSID 为 {72E42A61-6AA1-45AD-BA21-73065A897F5C} 的组件时失败,原因是出现以下错误: 80040154。但我确信是注册过这个组件的呀,麻烦各位能够帮忙解答一下,已经烦了我两天了……

解决方案 »

  1.   

    也是不行的!
    因为我要实现的是一个接口.
    另外,我是在Vista环境下的。
      

  2.   

    using System;
    using System.Reflection;
    using System.Reflection.Emit;
    using System.Runtime.InteropServices;
    public class App
    {
        private enum RegKind
        {
            RegKind_Default = 0,
            RegKind_Register = 1,
            RegKind_None = 2
        }
        
        [ DllImport( "oleaut32.dll", CharSet = CharSet.Unicode, PreserveSig = false )]
        private static extern void LoadTypeLibEx( String strTypeLibName, RegKind regKind, 
            [ MarshalAs( UnmanagedType.Interface )] out Object typeLib );
        
        public static void Main()
        {
            Object typeLib;
            LoadTypeLibEx( "SHDocVw.dll", RegKind.RegKind_None, out typeLib ); 
            
            if( typeLib == null )
            {
                Console.WriteLine( "LoadTypeLibEx failed." );
                return;
            }
                
            TypeLibConverter converter = new TypeLibConverter();
            ConversionEventHandler eventHandler = new ConversionEventHandler();
            AssemblyBuilder asm = converter.ConvertTypeLibToAssembly( typeLib, "ExplorerLib.dll", 0, eventHandler, null, null, null, null );    
            asm.Save( "ExplorerLib.dll" );
        }
    }public class ConversionEventHandler : ITypeLibImporterNotifySink
    {
        public void ReportEvent( ImporterEventKind eventKind, int eventCode, string eventMsg )
        {
            // handle warning event here...
        }
        
        public Assembly ResolveRef( object typeLib )
        {
            // resolve reference here and return a correct assembly...
            return null; 
        }    
    }
      

  3.   

    以上方法针对已经知道有DLL文件的可能是可以的,但我要实现的东东只知道GUID,实现时就是报错呀。
      

  4.   

    知道guid 还不能找到dll???
      

  5.   

    找不到,因为注册的东东名字叫"CXPRtpFilter.ax"
      

  6.   

    有 guid 可以通过 ProgIDFromCLSID获得 progid 再自动化方式创建
      

  7.   

    取不出progID来,取出的是null值。
      

  8.   

    原因是不支持Vista 64bit,NNDX……