|
OK. I have seen this happen when some of the project files are write protected (Read Only).
Could that be the reason of your problems?
|
|
|
|
|
did you remember to also copy the res subdirectory?
Steve
|
|
|
|
|
MAN I AM COPYING ENTIRE PROJECT FOLDER
|| ART OF LIVING ||
|
|
|
|
|
If you have the same project open in two instances of Visual Studio then the second does not show the class view.
Oh, please get rid the caps lock!
Elaine
The tigress is here
|
|
|
|
|
I am not opening same project.
My problem is still unsolved
|| ART OF LIVING ||
-- modified at 23:34 Friday 28th October, 2005
|
|
|
|
|
Hello,
I have a problem I don't know how to fix
I've got some code that works perfectly in the main executable, but falls over if moved to a dll
Heres some code written to highlight the problem:
The first example works perfectly:
The method setString sets sMyString to “happy string” and everything works just dandy
#include "LocalStringRefTest.h"
#include <string>
#include <stdio.h>
using namespace std ;
int main(int argc, char* argv[])
{
{
string sMyString;
sMyString = "";
{
LocalStringRefTest tester;
tester.setString(sMyString);
}
printf (sMyString.c_str());
}
return 0; }
But if I move my class to a dll and try again,
Everything works just fine until sMyString goes out of scope
#include "myDll/StringRefTest.h"
#include <string>
#include <stdio.h>
using namespace std ;
int main(int argc, char* argv[])
{
{
string sMyString;
sMyString = "";
{
StringRefTest tester;
tester.setString(sMyString);
}
printf (sMyString.c_str());
}
return 0; }
In same executable
LocalStringRefTest.h
#ifndef LocalStringRefTest_CLASS_H
#define LocalStringRefTest_CLASS_H
#include <string>
using namespace std ;
class LocalStringRefTest
{
public:
LocalStringRefTest();
bool setString(string& sString);
protected:
string m_sString;
};
#endif
LocalStringRefTest.cpp
#include "LocalStringRefTest.h"
using namespace std ;
LocalStringRefTest::LocalStringRefTest()
:m_sString("Happy String")
{
}
bool LocalStringRefTest::setString(string& sString)
{
sString = m_sString;
return true;
}
In dll
StringRefTest.h
#ifndef StringRefTest_CLASS_H
#define StringRefTest_CLASS_H
#include <string>
using namespace std ;
class __declspec(dllexport) StringRefTest
{
public:
StringRefTest();
bool setString(string& sString);
protected:
string m_sString;
};
#endif
StringRefTest.cpp
#include "myDll/StringRefTest.h"
using namespace std ;
StringRefTest::StringRefTest()
:m_sString("Happy String")
{
}
bool StringRefTest::setString(string& sString)
{
sString = m_sString;
return true;
}
As i debug through my code, everything works fine until the string goes out of scope
when that happens i get:
NTDLL! 7c96cd80()
NTDLL! 7c960af8()
KERNEL32! 7c85e7af()
_CrtIsValidHeapPointer(const void * 0x00961a00) line 1606
_free_dbg_lk(void * 0x00961a00, int 1) line 1011 + 9 bytes
_free_dbg(void * 0x00961a00, int 1) line 970 + 13 bytes
free(void * 0x00961a00) line 926 + 11 bytes
operator delete(void * 0x00961a00) line 7 + 9 bytes
std::allocator<char>::deallocate(void * 0x00961a00, unsigned int 33) line 64 + 38 bytes
std::basic_string<char,std::char_traits<char>,std::allocator<char>
::_Tidy(unsigned char 1) line 592
std::basic_string<char,std::char_traits<char>,std::allocator<char>
::~basic_string<char,std::char_traits<char>,std::allocator<char> >()
line 59 + 39 bytes
main(int 1, char * * 0x00a70eb0) line 26
mainCRTStartup() line 206 + 25 bytes
KERNEL32! 7c816d4f()
Invalid Address specified to RtlValidateHeap( 00A60000, 009619E0 )
from looking around on the net it seems this is a fairly commonly encountered problem.
I've found a lot of useful information but not a specific answer i was able to use to resolve my problem
i've found the related article on http://support.microsoft.com/kb/168958/
but i just don't understand what i need to do to be able to make it work,
thanks for you help,
mat
|
|
|
|
|
Hello. Im not 100% sure, but I think your problem is StringRefTest.cpp
bool StringRefTest::setString(string& sString){
sString = m_sString;
return true;
}
Shouldn't the assignment be the other way around?
Now, you have a local string and you assign it to sString.
That means that you allocate the string in the dll and frees it in your main program. And that's a no no.
|
|
|
|
|
the assignment is the right way around
perhaps i could have called the method getString to avoid confusion.
|
|
|
|
|
It would have made things clearer...
But still, I suspect the assignment. What does the copy constructor look like?
Maybe you could try to copy just the string data instead of the complete string class in the dll?
But again, I'm not 100% sure about this.
|
|
|
|
|
Do the CRT runtimes (Project Properties->C/C++->Runtime Library) of the exe and dll match?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thank you Senthil,
That sounds like a useful sugestion,
but i can't find the properties you're refering to in vc++ 6.0.
can you please explain how i get to the runtime library property?
-- modified at 4:00 Friday 28th October, 2005
oh i've found it, but the dll uses
'multi-threaded dll'
i can get my code to work by using the same runtime,
but wouldn't that be the wrong runtime to use for my executable?
cheers
mathew
|
|
|
|
|
I would like to know how to make a button which can toggle its button status.
When you press it, it will down and remain unchange until you press it again.
Please help!
Alex
|
|
|
|
|
Isn't there a property in the designer to turn this on ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I would like to know it.
If you know, please tell me.
|
|
|
|
|
I'm wrong, it's radio buttons that have a push style. Maybe there's an article on the site about a push button like that ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Do you have any suggestion?
Please help!
|
|
|
|
|
When I said 'maybe there's an article', I was suggesting that you search for one.
This[^] looks like one example of a class that will do what you want, I think.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
why you dont use the radiobutton with push-like style? i think that would be the easiest way.
P.
|
|
|
|
|
I think that using the radiobutton with push-like style is the easiest way, but how can I use it as I mentioned.
Please help!
|
|
|
|
|
Ok la!
Thank you very much!
|
|
|
|
|
Hi
there is a class where you can change the apperance of any button (normal button, radiobutton, checkbox). This way you can use a check box with the look of a normal button.
http://www.codeproject.com/buttonctrl/cbuttonst.asp[^]
Hope that this helps
codito ergo sum
|
|
|
|
|
I use radiobutton to do it.
Thank you very much!
|
|
|
|
|
Hi,
I have a CFormView derived class which has a thread running at the background which does some background processing. On my view, I have a button which when clicked, the handler function gets called and takes the user to some other screen. When clicked on the button, I cannot wait till my background thread ends and then call the handler. I have to immediately call the handler function without waiting for the thread to end.
What I am doing presently is, just signaling an event to end the thread and call the handler without waitng for he thread to end. if I do this way,my program is crashing with an assertion(it says illegal access of members in the thread). Inside the thread, members of the CFormView derived class are used.
Can anyone please suggest me a solution to call the handler immediately, without waiting for the thread to end and at the same time my program should not crash.
Thanks
Madhavi.
|
|
|
|
|
ledallam wrote: Can anyone please suggest me a solution to call the handler immediately, without waiting for the thread to end and at the same time my program should not crash.
How do you grant access to the CFormViews member variables in the first place and how do you spawn your thread?
When you call the so called "handler", what does it mean?
Is the CFormView object destroyed when you call the "handler"? One solution could be to make sure it's not.
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
We solved a problem similar to this by placing the thread control information into a separate queue. The queue is a singleton at the 'applciaiton' level,a nd not controlled by any of the threads' clients. The thread and the thread's client could access the thread data via the queue. If the 'client' had to leave before the thread was done, then the thread was signaled to exit, but it became a 'zombie' thread and removed itself from the qeue when it could. This way, there was no access violation because the thread's data belonged to a client that might 'disappear' before the thread was done.
|
|
|
|