来自CoCreateInstance的E_OUTOFMEMORY [英] E_OUTOFMEMORY from CoCreateInstance

查看:85
本文介绍了来自CoCreateInstance的E_OUTOFMEMORY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过CoCreateInstance使用MFC DLL,但遇到了问题.

我有

I''m trying to use an MFC DLL using CoCreateInstance but I''m having problems.

I have

<br />
	CLSID clsid;<br />
	HRESULT hr;<br />
	IInterface* pIInterface;<br />
	CLSIDFromString(L"My.ID", &clsid);<br />
	hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IInterface, (LPVOID*)&pIInterface);<br />



正确获取了CLSID(我已经检查过了),但是CoCreateInstance返回了E_OUTOFMEMORY.

我已经阅读了尽可能多的内容,但是对于CoCreateInstance来说,返回E_OUTOFMEMORY看起来是非常不寻常的.

我觉得这个错误并不是真正要告诉我的错误.我认为还有其他问题,但这是什么?我如何找到?非常感谢任何帮助.



The CLSID is obtained correctly (I have checked this), but CoCreateInstance returns with E_OUTOFMEMORY.

I''ve read around as much as I can, but it looks like it''s very unusual for CoCreateInstance to return with E_OUTOFMEMORY.

I have a feeling this error isn''t what it''s really trying to tell me. I think something else is the matter, but what is it? How do I find out? Any help greatly appreciated.

推荐答案

如果您具有COM DLL的源代码(由于您在CoCreateInstance()中使用CLSCTX_INPROC_SERVER,所以我认为它是DLL) ),在创建函数之一(如构造函数或FinalConstruct()函数)中放置一个断点(如果使用过ATL).查看您是否能够到达那里.

-Bio.
If you have the source codes for the COM DLL (I assumed that it is a DLL due to your use of CLSCTX_INPROC_SERVER in CoCreateInstance()), place a breakpoint in one of the creation functions like the constructor or the FinalConstruct() function (if you have used ATL). See if you are able to reach there.

- Bio.


问题必须出在您接口的实现之内,这是开始查找的地方.检查类的构造函数,然后检查FinalConstruct.
The problem must be within implementation of your interface, that''s where to start looking. Check the class''s constructor and then FinalConstruct. One of them is throwing that exception it seems.


以及其他一些响应,在将其提供给CoCreateInstance之前,我很想清除接口指针.大多数类工厂的实现都会检查所指向的内容是否为非null,如果找到有效的指针(或至少为非零),则会失败.

可能不是造成问题的原因,但值得快速进行更改和测试.

干杯,

As well as some of the other responses I''d be tempted to clear the interface pointer before feeding it into CoCreateInstance. Most implementations of class factories check to see what''s pointed to is non-null and fail if they find a valid (or non-zero at least) pointer.

Probably not the cause of you problem but worth a quick change and test.

Cheers,

Ash


这篇关于来自CoCreateInstance的E_OUTOFMEMORY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