我改写了定义,除去了Unsafe的代码,但是还存在同样的问题--控件加载的时候非法的内存访问非法的内存访问。
 [Guid("CB5BDC81-93C1-11CF-8F20-00805F2CD064")]
 public interface IObjectSafety
 {
  // methods
  void GetInterfacceSafyOptions(
   System.Int32 riid,
   out System.Int32 pdwSupportedOptions,
   out System.Int32 pdwEnabledOptions);
  void SetInterfaceSafetyOptions(
   System.Int32 riid,
   System.Int32 dwOptionsSetMask,
   System.Int32 dwEnabledOptions);
 }
此时类型库中的申明如下:
[
  odl,
  uuid(CB5BDC81-93C1-11CF-8F20-00805F2CD064),
  version(1.0),
  dual,
  oleautomation,
    custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "LsDehs.IObjectSafety")]
interface IObjectSafety : IDispatch {
    [id(0x60020000)]
    HRESULT GetInterfacceSafyOptions(
                    [in] long riid, 
                    [out] long* pdwSupportedOptions, 
                    [out] long* pdwEnabledOptions);
    [id(0x60020001)]
    HRESULT SetInterfaceSafetyOptions(
                    [in] long riid, 
                    [in] long dwOptionsSetMask, 
                    [in] long dwEnabledOptions);
};