我在访问COM接口中的一些字符串字段时遇到了问题。调用整数字段不会导致错误。当尝试调用
以下是源接口代码:(代码来源于这里)
clientID()
、deviceID()
或key()
时,我会得到旧的"尝试读取或写入受保护的内存"错误。以下是源接口代码:(代码来源于这里)
[scriptable, uuid(fab51c92-95c3-4468-b317-7de4d7588254)]
interface nsICacheEntryInfo : nsISupports
{
readonly attribute string clientID;
readonly attribute string deviceID;
readonly attribute ACString key;
readonly attribute long fetchCount;
readonly attribute PRUint32 lastFetched;
readonly attribute PRUint32 lastModified;
readonly attribute PRUint32 expirationTime;
readonly attribute unsigned long dataSize;
boolean isStreamBased();
};
以下是访问该接口的C#代码:
[Guid("fab51c92-95c3-4468-b317-7de4d7588254"), ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface nsICacheEntryInfo
{
string clientID();
string deviceID();
nsACString key();
int fetchCount();
Int64 lastFetched();
Int64 lastModified();
Int64 expirationTime();
uint dataSize();
[return: MarshalAs(UnmanagedType.Bool)]
bool isStreamBased();
}
有什么建议可以解释为什么尝试读取一个字段会导致访问冲突?