我改写了定义,除去了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);
};
[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);
};
http://www.csdn.net/develop/read_article.asp?id=21583
希望大家指正。另外我建议每个帖子的发起者,进一下楼主的义务,如果问题解决得话,那么把最终解决得方案整理一下,或者把自己的验证结果描述一下,有总结有记录大家才有提高。对个人,对这个社区都有好处:)响应回复者有分!!