473,609 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MFC application crash

HI All,
I have created a MFC exe using VC++ .NET 2003 on Windows XP Prof
service pack 2 and it works properly on my machine, but when I run the
same exe on a different machine (Windows XP Prof SP-2), The application

is bought up and after some time its throwing a windows xp error dialog

box saying,

I am also running the same application on 2 more machines there
everything works fine.

Here is thr Windows XP error dialog box that appreas when its crashed
TODO: <File descriptionhas encountered a problem and needs to close.
We are sorry for any inconenience.

If you are in the middle of something, the information you were working

on might be lost.
Please tell Microsoft about this problem.
blab blah....
I have function called OnNotifyNewData (WPARAM wParam, LPARAM lParam)
which appreas to be cauing the problem. When I run the application
commenting this function its didnt crashed.

LRESULT CUserViewFrame: :OnNotifyNewDat a (WPARAM wParam, LPARAM lParam)
{
const char* strVariable("CU serViewFrame::O nNotifyNewData START");
const char* strValue("6");
CUtility::LogDe bugInfo( strVariable, strValue);

WRITE_LOG_FUNCT ION_ENTRY("LRES ULT CUserViewFrame: :OnNotifyNewDat a
(WPARAM wParam, LPARAM lParam)")

PInstData pInstData = (PInstData)wPar am;
if (!pInstData) return 0;

CString csText;
char buffer[255];
LVFINDINFO info;
int iIndex = 0;

PSystemSetting pSystemSetting = CSystemSetting: :GetObject();

info.flags = LVFI_WRAP|LVFI_ STRING;
std::vector<CMa rketData>::cons t_iterator iter;
std::vector<CPa rticipant>::con st_iterator iterpart;

const std::vector<CMa rketData& userListBid =
pInstData->GetMarketDataB id();
for (iter = userListBid.beg in(); iter != userListBid.end (); iter++)
{
const std::vector<CPa rticipant& participants =
iter->GetParticipant s();
for (iterpart = participants.be gin(); iterpart != participants.en d();
iterpart++)
{
if (iterpart->GetSize() 0.0 && iter->GetPrice() 0.0)
{
memset(&buffer, 0, sizeof(buffer)) ;
if (sizeof(iterpar t->GetUserName( )/*.c_str()*/) 255
continue;
//sprintf(buffer, "%s", iterpart->GetUserName( )/*.c_str()*/);
info.psz = iterpart->GetUserName( );
iIndex = m_ctrlUserListC trl.FindItem(&i nfo);
if (iIndex == -1)
{ // insert the item
iIndex = m_ctrlUserListC trl.GetItemCoun t();

if (sizeof(iterpar t->GetUserName( )/*.c_str()*/) 255
continue;
//csText.Format(T EXT("%s"), iterpart->GetUserName( )/*.c_str()
csText = iterpart->GetUserName( ); //Sanjeev 012407
int size = iterpart->GetUserName(). GetLength();
char bufsize[20];
memset(&bufsize , 0, sizeof(bufsize) );
_itoa(size,bufs ize,10);
CUtility::LogDe bugInfo( "OnNotifyNewDat a - BID UserName", bufsize);
m_ctrlUserListC trl.InsertItem( LVIF_TEXT|LVIF_ STATE, iIndex, csText,
0, LVIS_SELECTED, 0, 0);
char * pchText = new char [csText.GetLengt h() + 1];
strcpy(pchText, (LPCTSTR)csText );
m_ctrlUserListC trl.SetItemData (iIndex, (DWORD)pchText) ;
}
if (sizeof(pInstDa ta->GetInstName( )/*.c_str()*/) 255)
continue;
//csText.Format(T EXT("%s"),
pInstData->GetInstName( )/*.c_str()*/); csText =
pInstData->GetInstName( );
m_ctrlUserListC trl.SetItemText (iIndex,
eUserViewListCo lumn::BID_INST, csText);

memset(&buffer, 0, sizeof(buffer)) ;
sprintf(buffer, "%%.%df", pSystemSetting->GetDecimalSize ());
csText.Format(b uffer, iterpart->GetSize());
m_ctrlUserListC trl.SetItemText (iIndex,
eUserViewListCo lumn::BID_SIZE, csText);

memset(&buffer, 0, sizeof(buffer)) ;
sprintf(buffer, "%%.%df", pSystemSetting->GetDecimalPric e());
csText.Format(b uffer, iter->GetPrice());
m_ctrlUserListC trl.SetItemText (iIndex,

eUserViewListCo lumn::BID_PRICE , csText);

if (sizeof(iterpar t->GetTimestamp() .c_str()) 255)
continue;
csText.Format(" %s", iterpart->GetTimestamp() .c_str());
m_ctrlUserListC trl.SetItemText (iIndex,
eUserViewListCo lumn::BID_TIME, csText);
}
}
}

const std::vector<CMa rketData& userListAsk =
pInstData->GetMarketDataA sk();
for (iter = userListAsk.beg in(); iter != userListAsk.end (); iter++)
{
const std::vector<CPa rticipant& participants =
iter->GetParticipant s();
for (iterpart = participants.be gin(); iterpart != participants.en d();
iterpart++)
{
if (iterpart->GetSize() 0.0 && iter->GetPrice() 0.0)
{
memset(&buffer, 0, sizeof(buffer)) ;
if (sizeof(iterpar t->GetUserName( )/*.c_str()*/) 255)
continue;
//sprintf(buffer, "%s", iterpart->GetUserName( )/*.c_str()*/);
int size = iterpart->GetUserName(). GetLength();
char bufsize[20];
memset(&bufsize , 0, sizeof(bufsize) );
_itoa(size,bufs ize,10);
CUtility::LogDe bugInfo( "OnNotifyNewDat a - ASK UserName", bufsize);
info.psz = iterpart->GetUserName( );
iIndex = m_ctrlUserListC trl.FindItem(&i nfo);
if (iIndex == -1)
{ // insert the item
iIndex = m_ctrlUserListC trl.GetItemCoun t();
if (sizeof(iterpar t->GetUserName( )/*.c_str()*/) 255)
continue;
//csText.Format(T EXT("%s"), iterpart->GetUserName( )/*.c_str()*/);
csText = iterpart->GetUserName( );
m_ctrlUserListC trl.InsertItem( LVIF_TEXT|LVIF_ STATE, iIndex, csText,
0, LVIS_SELECTED, 0, 0);
char * pchText = new char [csText.GetLengt h() + 1];
strcpy(pchText, (LPCTSTR)csText );
m_ctrlUserListC trl.SetItemData (iIndex, (DWORD)pchText) ;
}
if (sizeof(pInstDa ta->GetInstName( )/*.c_str()*/) 255)
continue;
//csText.Format(T EXT("%s"), pInstData->GetInstName(). c_str());
csText = pInstData->GetInstName( );
m_ctrlUserListC trl.SetItemText (iIndex,

eUserViewListCo lumn::ASK_INST, csText);

memset(&buffer, 0, sizeof(buffer)) ;
sprintf(buffer, "%%.%df", pSystemSetting->GetDecimalSize ());
csText.Format(b uffer, iterpart->GetSize());
m_ctrlUserListC trl.SetItemText (iIndex,

eUserViewListCo lumn::ASK_SIZE, csText);

memset(&buffer, 0, sizeof(buffer)) ;
sprintf(buffer, "%%.%df", pSystemSetting->GetDecimalPric e());
csText.Format(b uffer, iter->GetPrice());
m_ctrlUserListC trl.SetItemText (iIndex,

eUserViewListCo lumn::ASK_PRICE , csText);

if (sizeof(iterpar t->GetTimestamp() .c_str()) 255)
continue;
csText.Format(" %s", iterpart->GetTimestamp() .c_str());
m_ctrlUserListC trl.SetItemText (iIndex,

eUserViewListCo lumn::ASK_TIME, csText);
}
}
}

VERIFY(m_ctrlUs erListCtrl.Sort Items( CompareFunction , r

einterpret_cast <DWORD>(&m_ctrl UserListCtrl))) ;

WRITE_LOG_FUNCT ION_EXIT("LRESU LT
CUserViewFrame: :OnNotifyNewDat a (WPARAM wParam,
PARAM
lParam)")

const char* strVariable1("C UserViewFrame:: OnNotifyNewData END");
CUtility::LogDe bugInfo( strVariable1, strValue);

return 0;
}
Is there any chance the sprintf or CString Format function is creating
this problem.

I have spent lot of time it undertsanding this bug with no success. Any
help would be greatly appreciated.

Regards,
Sandy

Jan 24 '07 #1
4 3082
Sandy wrote:
HI All,
Please stop posing the same off topic question over and over again.

--
Ian Collins.
Jan 24 '07 #2
"Sandy" <sr******@gmail .comwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
<snip>

Hmm, if you write programs as you post requests for help, it's no wonder your
programs crash.

Try asking your question on:
microsoft.publi c.dotnet.langua ges.vc

This group is for standard C++ only.

--
"It is easy in the world to live after the world's opinion; it easy in solitude
to live after our own; but the great man is he who in the midst of the crowd
keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 24 '07 #3
>
Is there any chance the sprintf or CString Format function is creating
this problem.
Every chance. It's clear from your code that you don't understand how
the various types of string available to you work. Also you appear to
misunderstand sizeof (it doesn't test the length of a string).
I have spent lot of time it undertsanding this bug with no success. Any
help would be greatly appreciated.
Rewrite from scratch, write a little at a time, and test thouroughly as
you go. Ask specific questions in this group. A huge mess of code (and
it is a mess) and an unfocussed question is unlikely to get you much
help here.

I'd also suggest that you learn one string system (i.e. std::string or
CString or char arrays) and stick with it. std::string is obviously the
best in general terms.

John
>
Regards,
Sandy
Jan 24 '07 #4
"Sandy" <sr******@gmail .comwrote:
>HI All,
I have created a MFC exe using VC++ .NET 2003 on Windows XP Prof
service pack 2 and it works properly on my machine, but when I run the
same exe on a different machine (Windows XP Prof SP-2), The application
You're in the wrong group. You're far more likely to find help in
microsoft.publi c.vc.mfc

--
Tim Slattery
Sl********@bls. gov
http://members.cox.net/slatteryt
Jan 25 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2062
by: tony | last post by:
hi. i have net application that is compose of dll in vb.net and c managed code , and unmanaged. the application crash after 8-9 hours of running. its crash without any message box of exception (i compile it in debug mode ). i guess it crash in the unmanaged code, but im not sure.
0
2250
by: roni | last post by:
hi. i have application written in vb.net + managed c++ dll that call also to unmanaged c++ function. the application crash. i open the dump file of the crash with WinDbg and that's is the call stack (using the sos.dll) : =====================================
6
3672
by: GL | last post by:
I am getting a crash while exiting from my application. Pl find the Stack Trace of the crash: System.Windows.Forms.Application.ThreadWindows.ThreadWindows(System.Windows.Forms.Control parent = <undefined value>, bool onlyWinForms = true) + 0x8c bytes system.windows.forms.dll!ThreadContext.DisposeThreadWindows() + 0x54 bytes system.windows.forms.dll!ThreadContext.Dispose() + 0xa1 bytes...
1
2253
by: tony | last post by:
hi. my NET application is using mixed c++ dll ( managed and unmanaged) in that dll , im calling api's of unamanged dll. my application crash with no exception or warning. its hard to find when the crash happen ,and where.
7
6677
by: Ralf Gedrat | last post by:
Hello! I have some Vb.Net applications, which are terminated at indefinite times without message. If I call in the program regulated system.GC.Collect, then the program is terminated here sporadically without message. It's not possible to debug in visual studio, i get no exceptions (application is terminated unexpectedly without message).
5
4531
by: Sam Loveridge | last post by:
Hi All. I'm hoping someone can point me in the direction of a solution to unhandled exceptions in MDI child forms causing the application to crash. I've found various articles describing a method using Application.Run(new MyMainParentForm) to place in the application's Sub Main to allow catching of unhandled exceptions in the application. The problem I'm facing is that I want to be able to trap unhandled exceptions at the MDI child...
5
4527
by: Frank Rizzo | last post by:
I have a c# 2.0 winform app that runs under a user account with very limited rights. The application crashes on some actions (the Send Error to Microsoft screen) with unauthorized exception. This is despite the fact that I have try catch blocks around pretty much absolutely everything. I've tried logging to disk, but it seems to crash on a deeper level. The app works fine when run under an admin account. So how can I audit what the...
3
2269
by: Nalaka | last post by:
Hi, Can you tell me what type a things in asp.net code can crash... "application pool". Any example would do.... I was under imresiion that code cannot crash the app pool. Any direction is deeply appreciated Nalaka
4
2208
by: timor.super | last post by:
Hi group, I have a strange error. I'm a beginner with dotnet 3.0, when i try to run an wpf application from my windows explorer, the application crash. For example, i've downloaded the demo project at this url : http://www.codeproject.com/useritems/wpfdemo1.asp, that contains an exe and the source code.
6
2255
by: Tony Johansson | last post by:
Hello! We have a C#.ASP.NET application that runs on a IIS 6. The application contains actually several asp pages but there is no GUI. The application receive an xml file that is processed. There is also an MFC dll that is called from this asp application to make a syntax check on quite many commands. You don't have to know what a command is. The problem that we get is the following when the asp pages calls the MFC
0
8109
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8035
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8509
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8188
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5502
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4002
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2502
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1630
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.