Strange error?

This is a discussion on Strange error? within the C++ Programming forums, part of the General Programming Boards category; I get a very strange error, when I try to run my program: This application has requested the Runtime to ...

  1. #1
    C++ Programmer
    Join Date
    Aug 2005
    Posts
    39

    Strange error?

    I get a very strange error, when I try to run my program:

    This application has requested the Runtime to terminate it in an unusual way.
    Please contact the application's support team for more information.
    Does anyone know what this means? And does anyone know how to fix this?

    My program code:

    request.h
    Code:
    //
    // Create prototype from Request class
    //
    class Request
    {
          public:
                 Request();
                 ~Request();
                 
                 // Main function
                 bool handle_requests();
                 
                 // MySQL Functions
                 bool connect_to_db();
                 
          protected:             
                 // Winamp vars
                 WINAMPCOMLib::IApplicationPtr winamp;
                 
                 // MySQL vars
                 MYSQL * mysql_conn;
                 MYSQL_RES * result;
                 MYSQL_ROW row;
                 
    };
    main.cpp
    Code:
    #include <windows.h>
    #include <mysql.h>
    #include <iostream>
    #include <stdio.h>
    
    #pragma comment(lib, "D:\\server\\mysql\\lib\\opt\\libmysql.lib")
    
    #import "c:\program files\winamp\plugins\gen_com.dll"
    #include "request.h"
    
    using namespace std;
    
    //
    // Define class functions
    //
    Request::Request()
    {
    	cout << "Create winamp instance..." << endl;
    	// Create winamp instance
    	Request::winamp.CreateInstance(__uuidof(WINAMPCOMLib::Application));
    	
    	cout << "Done." << endl;			
    }
    Request::~Request()
    {
    	mysql_close(Request::mysql_conn);
    }
    
    bool Request::connect_to_db()
    {
    	cout << "Connecting to Database..." << endl;
    	Request::mysql_conn = mysql_init(NULL);
    	if(!mysql_real_connect(Request::mysql_conn, "localhost", "lucas", "***", "luckyradio", 0, NULL, 0))
    	{
    		cout << "Could not connect to database:\n" << mysql_error(Request::mysql_conn) << endl;
    		return false;
    	}
    	
    	cout << "Done." << endl;
    	return true;
    }
    
    bool Request::handle_requests()
    {
    	cout << "Winamp Request Handler started." << endl;
    	bool loop_started = false;
    	while(true)
    	{
    		if(!loop_started)
    		{
    			cout << "Staring Loop..." << endl;
    			loop_started = true;
    		}
    		
    		if(Request::winamp->CurrentPos == 0)
    		{
    			cout << "End of song..." << endl;
    			if(!mysql_query(Request::mysql_conn, "SELECT * FROM winamp_requests ORDER BY request_id ASC LIMIT 1"))
    			{
    				cout << "Query failed" << endl;
    				return false;
    			}
    			
    			Request::result = mysql_use_result(Request::mysql_conn);
    			Request::row = mysql_fetch_row(Request::result);
    			
    			cout << "Query succesfull" << endl;
    			
    			if(mysql_num_rows(Request::result))
    			{
    				cout << "We got a request!" << endl;
    				long playlist_pos = reinterpret_cast<long>(row[1]);
    			
    				Request::winamp->put_PlayListPos(playlist_pos);
    				Request::winamp->Play();
    				
    				cout << "Requesting: " << winamp->GetSongTitle(playlist_pos) << "..." << endl;
    			}
    			
    			mysql_free_result(Request::result);
    			
    			char sql[255];
    			sprintf(sql, "DELETE FROM winamp_requests WHERE request_id = %d", row[0]);
    			
    			if(!mysql_query(Request::mysql_conn, sql))
    			{
    				cout << "Query Failed" << endl;
    				return false;
    			}  						
    		}
    	}
    	
    	return false;
    }
    
    //
    // Start main program
    //
    int main()
    {
    	system("title Winamp MySQL Requests Handler");
    	cout << "Starting winamp Request handler...." << endl;
    	
    	Request request;
    	if(request.connect_to_db())
    	{
    		request.handle_requests();
    	
    		cout << "End of Program" << endl;
    		cin.get();
    	}
    	else
    	{
    		cout << "Error in connecting to Database!" << endl;
    		cin.get();
    	}
    	
    	return 0;
    }
    Thanks
    Last edited by MrLucky; 02-03-2006 at 01:36 PM.

  2. #2
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    you return 1 from your main method. That indicates an error. Applications should always return 0 on successful completion.

  3. #3
    C++ Programmer
    Join Date
    Aug 2005
    Posts
    39
    Hmm, I changed it, but still got the error:

    http://www.aoe3capitol.nl/images/requester_error2.png

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    Basically, your program crashed. Run it through the debugger to see where the crash occurs.

    A return code of 0 indicating success is the common usage, but there is nothing that says it has to be that way. You can return whatever your want from your own program if it has a specific meaning to your application.

  5. #5
    C++ Programmer
    Join Date
    Aug 2005
    Posts
    39
    Ok, thnx

    I tried to debug it and I got this as a result:

    'Requester.exe': Loaded 'C:\Documents and Settings\Lucas\My Documents\Visual Studio 2005\Projects\Requester\debug\Requester.exe', Binary was not built with debug information.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\Documents and Settings\Lucas\My Documents\Visual Studio 2005\Projects\Requester\debug\libmysql.dll', Binary was not built with debug information.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\wsock32.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\ws2_32.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\apphelp.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\mswsock.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\dnsapi.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\winrnr.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\wldap32.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\rasadhlp.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\Program Files\Google\Google Desktop Search\GoogleDesktopNetwork1.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\Program Files\Google\Google Desktop Search\GoogleDesktopNetwork2.dll', No symbols loaded.
    'Requester.exe': Unloaded 'C:\Program Files\Google\Google Desktop Search\GoogleDesktopNetwork2.dll'
    'Requester.exe': Loaded 'C:\WINDOWS\system32\hnetcfg.dll', No symbols loaded.
    'Requester.exe': Loaded 'C:\WINDOWS\system32\wshtcpip.dll', No symbols loaded.
    First-chance exception at 0x7c81eb33 in Requester.exe: Microsoft C++ exception: _com_error at memory location 0x0012fdf8..
    Unhandled exception at 0x7c81eb33 in Requester.exe: Microsoft C++ exception: _com_error at memory location 0x0012fdf8..
    A COM error..
    Does anyone have a possible fix for this?

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    When the exception is thrown, the debugger should stop and let you see the call stack at the time of the exception. Look at the call stack, and find the function closest to the top of the stack that you wrote. Then you can poke around at the variables at that level of the call stack to see if you notice anything wrong. You can tell whether it is crashing during a call to connect_to_db or to handle_requests. I don't know what that specific error is from, but you can use the debugger to get a lot more information.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 03:09 AM
  2. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21