Click here to Skip to main content
15,884,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My solution in VC++2012 includes some executable programs & some DLLs. One of project is DataReceiver which output is a program, dataReceiver.exe. One DLL is called DataInterface, whose output is DataInterface.dll.

In main program of DataReceiver, it declares an object DataIn via class DataInput, which is defined at DataInterface project. I inserted some logging message and then found strange things happen: the DataIn's constructor seems being skipped. The detail is described as below:

The snippet of main program of DataReceiver is as below:

C++
int main(int argc, char* argv[]) 
{
    boost::thread_group thGroup;
    boost::asio::io_service io_service;
    
    logMsg ("standebug: DataReceiver/main()\n");
    try 
    {
        logMsg ("standebug: DataReceiver/main():try\n");
        DataInput dataIn;
    
        cout << "K00.00.15.06.01\nNow:"<< boost::posix_time::to_iso_string(boost::posix_time::microsec_clock::local_time()) << endl;
        logMsg ("standebug: DataReceiver/main():to start()\n");
    
        dataIn.Start();
      ....................
    }

And the DataInput's constructor begins as:
C++
DataInput::DataInput(void)
{
    m_mode = 0;

    logMsg ("standebug: DataInput::DataInput\n");
    cout << "standebug: DataInput::DataInput\n";
    m_OnChangedFn_ptr = NULL;
    ....................
}

The DataInput's method, Start() begins as:
C++
void DataInput::Start(void)
{
    logMsg ("standebug: dataInput: Start\n");
    try
    {

    ..........
}


After building them successfully, I ran 'DataReceiver.exe' under MS Command Prompt, I found the logging message is as:

VB
standebug: DataReceiver/main()
standebug: DataReceiver/main():try
standebug: DataReceiver/main():to start()


It's very obviously, after DataIn is declared, neither DataIn.DataInput() or DataIn.Start() had been executed, why?

From logging message, DataIn's constructor is never ran. How come?
Posted
Updated 4-Nov-15 19:39pm
v3
Comments
George Jonsson 5-Nov-15 1:43am    
Are you 100% sure you have loaded the correct version of DataInterface.dll?
This looks like a case of doing the changes in one version and then load an old version by mistake.
[no name] 5-Nov-15 2:02am    
Despite not being a betting man my money is on this.
George Jonsson 5-Nov-15 2:31am    
I have of course never done that mistake myself. :-D
Stan Huang 5-Nov-15 19:01pm    
You're right. The original project dependency was not checked carefully.

1 solution

There is a chance that your constructor is not default one and default is called.

I also agree with the answer that you might load wrong binary file. Try to implement DataIn inside your application where main is located, it should work.
 
Share this answer
 
Comments
Stan Huang 5-Nov-15 19:00pm    
I admit that this is DLL issue that what I linked is not the right one. The projects I was delivered have too tricky dependency.
Sergey Kizyan 6-Nov-15 3:53am    
In any case just for testing you can redefine problematic class in your area to make sure this is linking and dependency issue
Stan Huang 6-Nov-15 4:08am    
good idea

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900