Home Help Center

a runtime error

i have succeed in compiling and linking the "hello world example" (the example in notebook) .
but when i run them .


what i do are as follows:
1 . run the server.exe (nothing happen)
2 . run the client.exe
it shows that
"This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information."

the server dose not receive the message "hello world".

thanks !

Comments

  • fw_cshafw_csha Member
    /////////////////////////////////////////
    //server.cpp
    /////////////////////////////////////////
    #include <Ice/Ice.h>
    #include "Printer.h"
    using namespace std;
    class PrinterI : public Printer {
    public:
    virtual void printString(const string & s,const Ice::Current &);
    };
    void PrinterI::printString(const string & s, const Ice::Current &)
    {
    cout << s << endl;
    }
    int
    main(int argc, char* argv[])
    {
    int status = 0;
    Ice::CommunicatorPtr ic;
    try {
    ic = Ice::initialize(argc, argv);
    Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(
    "SimplePrinterAdapter", "default -p 22222");
    Ice::ObjectPtr object = new PrinterI;
    adapter->add(object,
    Ice::stringToIdentity("SimplePrinter"));
    adapter->activate();
    ic->waitForShutdown();
    } catch (const Ice::Exception & e) {
    cerr << e << endl;
    status = 1;
    } catch (const char * msg) {
    cerr << msg << endl;
    status = 1;
    }
    if (ic)
    ic->destroy();
    return status;
    }

    /////////////////////////////////////
    //client.cpp
    /////////////////////////////////////

    #include <Ice/Ice.h>
    #include "Printer.h"
    using namespace std;
    int
    main(int argc, char * argv[])
    {
    int status = 0;
    Ice::CommunicatorPtr ic;
    try {
    ic = Ice::initialize(argc, argv);
    Ice::ObjectPrx base = ic->stringToProxy(
    "SimplePrinter:default -p 22222");
    PrinterPrx printer = PrinterPrx::checkedCast(base);
    if (!printer)
    throw "Invalid proxy";
    printer->printString("Hello World!");
    } catch (const Ice::Exception & ex) {
    cerr << ex << endl;

    status = 1;
    } catch (const char * msg) {
    cerr << msg << endl;
    status = 1;
    }

    if (ic)
    ic->destroy();
    return status;
    }
  • stephanstephan Member Stephan StapelOrganization: Stephan StapelProject: BristolNG
    Imho not too much wrong with the code.
    As you seem to be running Windows (the error message you wrote is a Windows error message, isn't it?), did you try to run the application from within Visual Studio? The integrated debugger should give additional information.

    Also: Did you compile your program in debug mode? If so, please try to use release mode and see if the program still breaks down. I had some cases where debug mode applications crashed whereas the release mode compiled versions run perfectly...

    regs,

    Stephan
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Crash in debug, works fine in release ... sounds like a runtime library issue.

    When you build Ice in debug more, everything is built with /MDd: all the libraries have a 'd' suffix (e.g. iced.lib and ice15d.dll) and are linked with the debug multi-threaded VC++ runtime DLLs.

    When you build Ice in release mode, everything is built with /MD: no 'd' suffix (ice.lib, ice15.lib), and all the libraries and linked with the release multi-threaded VC++ runtime DLLs.

    When you build your application, choose /MD or /MDd, and link with the corresponding Ice libraries.

    Cheers,
    Bernard
  • stephanstephan Member Stephan StapelOrganization: Stephan StapelProject: BristolNG
    Originally posted by bernard
    Crash in debug, works fine in release ... sounds like a runtime library issue.

    I didn't say that this is the problem. That was just an assumption :)
  • fw_cshafw_csha Member
    Originally posted by bernard
    Crash in debug, works fine in release ... sounds like a runtime library issue.

    When you build Ice in debug more, everything is built with /MDd: all the libraries have a 'd' suffix (e.g. iced.lib and ice15d.dll) and are linked with the debug multi-threaded VC++ runtime DLLs.

    When you build Ice in release mode, everything is built with /MD: no 'd' suffix (ice.lib, ice15.lib), and all the libraries and linked with the release multi-threaded VC++ runtime DLLs.

    When you build your application, choose /MD or /MDd, and link with the corresponding Ice libraries.

    Cheers,
    Bernard



    I have tried to compile the files in release ,but the problem still exists.

    Maybe it is caused by the config file that does't have extended name.

    Where could i find some instructions for writing the config file?



    #
    # The client reads this property to create the reference to the
    # "hello" object in the server.
    #
    Hello.Proxy=hello:tcp -p 10000:udp -p 10000:ssl -p 10001

    #
    # The server creates one single object adapter with the name
    # "Hello". The following line sets the endpoints for this
    # adapter.
    #
    Hello.Endpoints=tcp -p 10000:udp -p 10000:ssl -p 10001

    #
    # Warn about connection exceptions
    #
    Ice.Warn.Connections=1

    #
    # We want a faster ACM for this demo.
    #
    Ice.ConnectionIdleTime=10

    #
    # Network Tracing
    #
    # 0 = no network tracing
    # 1 = trace connection establishment and closure
    # 2 = like 1, but more detailed
    # 3 = like 2, but also trace data transfer
    #
    Ice.Trace.Network=0

    #
    # Protocol Tracing
    #
    # 0 = no protocol tracing
    # 1 = trace protocol messages
    #
    Ice.Trace.Protocol=0

    #
    # Security Tracing
    #
    # 0 = no security tracing
    # 1 = trace warning messages
    # 2 = config file parsing warnings
    #
    IceSSL.Trace.Security=0

    #
    # SSL Configuration File
    #
    # An XML based file that specifies the certificates, keys, SSL version
    # and other pertinent information for creating an SSL connection.
    #
    Ice.Plugin.IceSSL=IceSSL:create
    IceSSL.Client.CertPath=../../../certs
    IceSSL.Client.Config=sslconfig.xml
    IceSSL.Server.CertPath=../../../certs
    IceSSL.Server.Config=sslconfig.xml

    #
    # Glacier settings
    #
    Glacier.Router.Endpoints=default -p 10005
    Glacier.Router.Client.Endpoints=tcp:udp:ssl
    Glacier.Router.Trace.Client=2
    Glacier.Router.Trace.RoutingTable=1

    #
    # Uncomment the following lines if you want to run this demo with Glacier
    #
    #Ice.Default.Router=Glacier/router:default -p 10005

    #
    # IcePack registry settings (assumes that a db directory exists in the
    # current working directory).
    #
    IcePack.Registry.Client.Endpoints=default -p 10006
    IcePack.Registry.Server.Endpoints=default
    IcePack.Registry.Admin.Endpoints=default
    IcePack.Registry.Data=db
    IcePack.Registry.DynamicRegistration=1

    #
    # Uncomment the following lines if you want to run this demo with the
    # IcePack registry. Note that we override properties previously set
    # above, so make sure to comment out these properties to run the demo
    # without IcePack.
    #
    #[email protected]
    #Hello.Endpoints=tcp:udp:ssl
    #Hello.AdapterId=HelloAdapter
    #Ice.Default.Locator=IcePack/Locator:default -p 10006
  • stephanstephan Member Stephan StapelOrganization: Stephan StapelProject: BristolNG
    Originally posted by fw_csha

    Maybe it is caused by the config file that does't have extended name.
    Where could i find some instructions for writing the config file?

    No, the extension is not the problem. The ice runtime takes any file that is passed to the executable through

    executable.exe --Ice.Config=myfile.txt

    However, your server app states "-p 222222" while the config says "-p 10000". Are you sure that this is the desired setting?

    Maybe the client doesn't find the servant. Are you checking for null pointers and catching exceptions in the client?

    regs,

    Stephan
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    For this very simple application, you don't even need any configuration. Like Stephan suggested in his first post, the best would be to debug this problem in Visual Studio.

    Also double-check that you build with /MDd and link with iced.lib and iceutild.lib. You also need to use the same version of Visual C++ to build Ice and to build your application.

    Cheers,
    Bernard
  • BalooBaloo Member
    I'm not sure if this is what you are looking for, but I had similar problems, so I'm gonna write down what I had to set in VS.NET 2003 (C++):

    debug multithreaded dll (for debug)
    multithreaded dll (for release)
    RTTI enabled (C++/language)
    linker: ice.lib/iceutil.lib (can be done with #pragma comment(lib, "<libname>")

    I think that's all. If I remember correctly, in my case RTTI solved the errors you posted.

    Hope that helps!


    Baloo

    p.s.: remember, these are for VS.NET 2003 + C++
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    You must use ice.lib and iceutil.lib for release only. Use iced.lib and iceutild.lib for debug.
  • fw_cshafw_csha Member
    Originally posted by Baloo
    I'm not sure if this is what you are looking for, but I had similar problems, so I'm gonna write down what I had to set in VS.NET 2003 (C++):

    debug multithreaded dll (for debug)
    multithreaded dll (for release)
    RTTI enabled (C++/language)
    linker: ice.lib/iceutil.lib (can be done with #pragma comment(lib, "<libname>")

    I think that's all. If I remember correctly, in my case RTTI solved the errors you posted.

    Hope that helps!


    Baloo

    p.s.: remember, these are for VS.NET 2003 + C++



    thanks so so so ~~~~~~ much!!!

    "in my case RTTI solved the errors you posted."

    so do i :)
Sign In or Register to comment.