Archived

This forum has been archived. Please start a new discussion on GitHub.

Managed C++ extensions and ICE

I tried to insert some simple ICE code in my existing program, which is written using MS managed C++ extensions. And I got all sort of compilation errors. From the error messages I understand that ICE header files redefine some standard managed C++ definitions. My question is: is it possible to make managed extensions and ICE work together? If it is possible, could you give guidelines how to do this?
I use ICE v 2.0 and MS VS .NET 2003.

Thanks,
Sergei.

Comments

  • We have never tried to make Ice work with managed C++ -- it simply wasn't designed for that, and we have never tried this. But, if you can post a list of the symbols that you think cause problems, we can at least have a look at this.

    Cheers,

    Michi.
  • Thanks for quick reply!

    I made the program compile!
    There were two symbols redefined "MessageBox" and "GetObject". After I undefined them (and defined them back after problem lines using push_macro and pop_macro pragmas) compilation was successful. I'm still not sure if this is it. Will continue tests and will add more ICE code.

    Thanks,
    Sergey.
  • I very much doubt that either of these symbols is defined by Ice. More likely, you got those by including some other header file. At any rate, good to hear that things are working for you!

    Cheers,

    Michi.
  • Just for test, I inserted <Ice.h> header only, no other code or headers. Perhaps, ICE redefines not those symbols, but some global symbols, like WINNT40 or similar, which caused MS's headers to switch "MessageBox" and "GetObject" definitions. I didn't insert any usable code yet, but will do it soon and will report my findings.

    Regards,
    Sergei.
  • No luck. Everything has been compiled successfully, I was able to start the program and perform ICE initialization (got communicator pointer and object proxy), but when I tried to communicate with my server, I got managed code exception "Could not load type Ice.ConnectionI". It looks like it couldn't load the ICE run-time (or part of it). Any suggestions? Or just forget about managed C++?

    Regards,
    Sergei.
  • The nice thing about .NET is that all languages using the common language infrastructure have access to the same set of classes and types. In particular, classes defined and implemented in C# can be subclassed, instantiated, etc. in Managed C++.

    If you use the Slice-to-C# compiler to generate C# skeleton and proxy code, and then compile them into MSIL using Microsoft's C# compiler, the result is a set of .NET classes which can be used from any other .NET language. You can then write your servant classes and client code in C#, VB.NET, Managed C++, or any other language for which a .NET compiler exists.
  • Dear Wyzard, are you telling me, that if I produce and complile skeleton code in C#, then the rest of my managed C++ code will work with ICE?

    Thanks,
    Sergei.
  • I haven't tried it specifically with Ice so I can't say from experience that it definitely will work, but that's how .NET works in general, Ice or not. Once you've compiled some code, it doesn't matter what language it was originally written in.
  • Thanks for your advice, Wyzard. I've made it work! But to do that, one has to switch from Ice C++ mapping to C# mapping completely.
    What I've done to build a client:
    1. Produced a cs file from slice definition file (slice2cs).
    2. Opened new C# library project and inserted generated cs file. Added a reference to icecs.dll
    3. Built that library.
    4. Removed all the Ice headers from managed C++ code. Inserted references to the produced library and to icecs.dll instead.
    5. Replaced the Ice C++ mapping code with the C# one. For example, instead of using IceUtil::createProperties(...) used Ice::Util::createProperties() or replaced XxxxPrx::checkedCast(...) with XxxxPrxHelper::checkedCast(). So actually I used C# Ice mapping in C++ code.
    And the client worked! And, BTW, no need to change "define" directives (see my previous posts above), because there are no Ice headers in the code.
    I've not tried to make a server in managed C++ yet. Will try soon.

    Sergei.
  • Server part is working too. Same thing, C# mapping, i.e. derive your interface class from _<interfacename>Disp class, not from <interfacename> class.

    Regards,
    Sergei.