解决::存储ROT的门,或者存储NOT/System.AccessViolationException [英] Solved::Storming the gates of ROT, or maybe NOT / System.AccessViolationException

查看:87
本文介绍了解决::存储ROT的门,或者存储NOT/System.AccessViolationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有3个需要从另一个COM服务器"Master"访问的COM服务器"Slaves"实例,因此我在ROT中注册了Slave. -大概是这样. :-)
这是在ROT中注册com服务器实例的代码.代码是
在构造函数中.

它的作用与确实在ROT中注册GUID的作用相同.
我可以打开IROTVEIWER,并看到!{GUID}在其中显示我的三个COM服务器从属实例.


Hi all,

I have 3 instances of a COM server "Slaves" that I need to be accessed from yet another com server "Master" so I registered the Slaves in the ROT. - or so I think. :-)
Here is the code that registers the com server instances in the ROT. The code is
in the constructor.

This works in as much as it does indeed register the GUID(s) in the ROT.
I can open up IROTVEIWER and see my three COM server Slave instances there displayed by !{GUID}.


DWORD ROTCookie = 0;

GUID g;

CoCreateGuid(&g);
RegisterActiveObject(this, g, ACTIVEOBJECT_WEAK, &ROTCookie);


然后,我将生成的GUID发送到需要与这些服务器通信的COM服务器.
它们按预期到达,并且是在构造函数中返回的值.

我抓取了从上面的构造函数代码发送过来的一个SlaveGUID. GetActiveObject似乎可以正常工作,因为我可以对pUnk->进行编码.并查看QueryInterface,AddRef和Release功能.

但是我想调用我自己的一个函数(MidiOutFromMaster(),所以我认为我可能需要做一个QI,但是它抛出System.AccessViolationException.我在执行过程中一定做错了什么.我是树林里的宝贝关于COM.

我也尝试过IID_this,那个以及其他由于QI线而无知的事情.


Then I send the GUIDs generated off to the COM server that needs to talk to these
and they arrive as expected and are the values generated back at the constructor.

I grabbed one of the SlaveGUIDs that was sent over from the constructor code above. GetActiveObject seems to work as I can codesense pUnk-> and see the QueryInterface, AddRef and Release funtcions.

But I want one of my own functions (MidiOutFromMaster() to call so I thought I might need to do a QI but it throws up a System.AccessViolationException. I must be doing something wrong along the way . I am a babe in the woods with respect to COM.

I''ve tried IID_this, that and the other thing out of ignorance in the QI line also.

IUnknown *pUnk;

void** ppv; 


HRESULT hr = GetActiveObject(SlaveGUID, NULL, (IUnknown**)&pUnk);


        hr = pUnk->QueryInterface( IID_IDispatch, ppv ); // causes exemption.



但是我感觉很接近我的目标.
提前谢谢.

:Ron



I feel close to my goal however.
Thanks in advance.

:Ron

推荐答案

修复它.

hr = pUnk-> QueryInterface(IID_IUnknown,(void **)& ppv);
Fixed it.

hr = pUnk->QueryInterface( IID_IUnknown, (void**)&ppv );


这篇关于解决::存储ROT的门,或者存储NOT/System.AccessViolationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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