|
Carlos, thank you for your prompt reply.
I have tried CreateInstance(__uuidof(Connection));
before, but that didn't solve the problem.
|
|
|
|
|
The code below, takes a parameterized object name, looks for a specific interface
and trys to call its methods.
It finds the interface with no difficulty but gets the error 0x8007806ba
(The RPC server is unavailable. ).
The same calls work from a VB test script. I'm running this on a Windows 2k server
with SP 2. I've checked all the security parameters (DCOMCNFG) all are set to
default, the same as for the other objects that work fine...
This code used to work, I've modified the object, transfered it to a new program
and now it fails. I did change the name of the interface (I seperated the methods
out from another interface). So I tried the old object, everything works fine. (difference shown as commente line (//OLD.)
It would appear there is something wrong with my new object. I would think the
problem must be in the new object, except that I wrote a VB test app, and it works fine. This makes me think the problem is NOT in the object.
Please Help!!
I'd include the code for the object, but its large, and I'm not sure which parts would be useful...
Thanks, Bill
*******************************************************************************************
This VB code works fine
Dim apminfo As New APMOBJECTLib.MessageInfo
Private Sub Command1_Click()
Dim t As String
t = apminfo.GetFunction("sfddsfsdlfksdflk")
End Sub
*****************************************************************************************
This code locates and connects to the interface (MessageInfo). Every thing here succeeds...
CErrorInfo CServiceMessage::UnpackMessage(VARIANT vBody)
{
CErrorInfo err;
CoInitialize(NULL);
VARIANT vResult;
_bstr_t bstrValue;
m_strBody = GetMessageAsString(vBody);
try
{
// Get Function handler object
CLSID ID;
m_pBroker=NULL;
//OLD CString strObjName = "APMObj.CFunction"; // This works fine when activated
CString strObjName = "APMObject.MessageInfo"; // New object.
// The following line of code succeeds
HRESULT hr = CLSIDFromProgID( strObjName.AllocSysString(), &ID);
if (hr != S_OK)
{
LPTSTR lpMsgBuf;
CString strError;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, hr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf, 0, NULL ) == 0 ) // Couldn't find error code
{
lpMsgBuf = "Unknown Error";
}
strError.Format("%s: %s %s Error %d: %s.","CConfigServices::Load()",
"Attempting to find object ", m_pParent->m_strObjectName,
hr, lpMsgBuf);
err.SetError(ERR_SEVERITY_MAJOR, CONFIGERROR + CString(strError));
LocalFree(lpMsgBuf);
return err;
}
hr = CoCreateInstance(ID, NULL, CLSCTX_LOCAL_SERVER,
IID_IDispatch, (void **)&(m_pBroker));
if (hr != S_OK)
{
// error handling
}
vResult = GetValue(vBody,CString("GetPriority"),VT_I4);
*******************************************************************************
This code fails
VARIANT CServiceMessage::GetValue(VARIANT vBody, CString strField, int iType)
{
DISPID dispID;
HRESULT hr;
CErrorInfo err;
LPOLESTR olestr;
VARIANT vResult;
try
{
// Unpack function name
olestr = strField.AllocSysString();
TRACEX("Get ID of " + strField);
// the following line of code fails if the new object and interface is used. It works if
// the old object name and interface is used.
hr = m_pBroker->GetIDsOfNames(IID_NULL, &olestr, 1, LOCALE_USER_DEFAULT,
&dispID);
if (hr != S_OK)
// hr is = 0x800706ba (RPC Server Not Found)
Thanks for the help,
Bill
|
|
|
|
|
The code below, takes a parameterized object name, looks for a specific interface and trys to call its methods.
It finds the interface with no difficulty but gets the error 0x8007806ba
(The RPC server is unavailable. ).
The same calls work from a VB test script. I'm running this on a Windows 2k server with SP 2. I've checked all the security parameters (DCOMCNFG) all are set to default, the same as for the other objects that work fine...
This code used to work, I've modified the object, transfered it to a new program and now it fails. I did change the name of the interface (I seperated the methods out from another interface). So I tried the old object, everything works fine. (difference shown as commente line (//OLD.)
It would appear there is something wrong with my new object. I would think the problem must be in the new object, except that I wrote a VB test app, and it works fine. This makes me think the problem is NOT in the object.
Please Help!!
I'd include the code for the object, but its large, and I'm not sure which parts would be useful...
Thanks, Bill
*******************************************************************************************
This VB code works fine
Dim apminfo As New APMOBJECTLib.MessageInfo
Private Sub Command1_Click()
Dim t As String
t = apminfo.GetFunction("sfddsfsdlfksdflk")
End Sub
*****************************************************************************************
This code locates and connects to the interface (MessageInfo). Every thing here succeeds...
CErrorInfo CServiceMessage::UnpackMessage(VARIANT vBody)
{
CErrorInfo err;
CoInitialize(NULL);
VARIANT vResult;
_bstr_t bstrValue;
m_strBody = GetMessageAsString(vBody);
try
{
// Get Function handler object
CLSID ID;
m_pBroker=NULL;
//OLD CString strObjName = "APMObj.CFunction"; // This works fine when activated
CString strObjName = "APMObject.MessageInfo"; // New object.
// The following line of code succeeds
HRESULT hr = CLSIDFromProgID( strObjName.AllocSysString(), &ID);
if (hr != S_OK)
{
LPTSTR lpMsgBuf;
CString strError;
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, hr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf, 0, NULL ) == 0 ) // Couldn't find error code
{
lpMsgBuf = "Unknown Error";
}
strError.Format("%s: %s %s Error %d: %s.","CConfigServices::Load()",
"Attempting to find object ", m_pParent->m_strObjectName,
hr, lpMsgBuf);
err.SetError(ERR_SEVERITY_MAJOR, CONFIGERROR + CString(strError));
LocalFree(lpMsgBuf);
return err;
}
hr = CoCreateInstance(ID, NULL, CLSCTX_LOCAL_SERVER,
IID_IDispatch, (void **)&(m_pBroker));
if (hr != S_OK)
{
// error handling
}
vResult = GetValue(vBody,CString("GetPriority"),VT_I4);
*******************************************************************************
This code fails
VARIANT CServiceMessage::GetValue(VARIANT vBody, CString strField, int iType)
{
DISPID dispID;
HRESULT hr;
CErrorInfo err;
LPOLESTR olestr;
VARIANT vResult;
try
{
// Unpack function name
olestr = strField.AllocSysString();
TRACEX("Get ID of " + strField);
// the following line of code fails if the new object and interface is used. It works if
// the old object name and interface is used.
hr = m_pBroker->GetIDsOfNames(IID_NULL, &olestr, 1, LOCALE_USER_DEFAULT,
&dispID);
if (hr != S_OK)
// hr is = 0x800706ba (RPC Server Not Found)
Thanks for the help,
Bill
|
|
|
|
|
Sorry for the double post. My browser reported an error the first time...
I thought it didn't post.
Thanks for the help,
Bill
|
|
|
|
|
I have a COM server and client, both running on the same box. When I try to run the client on a Windows 2000 server, I get the RPC Server Unavailable message. This happens when I try to get the dispid of the method name (GetIDsFromNames). All the calls up til then work fine (CoCreate etc.)
I threw together a VB app to test it. Works fine.
I moved both to NT4. Works fine.
Obviously there is something my C++ client needs to do for W2k that is different. Any body know what that might be???
Help, this is driving me nuts...
Thanks for the help,
Bill
|
|
|
|
|
Sorry, I pushed the wrong button, here is the entire post. Pleasd ignor this. I'll repost.
Thanks for the help,
Bill
|
|
|
|
|
Does anybody know a reliable tool that traces COM?
|
|
|
|
|
Hi,
I have a dialog based app (maindlg is CPropertySheet) and I want to add accelerators to the pages. How is this done in WTL?
Thanks,
Remon
|
|
|
|
|
|
Yes, I'am aware of this function, but is doesn't work in a modal property sheet.
Remon
|
|
|
|
|
Hi!
I am trying to create an out of process server which runs as a remote service. So, I have created the service on machine B.
The client is on machine A, and has been compiled using #include (with the _i.c and .h) files. The service (on machine B) has been initialized as follows:
a. nmake the *ps.mk file
b. regsvr32 the *ps.dll file
c. Run *.exe -service
d. and finally start the service on machine B.
On machine A(client), I do the following:
CoInitialize(NULL);
LPWSTR pwszName="name of machine B;
COSERVERINFO csi={0,pwszName,NULL,0};
MULTI_QI mqi[]={{&IID_ITestInterface,NULL,S_OK}};
try{
HRESULT hr=CoCreateInstanceEx(CLSID_TestInterface,NULL,CLSCTX_SERVER,
&csi,sizeof(mqi)/sizeof(mqi[0]),mqi);
if(FAILED(hr)) _com_issue_error();
//use a smart pointer and do some method invokation..
}
catch(_com_error&error){
// display error
}
when I run this, I get the error that Interface not registered 80040155.
Can someone point out what is going wrong here. My main query is whether this error is generated from the client side (machine A), indicating that the interface should be registered on machine A, or it is generated from the server itself.
Ideas/comments would be greatly appreciated.
thanks in advance
|
|
|
|
|
hello,
i think that the *PS.dll is not registered in the client machine. So copy the ps dll in the client machine and register it and try running it. If error persists please report so that i can think of something else.
Ganesh.M.Ramaswamy
|
|
|
|
|
Hi! Thanks for your message.
I copied the *ps.dll file and registered it using regsvr32.exe. It still does not work, and I get the same error.
Does the *ps.dll file have to be copied into a specific directory e.g winnt\system32?
I have tried doing that though..
|
|
|
|
|
I can programatically create a link to a file... but how do you create a link to a folder?
Thanks,
|
|
|
|
|
I'm curious how people out there implement these 2 aspects of a class when COM pointers are in use. Here's an example class :
CClass
{
public :
CClass();
CClass( CClass& other );
~CClass();
CClass& operator=( CClass& rhs );
private :
_ConnectionPtr m_connection;
};
Given this, what's the best way to copy m_connection in the necessary routines? As so? :
CClass::CClass( CClass& other )
{
other.m_connection->QueryInterface( __uuidof(Connection), (void**)&m_connection );
}
CClass& CClass::operator=( CClass& rhs )
{
if ( this != &rhs )
{
rhs.m_connection->QueryInterface( __uuidof(Connection), (void**)&m_connection );
}
return *this;
}
Or is there a more proper way for copying the pointer from one class to another?
|
|
|
|
|
When you copy an interface pointer, check it for NULL, and if it's not NULL, copy the value then AddRef() it.
--Mike--
http://home.inreach.com/mdunn/
Ford: How would you react if I said that I'm not from Guildford after all, but from a small planet somewhere in the vicinity of Betelguese?
Arthur: I don't know. Why, do you think it's the sort of thing you're likely to say?
|
|
|
|
|
_ConnectionPtr is smart pointer
(_com_ptr_t<_com_IIID<_Connection, __uuidof(Connection)> >).
Just do it
m_connection = rhs.m_connection;
and _com_ptr<>::operator =() calls QueryInterface himself
|
|
|
|
|
I have 2 dll 's which are using the same structure and same interfaces
but i want to write one client.
I included the headers generated by the idl 's in my client i am getting redefination of structures.
Is there any way where I can access both the DLLs using a single client.
The DLLs share the same structures and interfaces
Thanks for any help
parag
|
|
|
|
|
Yes you can . You will have to use namespace under this circumstance
Jafer
|
|
|
|
|
How do you pass a "C" type struct to a visual basic active X dll? I have looked at the tutorials on the site for passing simple system-defined datatypes but get problems with the MIDL compiler if I try to pass a structure. How does one do this? i.e. I create my active x dll and then get the .idl file from the ole viewer and try to run midl to create header file for me but that's where it goes wrong complaining about the type there. Is there an article on this somewhere?
|
|
|
|
|
Hello,
declare the structure in ur MIDL file and then in client side VB code there is something called as *type* data type. this is similar to a structure. declare this in the format as ur structure and create an instance for it and use it. this worked for me in COM dll/VB client and so i think it will work in VB activex client also.
Ganesh.M.Ramaswamy
|
|
|
|
|
Hi,
I might look a bit selfish here, but,
have you tried this ?
www.codeproject.com\atl\udtdemo.asp
Hope this helps
|
|
|
|
|
Suppose a client connected with a remote DCOM component by creating its instance and then calling its methods, can the component know where the client comes from, or what IP the client has? If can, how? And when firewall exists in the client side, how is the situation then?
Thanks a lot!
|
|
|
|
|
hello,
As far as i know the basic design of COM/DCOM is that both client and server should be unaware of the other and as i suppose COM doesnt give any direct interface/method for getting IP address (though it does these things internally). i also think that there wont be any need for a COM component to trace the client.
Ganesh.M.Ramaswamy
|
|
|
|
|
hi
I am a beginner to ATL .I cant call the control's property pages in 'Active control test container' and VC++ ,but can do that in VB.How will i do to perform that?
|
|
|
|
|