|
You said:
"The index is 4"
and
"rite now listbox has only one entry."
Are you calling CListBox::GetText( 4, _case) in a CListBox that has only 1 entry?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
hey i didnt said 4....
i said only that my listbox has only 1 entry..
NT
|
|
|
|
|
You are right. I was unable to decipher you SMS-style 1337-speak.
Here.[^]
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Okey let me explain in detail.
void CMyProj::OnSelchangeList()
{
CClientdemoDlg dlgobj;
dlgobj.OnClientChangeListbox();
}
void CClientdemoDlg::OnClientChangeListbox()
{
CMyProj objnew;
CString _temp;
_temp=objnew.OnTextList();
}
CString CMyProj::OnTextList()
{
int index;
CString _case;
index = m_caselist.GetCurSel();
m_caselist.GetText(index,_case);
return _case;
}
notice the classes.......
NT
-- modified at 5:54 Thursday 16th August, 2007
NT
|
|
|
|
|
tyagineha wrote: void CClientdemoDlg::OnClientChangeListbox()
{
CMyProj objnew;
CString _temp;
_temp=objnew.OnText();
}
But in your example you show the code for CMyProj::OnTextList().
It seems as you think you are calling CMyProj::OnTextList(), but in your sample you call CMyProj::OnText()
Maybe you should look for the problem in CMyProj::OnText() ?
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Ok. What and where is your Error?
Not just "Debug Assert", but complete details, please.
I get from what you have written, that _case ist still OK, but after it has been assigned to _temp it is no longer OK?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
So you corrected your code sample without telling anyone?
I suggest you do like this:
1. Learn how to use the debugger. (It's not too hard).
2. Put a breakpoint on this line: _temp=objnew.OnTextList();
3. Single-step your code, line by line and examine what's happening.
That's it. And that's exactly what other people do, IMO.
For a good reason.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Short answer: You have created an object of type CClinetdemoDlg but you have not created the actual dialog. The call to both GetCurSel and GetText will fail because they required a window to operate on.
Long answer: You appear to be creating lots of temporary instances of the dialog and your CMyProj class. The act of creating the instance does NOT associate the just-created instance with the already existing one. In OnSelChangeList, you create a CClientdemoDlg. This is NOT associated with the actual dialog that I assume you created elsewhere. You then call OnClientChangeListbox in an instance not associated with a window. This causes the problem I mentioned earlier. Also, in that function, you create an instance of CMyProj. This instance is NOT the same as the one that called the function. This is important because you then call OnTextList in the just-created instance of CMyProj and in that function reference the member variable m_caselist. This variable is not the same as the one in the original class that started this calling chain. Accessing this variable will not affect the original caller.
Judy
|
|
|
|
|
What line of what file is asserting?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
tyagineha wrote: can any body tell me why i m getting error in this code?????????
You failed to indicate the error. We are not mind readers. Set a breakpoint on the GetCurSel() statement and single-step over each statement, noting the values of index and _case along the way.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello All,
actually i have to made a project using VS2005 with CLR support so can anybody tell me how can i use ofstream class in this project.
i am also "iostraem" but still it is giving error like
"error C2061: syntax error : identifier 'fstream'"
please share your knowledge
thanks
Bankey
|
|
|
|
|
Banks K wrote: how can i use ofstream
"error C2061: syntax error : identifier 'fstream'"
a) Did you #include <fstream> ?
b) Are you writing std::fstream OR do you have using namespace std; at the top of the file?
c) You seem to want to program a managed C++ program. You should use the .NET classes and ask question in the managed C++ forum.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Sure you can, but Microsoft is stepping so far out of previous specifications that it is becoming hard to tell where the line is.
Unless you are just using ‘ofstream’ for reading, then you have a problem that I can not solve with-out the code.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I've written a class with only three attributes:
<br />
class UTILITIES_API CStartupManager<br />
{<br />
...<br />
protected:<br />
string m_strConfigFileName;<br />
ifstream m_oConfigFile;<br />
multimap<string, string> m_oApplicationConfig;<br />
};<br />
The main application does this (and nothing else):
<br />
void InitApplication()<br />
{<br />
CStartupManager oStartupManager;<br />
<br />
oStartupManager.StartUp("app.config");<br />
<br />
return;<br />
}<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
InitApplication();<br />
return 0;<br />
}<br />
I ran it and it crashed with message "User breakpoint called from code at 0x7c901230"..
I debugged with WinDbg as Visual Studio tells me that the fiasco happens in the destructor that dooes nothing -
<br />
CStartupManager::~CStartupManager()<br />
{<br />
return;<br />
}<br />
Reading stack trace appear it's coming from attempt to free/deallocate the same chunk of memory twice:
<br />
NTDLL! 7c901230()<br />
NTDLL! 7c96cd80()<br />
NTDLL! 7c960af8()<br />
KERNEL32! 7c85e9cf()<br />
_CrtIsValidHeapPointer(const void * 0x004433a8) line 1697<br />
_free_dbg_lk(void * 0x004433a8, int 1) line 1044 + 9 bytes<br />
_free_dbg(void * 0x004433a8, int 1) line 1001 + 13 bytes<br />
free(void * 0x004433a8) line 956 + 11 bytes<br />
operator delete(void * 0x004433a8) line 7 + 9 bytes<br />
std::allocator::deallocate(void * 0x004433a8, unsigned int 33) line 64 + 38 bytes<br />
std::basic_string,std::allocator >::_Tidy(unsigned char 1) line 592<br />
std::basic_string,std::allocator >::~basic_string,std::allocator >() line 59 + 39 bytes<br />
CSomeClass::~CSomeClass() line 16 + 51 bytes
Following advice from my mentors, in hope of locating where the fault is exactly by debugging with WinDbg. Launch and attached to the target process, then run until I get:
<br />
Break instruction exception - code 80000003 (first chance)<br />
To drilldown further, "!analyze -v" seems to be telling me (the same information as Visual Studio) access violation happens in CStartupManager::~StartupManager (which does nothing)
<br />
...<br />
ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at "0x%08lx" referenced memory at "0x%08lx". The memory could not be "%s".<br />
BUGCHECK_STR: ACCESS_VIOLATION<br />
...<br />
<br />
STACK_TEXT: <br />
0012fb20 7c968b5e 01741000 018defb0 0012fb48 ntdll!RtlpDphIsNormalHeapBlock+0x81<br />
0012fb40 7c9697ae 00000007 00001002 018defb0 ntdll!RtlpDphNormalHeapValidate+0x2d<br />
0012fb84 7c960a4e 01740000 00000000 018defb0 ntdll!RtlpDebugPageHeapValidate+0x5a<br />
0012fbe8 7c85e9cf 01740000 00000000 018defb0 ntdll!RtlValidateHeap+0x36<br />
0012fbfc 1002ed00 01740000 00000000 018defb0 kernel32!HeapValidate+0x14<br />
0012fc20 1002e051 018defd0 0012fce8 0012fe14 Utilities!_CrtIsValidHeapPointer+0x120 [dbgheap.c @ 1697]<br />
0012fc3c 1002df81 018defd0 00000001 0012fce8 Utilities!_free_dbg_lk+0xa1 [dbgheap.c @ 1044]<br />
0012fc70 1002df0e 018defd0 00000001 0012fc8c Utilities!_free_dbg+0x41 [dbgheap.c @ 1001]<br />
0012fc80 1001605c 018defd0 0012fce8 100038b6 Utilities!free+0xe [dbgheap.c @ 956]<br />
0012fc8c 100038b6 018defd0 0012fd4c 0012fe14 Utilities!operator delete+0xc [delop.cpp @ 7]<br />
0012fce8 100030d2 018defd0 00000021 0012fda8 Utilities!std::allocator<char>::deallocate+0x26 [c:\program files\microsoft visual studio\vc98\include\xmemory @ 64]<br />
0012fd4c 100029b7 00000001 0012fe00 0012fe14 Utilities!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Tidy+0x82 [c:\program files\microsoft visual studio\vc98\include\xstring @ 592]<br />
0012fda8 10006571 0012ff20 0012fe14 7ffd9000 Utilities!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >+0x27 [c:\program files\microsoft visual studio\vc98\include\xstring @ 59]<br />
0012fe0c 00402912 0012ff80 00d2f778 7ffd9000 Utilities!CStartupManager::~CStartupManager+0x71 [C:\...path...\Utilities\StartupManager.cpp @ 15]<br />
0012ff2c 0040298d 00d2f6f2 00d2f778 7ffd9000 DesktopAPI!InitApplication+0x92 [C:\...path...\DesktopAPI.cpp @ 17]<br />
0012ff80 00404849 00000001 0185afb0 0185cf50 DesktopAPI!main+0x1d <br />
[C:\...path...\DesktopAPI.cpp @ 24]<br />
0012ffc0 7c816fd7 00d2f6f2 00d2f778 7ffd9000 DesktopAPI!mainCRTStartup+0xe9 [crt0.c @ 206]<br />
0012fff0 00000000 00404760 00000000 78746341 kernel32!BaseProcessStart+0x23<br />
"It happen in destructor" is getting nowhere. And its seems that the fault wasn't caught instantly but rather detected when memory is freed -- how can I enable "Full-page heap" from Global Flags so I get the violation as it happens?
While WinDbg indicates this happens in destructor CStartupManager::~CStartupManager ... seems like it's actually happenning before that.
Reference here:
Full-Page Heap
Full-page heap should be enabled for individual processes, or under limited parameters for large processes, because of its high memory requirements. It cannot be enabled system-wide, because it is difficult to evaluate the required page file size. Using a page file that is too small with system-wide full-page heap renders the system unbootable.
The advantage of full-page heap is that it causes a process to access violate (AV) exactly at the point of failure. This makes the failure easy to debug. In order to be able to pinpoint failures, first use normal page heap to determine the range where a process is failing, and then use full-page heap on individual large-scale processes for that restricted class of allocations (that is, a specific size range or a specific library).
Normal Page Heap
Normal page heap can be used for the testing of large-scale processes without the high memory consumption that full-page heap requires. However, normal page heap delays detection until blocks are freed, thus making failures more difficult to debug.
In general, use normal page heap for initial large-scale processes testing. Then, if problems are detected, enable full-page heap for a restricted class of allocations in those processes.
Many thanks!
|
|
|
|
|
What is CStartupManager::StartUp doing? You never showed us that code or just told us what you are doing there.
The debugger text you showed us clearly (for funny definitions of CLEAR, that is) states, that something happened while destructing a basic_string<char> . That is a std::string .
And its your d'tor calling basic_string d'tor. Hence the pointing at your (empty) destructor.
I bet somewhere, something is done to m_strConfigFileName .
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
I think the problem wasn't really in destructor - suspecting that it's actually happening earlier.
|
|
|
|
|
So what is CStartupManager::StartUp() doing? What's being done with m_strConfigFileName ? Can m_oConfigFile and m_oApplicationConfig be removed from the class?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
In VS2005 running on WinXP Pro, I keep getting this error, "fatal error RC1107" any time I try to double click the resource file for my project in the Solution Explorer. It's not just one project, it's all of them. And even if I make a new project just from scratch, it still happens. So there has to be something wrong with my machine right?
Here's a pic of my problem for those who care to see...
Everywhere I went, they all said it has to do with project settings, and a bug in visual studio that was adding double quotes, but my Resources Command Line looks fine:
/d "_DEBUG" /d "_AFXDLL" /l 0x409 /I "Debug" /fo"Debug/WadBuilder.res"
Any ideas would be great
Sorry if this has already been addressed a thousand times before. I did a few hours of searching on the internet, and none of the other solutions I saw worked...
Thanks in advance.
|
|
|
|
|
Try this.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Ah thanks... I had already tried googling for the error message and gone through plenty of pages, but I just went through them all again and a few more this morning, and finially found it.. Most of them were a slightly different bug, but incase someone else has the problem and ends up here:
"To fix the problem, I made a minor change to the include paths in the IDE.
Tools -> Options -> Projects and Solutions -> VC++ Directories
Show directories for: Include files
I Added a slash to my last path, so "P:\" became "P:\\". Ok the changes and the problem went away.
Hope this works for you.
Andy"
|
|
|
|
|
Hey, many thanks to you!! i was getting the same problem and then on checking my include directory list, I found '\' at end of one of the include paths. Removing that '\' solved the problem for me.
|
|
|
|
|
Thanks guys!!! I can't help but wonder how long it would have taken to fix this problem if I hadn't found this information ... the internet in general and Codeproject in particular is pretty neat some times ...
This is not a signature.
|
|
|
|
|
Thanks Guys... Its fixed for me also
|
|
|
|
|
Many thanks!!!! I can't believe it
|
|
|
|
|
Hey, thank you.. i was struggling to fix this issue since 2days... you saved my time....
I really wonder how you ended up changing the include path
|
|
|
|