ussoftproblem with COM server registration???
-
hello! I am learning the MS COM/DCOM architecture. I ve developed a few simple client/server programs and I ve obtained always the same result: I think client cannot get the object. I ve used C++ with Microsift Visual C++ 6.0. To make the server I ve followed the next steps: 1- create an ATL COM AppWizard Project. 2- EXE Server. 3- New ATL object (simple object) 4- Add methods to Interface 5- Code the methods. 6- Build the project it shows me: Compiling resources... Compiling... Linking... Performing registration Server registration done! ..and client is something like this: const IID IID_IHelloObj = {0x389A6DD0,0xC789,0x463F,{0x87,0xD5,0x8C,0x3A,0x51,0xDC,0xB4,0xDF}}; const CLSID CLSID_HelloObj = {0x1635DA5A,0xD02E,0x4049,{0xB9,0x21,0x07,0xE1,0x81,0x55,0xB2,0x0E}}; void main() { HRESULT hr; IHelloObj *IHello; int num; // to test the service hr = CoInitialize(0); if(SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_HelloObj, NULL, CLSCTX_INPROC_SERVER, IID_IHelloObj, (void**)&IHello); if(SUCCEEDED(hr)) { hr=IHello->GetNumber(&num); hr=IHello->Release(); } else cout << "error"; } CoUninitialize(); } This is all what i ve done. Must i do more things to run the service? What can be the cause of the error? Thanks in advance!!!
-
hello! I am learning the MS COM/DCOM architecture. I ve developed a few simple client/server programs and I ve obtained always the same result: I think client cannot get the object. I ve used C++ with Microsift Visual C++ 6.0. To make the server I ve followed the next steps: 1- create an ATL COM AppWizard Project. 2- EXE Server. 3- New ATL object (simple object) 4- Add methods to Interface 5- Code the methods. 6- Build the project it shows me: Compiling resources... Compiling... Linking... Performing registration Server registration done! ..and client is something like this: const IID IID_IHelloObj = {0x389A6DD0,0xC789,0x463F,{0x87,0xD5,0x8C,0x3A,0x51,0xDC,0xB4,0xDF}}; const CLSID CLSID_HelloObj = {0x1635DA5A,0xD02E,0x4049,{0xB9,0x21,0x07,0xE1,0x81,0x55,0xB2,0x0E}}; void main() { HRESULT hr; IHelloObj *IHello; int num; // to test the service hr = CoInitialize(0); if(SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_HelloObj, NULL, CLSCTX_INPROC_SERVER, IID_IHelloObj, (void**)&IHello); if(SUCCEEDED(hr)) { hr=IHello->GetNumber(&num); hr=IHello->Release(); } else cout << "error"; } CoUninitialize(); } This is all what i ve done. Must i do more things to run the service? What can be the cause of the error? Thanks in advance!!!
-
hello! I am learning the MS COM/DCOM architecture. I ve developed a few simple client/server programs and I ve obtained always the same result: I think client cannot get the object. I ve used C++ with Microsift Visual C++ 6.0. To make the server I ve followed the next steps: 1- create an ATL COM AppWizard Project. 2- EXE Server. 3- New ATL object (simple object) 4- Add methods to Interface 5- Code the methods. 6- Build the project it shows me: Compiling resources... Compiling... Linking... Performing registration Server registration done! ..and client is something like this: const IID IID_IHelloObj = {0x389A6DD0,0xC789,0x463F,{0x87,0xD5,0x8C,0x3A,0x51,0xDC,0xB4,0xDF}}; const CLSID CLSID_HelloObj = {0x1635DA5A,0xD02E,0x4049,{0xB9,0x21,0x07,0xE1,0x81,0x55,0xB2,0x0E}}; void main() { HRESULT hr; IHelloObj *IHello; int num; // to test the service hr = CoInitialize(0); if(SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_HelloObj, NULL, CLSCTX_INPROC_SERVER, IID_IHelloObj, (void**)&IHello); if(SUCCEEDED(hr)) { hr=IHello->GetNumber(&num); hr=IHello->Release(); } else cout << "error"; } CoUninitialize(); } This is all what i ve done. Must i do more things to run the service? What can be the cause of the error? Thanks in advance!!!
-
0. What value is in hr, and when? This will tell you more about what's going wrong. 1. Are you sure you're using the correct interface IDs and class IDs? 2. Have you tried using CLSIDFromProgID to get your clsid instead? Steve S
hello, 0. com_error error(hr) (first, construct a _com_server) HRESULT_FACILITY(hr) returns 4 HRESULT_SEVERITY(hr) returns 1 error.ErrorMessage() returns "Class not registered" 1. I think so ... I get the IID and the CLSID from the _i.c file in the External Dependencies of the server project. 2. No, i haven´t. I dont know how to get the ProgID (the first parameter). I search it in some documentation and i find something like: hr = CLSIDFromProgID(OLESTR("Project_name.Object_name"),&pClsid); but it does not run (error.ErrorMessage() returns "class String is not valid") 3. I ve tried to initialize as MTA instead with CoInitializeEx(NULL, COINIT_MULTITHREADED) but i dont know what header files must i include. Is CoInitializeEx supported in Visual C++ 6.0 or is a .NET function??? A lot of thanks!!
-
hello! I am learning the MS COM/DCOM architecture. I ve developed a few simple client/server programs and I ve obtained always the same result: I think client cannot get the object. I ve used C++ with Microsift Visual C++ 6.0. To make the server I ve followed the next steps: 1- create an ATL COM AppWizard Project. 2- EXE Server. 3- New ATL object (simple object) 4- Add methods to Interface 5- Code the methods. 6- Build the project it shows me: Compiling resources... Compiling... Linking... Performing registration Server registration done! ..and client is something like this: const IID IID_IHelloObj = {0x389A6DD0,0xC789,0x463F,{0x87,0xD5,0x8C,0x3A,0x51,0xDC,0xB4,0xDF}}; const CLSID CLSID_HelloObj = {0x1635DA5A,0xD02E,0x4049,{0xB9,0x21,0x07,0xE1,0x81,0x55,0xB2,0x0E}}; void main() { HRESULT hr; IHelloObj *IHello; int num; // to test the service hr = CoInitialize(0); if(SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_HelloObj, NULL, CLSCTX_INPROC_SERVER, IID_IHelloObj, (void**)&IHello); if(SUCCEEDED(hr)) { hr=IHello->GetNumber(&num); hr=IHello->Release(); } else cout << "error"; } CoUninitialize(); } This is all what i ve done. Must i do more things to run the service? What can be the cause of the error? Thanks in advance!!!
Hello, Finally, i ve used the CLSIDFromProgID function (CLSIDFromProgID(OLESTR("HelloServer.HelloObj.1"),&pClsid)) but the result is the same: "Class not registered" I ve sawn the windows register and i think there are all the data related with the registration: LocalServer32 - path of the EXE server (HelloServer.exe) ProgID - project_name.object_name.method (HelloServer.HelloObj.1) Typelib - a String {FF638 ....) VersionIndepentProgID - HelloServer.HelloObj Apart from this, I ve tried to initialize as MTA instead with CoInitializeEx(NULL, COINIT_MULTITHREADED) but the builder does not find this function and i dont know what header files must i include. thank you very much.
-
hello! I am learning the MS COM/DCOM architecture. I ve developed a few simple client/server programs and I ve obtained always the same result: I think client cannot get the object. I ve used C++ with Microsift Visual C++ 6.0. To make the server I ve followed the next steps: 1- create an ATL COM AppWizard Project. 2- EXE Server. 3- New ATL object (simple object) 4- Add methods to Interface 5- Code the methods. 6- Build the project it shows me: Compiling resources... Compiling... Linking... Performing registration Server registration done! ..and client is something like this: const IID IID_IHelloObj = {0x389A6DD0,0xC789,0x463F,{0x87,0xD5,0x8C,0x3A,0x51,0xDC,0xB4,0xDF}}; const CLSID CLSID_HelloObj = {0x1635DA5A,0xD02E,0x4049,{0xB9,0x21,0x07,0xE1,0x81,0x55,0xB2,0x0E}}; void main() { HRESULT hr; IHelloObj *IHello; int num; // to test the service hr = CoInitialize(0); if(SUCCEEDED(hr)) { hr = CoCreateInstance(CLSID_HelloObj, NULL, CLSCTX_INPROC_SERVER, IID_IHelloObj, (void**)&IHello); if(SUCCEEDED(hr)) { hr=IHello->GetNumber(&num); hr=IHello->Release(); } else cout << "error"; } CoUninitialize(); } This is all what i ve done. Must i do more things to run the service? What can be the cause of the error? Thanks in advance!!!
-
Because you have made the EXE server, you cannot use the CLSCTX_INPROC_SERVER constant in calling of the CoCreateInstance. You should use the CLSCTX_LOCAL_SERVER or better CLSCTX_SERVER instead. With best wishes, Vita
Ohh, thanks for your help! ...but now i have got another problem :-O: HRESULT says "interface not compatible" i ve tried it with CoCreateInstanceEx instead CoCreateInstance but the result is the same. Could be the MIDL definition the cause of the problem? Code is something like this: IHelloObj *iHello; // point to teh interface remoto // other variables ans COM inicialitation //mutli_qi strcuture MULTI_QI qi = {&IID_IHelloObj, NULL, S_OK}; //server info COSERVERINFO csi; csi.pwszName = _bstr_t("localhost"); ... hr = CoCreateInstanceEx(CLSID_HelloObj,NULL,CLSCTX_SERVER,&csi, 1,&qi); // here hr and qi.hr are not succeeded if(SUCCEEDED(hr) && SUCCEEDED(qi.hr)) { // get the interface // call to remote methods ... A lot of thanks!!