Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC bugs
Hi All,
Last 20 days i spend my every morning to solved this exception but i can't get it.
Before i asked my question, let me inform you about my plateform of developement
1)Operating System:-Window 2003 server edition
2)Microsoft visual studio 2003
3)MFC Dialog based Application

______________________________________________________________________
Now,
I have one utility that take Three file from user as input.
1)BIL OF MATERIAL
2)SALES PLAN
3)MRP DETAILS

And on the basis of this file i genarate A Master file.
 
Concept working so far fine but as i allows user to enter 3 file.
so, I ask the user to select file from a CFileDialog.
There are 3 edit box and 3 browse button to do so.
Now,
When i select first file with file dailog say BIL_1.csv(*.CSV Excel file format)
File selected correctly.
But next time i click another Browse button another file dialog opens allows user to select next file but while selecting next file if my focus goes on BIL_1.csv(Previously selected file).
then instead of showing TOOLTIP text a UNHADLE EXCEPTION Came.
Unhadled Exception at 0x7c95a8ad in sapUtility.exe 0xC0000005:Access violation reading location 0x010f3850
SapUtility.exe is my project name.
A on click of break.
7C95A8A7 mov eax,dword ptr[eax+1C4H]
7C95A8d mov eax,dword ptr[eax]

and value of eax is 17774672
__________________________________________________________________
NOTE:-
1)This happen when i select files from DESKTOP.there is lots of shortcuts.
2)This happen only with .csv files utill now.
3)This happen for Tool Tip text shown
4)I dont known this may be very confusing question.
5)May be microsoft BUG.
6)Please review my previous post.
MFC Error: CFileDailog Error of 0x7c95a8ad type exception[^]
________________________________________________________
[EDIT] FOR CODE:
void CSApUtiliy::OnBnClickedButton1()
{
  CFileDialog InputFile_BOM(TRUE,"CSV","*.CSV",OF_HIDEREADONLY|OFN_PATHMUSTEXIST,"csv Files(*.csv)|*.csv|All files(*.*)|*.*||",this);  //constructor
CEdit* Input_FileText=(CEdit*)GetDlgItem(ID_EDIT2);
if(InputFile_BOM.DoModel()==IDOK)
{
  CString PathName=InputFile_BOM.GetPathName();
  Input_FileText.SetWindowText(PathName);
}
}
And For Next Button
void CSApUtiliy::OnBnClickedButton2()
{
  CFileDialog InputFile_Sale(TRUE,"CSV","*.CSV",OF_HIDEREADONLY|OFN_PATHMUSTEXIST,"csv Files(*.csv)|*.csv|All files(*.*)|*.*||",this); //constructor
CEdit* Input_FileText=(CEdit*)GetDlgItem(ID_EDIT1);
if(InputFile_Sale.DoModel()==IDOK)
{
  CString PathName=InputFile_Sale.GetPathName();
  Input_FileText.SetWindowText(PathName);
}
}
__________________________________________________________________
Surly microsoft BUG??
But want solution
All helps are grealty apretiate.
Posted 24-May-11 18:24pm
Edited 26-May-11 19:40pm
v9
Comments
Albert Holguin at 25-May-11 0:28am
   
yet you're still not showing your code...
santosh dhanawade at 25-May-11 1:06am
   
Note that exception come for only desktop file selection
Albert Holguin at 25-May-11 1:12am
   
are you selecting a file or a shortcut?
santosh dhanawade at 25-May-11 1:19am
   
I'm selecting file
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

this is an odd problem (I commonly use CFileDialog() and have never had this problem)... are you sure you're not trying to access these button simultaneously from different threads? ... another thing to try is to allocate and deallocate the heap manually (to see if forcing the deallocation of CFileDialog helps).
 
Call new CFileDialog() and delete CFileDialog() manually instead of allocating on the stack.
 
Another thing... why does the break show only assembly? ...if this is a CFileDialog on your dev machine, you should be able to see the code to see where this is breaking. Are you not seeing the problem in Debug or not using a Debugger?
  Permalink  
v3
Comments
santosh dhanawade at 25-May-11 1:19am
   
I have been try this
Albert Holguin at 25-May-11 1:19am
   
just updated...
santosh dhanawade at 25-May-11 1:20am
   
Is there CFileDialog() constructor taking 0 argument.
Albert Holguin at 25-May-11 1:23am
   
No, but there is one that takes only 1 argument, the initial argument that specifies the type of CFileDialog... also, try allocating the CString outside of the if() statement, to see if its maybe being deallocated before it gets a chance to be posted
santosh dhanawade at 25-May-11 1:22am
   
UPDATED:
With debug too i goes on Assembly
Albert Holguin at 25-May-11 1:26am
   
typically when it goes to assembly it means that there's no source code for that piece of code... which if you're using MFC, the source should be there...
Albert Holguin at 25-May-11 1:28am
   
