Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. ussoftproblem with COM server registration???

ussoftproblem with COM server registration???

Scheduled Pinned Locked Moved COM
c++comsysadminarchitecturehelp
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pelos
    wrote on last edited by
    #1

    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!!!

    S A P V 4 Replies Last reply
    0
    • P pelos

      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!!!

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      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

      P 1 Reply Last reply
      0
      • P pelos

        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!!!

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        You initialized client as single threaded apartment. It won't work if you don't have message queue. Try to initialize as MTA instead: CoInitializeEx(NULL, COINIT_MULTITHREADED) Edward

        1 Reply Last reply
        0
        • S Steve S

          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

          P Offline
          P Offline
          pelos
          wrote on last edited by
          #4

          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!!

          1 Reply Last reply
          0
          • P pelos

            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!!!

            P Offline
            P Offline
            pelos
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • P pelos

              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!!!

              V Offline
              V Offline
              Vi2
              wrote on last edited by
              #6

              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

              P 1 Reply Last reply
              0
              • V Vi2

                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

                P Offline
                P Offline
                pelos
                wrote on last edited by
                #7

                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!!

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups