我有一个SDI,中有四个视图(拆分窗口).其中两个要接收来自服务器的数据.但我没有重载csocket类,而是每次在发消息后马上接来自服务器的数据.
   建了一个g_PrimarySocket...在第一个View中初始化连接.然后第一个视图接完数据后..第四个视图再用该套接字接数据时就只能接一个类(数据是传的类的指针),第二个就抛出异常:一个未命名文件 格式错误.
我跟踪程序到archive 里面,发现有一个if判断出我这个类在某MAP表中已经存在,还有什么nIndex大于LoadArray->GetUpperBound()...if里面就是一个异常在等着我!!!!请问,这是为什么? 为什么我第一个视图里面的东西全部接收到了?第四个里面只能收到一个类的信息?
CSocket g_PrimarySocket;
///....
void InitGlobalVar()
{
CFile Config(_T("config.ini"),CFile::modeReadWrite);
CArchive arLoad(&Config,CArchive::load);
CArchive arStore(&Config,CArchive::store); arLoad >> theApp.m_bInitConfiged;
if ( theApp.m_bInitConfiged )
{
arLoad >> theApp.m_Port;
arLoad >> theApp.m_IPAddr;
}
else 
{
AfxMessageBox(_T("这是第一次使用本软件,需要您配置您的服务器地址和端口!"));
CFirstPage dlg;
dlg.DoModal();
theApp.m_IPAddr = dlg.m_SetIPAddress;
theApp.m_Port   = dlg.m_SetPortNumber;
//dlg.DoModal();
Config.SeekToBegin();
theApp.m_bInitConfiged = TRUE;
arStore << theApp.m_bInitConfiged;
arStore << theApp.m_Port;
arStore << theApp.m_IPAddr;
}
g_PrimarySocket.Create();
g_bConnected = g_PrimarySocket.Connect(theApp.m_IPAddr,theApp.m_Port);
if( !g_bConnected )
{
g_PrimarySocket.Close();
AfxMessageBox(_T("连接失败!\n请检查您的网络连接设置!"));
return ;
}
}///////
void CXXX1View::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
InitGlobalVar();
if(g_bConnected)
{....}
else{...}////////这里可以接到数据...
}
///////////
void CXXX2View::OnInitialUpdate()
{
          if(g_bConnected)
{....}
else{...}////////这里就只能接到一个数据(一个类的指针)...
}感激不尽!!!!!!!!!!!!!!!!!!!!!!将~