Also note that the call should be DoModal() not DoModel(), I don't know if that's just a typo
Albert Holguin at 25-May-11 1:30am
   
Also just noticed that this Input_FileText.SetWindowText(PathName); should really be this Input_FileText->SetWindowText(PathName); since its a pointer
santosh dhanawade at 25-May-11 1:39am
   
What do mean by out side the if()
Albert Holguin at 25-May-11 1:42am
   
outside of the brackets of the if() statement, since that CString is generated within the brackets of that if() statement, it will only persist on the stack until it goes out of scope, which is at the end bracket of the if() statement... if for example, SetWindowText() happend to be asynchronous, the variable may be deallocated by the time that call uses the variable.
Albert Holguin at 2-Jun-11 0:22am
   
First make sure of those things I pointed out above (make sure DoModal() is called correctly) and make sure you're using '->' operator instead of '.' in the SetWindowText() calls.
santosh dhanawade at 25-May-11 1:22am
   
do you have Visual studio 2003
Albert Holguin at 25-May-11 1:24am
   
I've programmed in studio 6, 2003, 2005, and 2008... but I only have 2008 on this machine
santosh dhanawade at 25-May-11 1:37am
   
All you mention is just typo becouse i cant access my server code to stand allone NET machine
santosh dhanawade at 25-May-11 1:42am
   
Im not gets CFileDialog constructor taking 1 argument.
Albert Holguin at 25-May-11 1:43am
   
http://msdn.microsoft.com/en-us/library/wh5hz49d%28v=VS.71%29.aspx
santosh dhanawade at 25-May-11 1:45am
   
This links provide CFileDialog With 7 parameter as constructor argument
Albert Holguin at 25-May-11 1:47am
   
THEY'RE ALL DEFAULTED EXCEPT FOR ONE! ...this sort of proves that you don't know what you're doing at an elementary level... Sorry but its late, I'm off to sleep.
santosh dhanawade at 25-May-11 1:49am
   
Its OK Goog night surly next morning we have chat.
And Placing CString outSide if()
not working
santosh dhanawade at 25-May-11 1:49am
   
What is
THEY'RE ALL DEFAULTED EXCEPT FOR ONE!
Albert Holguin at 25-May-11 1:50am
   
I give up
santosh dhanawade at 25-May-11 1:50am
   
Dont say that please!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Try making the calls like this:
void CSApUtiliy::OnBnClickedButton1()
{
  CString PathName;
  CFileDialog InputFile_BOM(TRUE);  //constructor

  CEdit* Input_FileText=(CEdit*)GetDlgItem(ID_EDIT);
  
  if(InputFile_BOM.DoModal()==IDOK)
  {
    PathName=InputFile_BOM.GetPathName();
    Input_FileText->SetWindowText(PathName);
  }
}
 
if that works, then add arguments into the CFileDialog until you get it to do what you want.
  Permalink  
Comments
santosh dhanawade at 2-Jun-11 0:35am
   
What is difference And CFileDialog not gets one parameter let me remind you
Albert Holguin at 2-Jun-11 0:37am
   
see, you need to go back and learn a bit more C++...
Albert Holguin at 2-Jun-11 0:38am
   
...and don't downvote me unless you want me to return the favor...
Albert Holguin at 2-Jun-11 0:40am
   
Read this http://www.learncpp.com/cpp-tutorial/85-constructors/
santosh dhanawade at 2-Jun-11 0:40am
   
Its ok you give up i new that!!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

could you try this?
 
void CSApUtiliy::OnBnClickedButton1()
{
	CFileDialog InputFile_BOM(TRUE,"CSV","*.CSV",OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,"csv Files(*.csv)|*.csv|All files(*.*)|*.*||",this);  //constructor
	if(InputFile_BOM.DoModal()==IDOK)
	{
		CString PathName=InputFile_BOM.GetPathName();
		GetDlgItem( ID_EDIT2 )->SetWindowText(PathName);
	}
}
And For Next Button
void CSApUtiliy::OnBnClickedButton2()
{
	CFileDialog InputFile_Sale(TRUE,"CSV","*.CSV",OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,"csv Files(*.csv)|*.csv|All files(*.*)|*.*||",this); //constructor
	if(InputFile_Sale.DoModal()==IDOK)
	{
		CString PathName=InputFile_Sale.GetPathName();
		GetDlgItem( ID_EDIT1 )->SetWindowText(PathName);
	}
}
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 328
1 Sergey Alexandrovich Kryukov 295
2 Gihan Liyanage 292
3 ClimerChinna 232
4 Abhinav S 192
0 Sergey Alexandrovich Kryukov 8,213
1 OriginalGriff 7,089
2 CPallini 2,598
3 Richard MacCutchan 1,925
4 Abhinav S 1,778


Advertise | Privacy | Mobile
Web03 | 2.8.140826.1 | Last Updated 2 Jun 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100