|
(Maybe you chaps know better than the MC++ chaps)
Ok so I have a MC++ Class Library and it is being called from a C# app. All hunky dory, except I cannot get the class library to write to any files when it is called from the C# app.
I wrote the equivalent code in the C# app and the file was created fine and in the right place.
Am I supposed to be doing something extra to tell the system that the class dll can write files?
The crappy thing is that no error is generated, in fact stepping through each line the system seems to think the file was created just fine. But no file appears.
I am using the XMLTextWriter to write the file. e.g. myXmlTextWriter = new XmlTextWriter (S"test.xml", System::Text::Encoding::UTF8);
I have used Flush and Close, no luck.
So what gives? thanks.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Alison Pentland wrote:
I now have an image of you in front of the mirror in the morning, wearing your knickers, socks and shoes trying to decided if they match!
|
|
|
|
|
Paul Watson wrote:
But no file appears.
Try with absolute path name. The file is generated but you are looking at the wrong place.
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
|
|
|
|
|
Rama Krishna wrote:
Try with absolute path name. The file is generated but you are looking at the wrong place
I wish Rama. That was my first thought, so I tried c:\test.xml to no avail. I even checked in the DEBUG folder, then set the project to RELEASE and checked in that folder. Nix, nada, nothing. Even compiled the app and ran it out of the DEBUG environment. Nothing.
I even put in a FUBAR path (e.g. c:\sibling\kill\die!.][\\wicky\test.xml) and it still ran without generating an error. I would think it would throw an exception with a path like that.
Some further info: The app that runs is the c# app. It loads with a Windows Form and in the form_load it creates an instance of the class I coded in C++. It then calls a function in that class which contains the code which is supposed to write an XML file.
If I take that XML code, translate it to c# and put it in the c# app, then the XML file appears.
If I run the C++ class library on it's own and call that function, the XML file appears.
But as soon as I try and call the c++ class lib function from c#, the XML file does not appear. No errors either.
To me it seems as though the c++ class lib is not getting the neccesary rights to write a file. But then it should throw an exception surely?
*sigh* Be glad when this contest is over lol
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Alison Pentland wrote:
I now have an image of you in front of the mirror in the morning, wearing your knickers, socks and shoes trying to decided if they match!
|
|
|
|
|
Maybe you forget an extra \. You should do: C:\\file.txt . Just guessing
Best regards,
Alexandru Savescu
|
|
|
|
|
Alexpro wrote:
Maybe you forget an extra \. You should do: C:\\file.txt. Just guessing
Good idea, but alas, no luck.
Further info: I just moved the code out of the one function and into a function I know was working earlier. Lo and behold it starts returning exceptions. Errors I can deal with, it is when you get nothing that I get frustrated.
Maybe I should try this in normal C++ and leave MC++ alone.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Alison Pentland wrote:
I now have an image of you in front of the mirror in the morning, wearing your knickers, socks and shoes trying to decided if they match!
|
|
|
|
|
Paul Watson wrote:
Maybe I should try this in normal C++ and leave MC++ alone.
Or return back to familiar terrotories.
C++ doesnot work for some people. It looks at the personality first and decides whether it should work for the person or not.;)
If possible mail me the code. This looks very weird problem.
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
|
|
|
|
|
Rama Krishna wrote:
Or return back to familiar terrotories.
C++ does not work for some people. It looks at the personality first and decides whether it should work for the person or not
Wave a read flag in front of my face why don't you!
That is tantamount to a challenge of the highest order. Now not only do I have to win that contest, but I have to do it well enough to impress Rama Programmer Guru Krishna, hehe.
Well I don't fully understand the problem yet, but I have got the code working by not using a bool and rather using a String* . I assume it has some managed types explanation behind it.
You can check it out when I submit my article
Thanks for the help.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Alison Pentland wrote:
I now have an image of you in front of the mirror in the morning, wearing your knickers, socks and shoes trying to decided if they match!
|
|
|
|
|
Is it possible to assign a thread to a single processor in C++ with Visual studio ?
|
|
|
|
|
Check SetThreadAffinityMask. But better be sure what you're doing.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
If you are simply concerned that windows is optimizing your threads processing effectively, you should know that it runs all of your threads on different processors until it has to double up on a processor. So it tries to maximize the through put of the multi-processors parallel processing.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
In MFC, how would you go about getting that PATH of the current executable - AfxGetAppName is not enough.
Help
|
|
|
|
|
__argv[0] should do the trick. It's global variable in MFC.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
__argv[0] will contain incomplete path when you launch the program from command line. Seems that most reliable way of getting the path will be ::GetModuleFileName.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
Cheers. I had a feeling about GetModuleFileName, but thought it would only provide the filename again.
|
|
|
|
|
Giles wrote:
I had a feeling about GetModuleFileName, but thought it would only provide the filename again.
It'll give you complete path, including filename. If you want to have only directory part left, copy the filename into CString, then use CString::ReverseFind and CString::Left.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
GetModuleFileName(0,...)
includeh10
|
|
|
|
|
i need a dockable menu (that is: the menu can be move around and docked at top, left ... of main frame,
Help.....
seven flowers for u ...
includeh10
|
|
|
|
|
Hello everybody!
I tried to outsource some common classes from some existing projects into a shared static WIN32-library. The classes were implemented into a MFC dialog application and make use of MFC templates such as "CMap" and also of MIDL base_types like "hyper"...
The problem is: If I try to compile those classes within a static WIN32-lib workspace, Visual Studio mourns about that "hyper", "CMap", etc. are unknown (Error C2501). Although I've set the option that I want to use MFC in this library.
I think that I have to link some more headers or set some switches in the properties of the static lib workspace... But I found no suitable hints at the MSDN library at all!
So... Maybe someone can give me a tip how to implement "hyper", "CMap" & Co. into a static WIN32-library...??? *pls*
Many thanks in advance!
With best regards,
Andreas Dilling
|
|
|
|
|
Hello,
when i exit my application, i get this message from the debugger:
Warning: calling DestroyWindow in CDialog::~CDialog --
OnDestroy or PostNcDestroy in derived class will not be called.
What is the meaning of this Warning?
Thanks for your Help!
|
|
|
|
|
This means that you're having problems with lifetime of your dialog. Is your dialog main window of your app?
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
That msg occurs when you have a class instance that is being
destroyed before its window. The class destructor will
automatically destroy the window for you, but since this is
done from the destructor, the instance is no longer around
to handle any messages. This is sometimes the behavior you
want, just make sure that your destructor AND OnDestroy both
call a cleanup routine in common.
|
|
|
|
|
Hello Thomas and Scott,
Thank you very much for your help!
I have found the error:
I have a view, he create via new dialogs. When i exit the dialogs, in my OnDestroy-function of the view, i delete the dialog.
Now i delete the dialogs in the destructor of my view.
|
|
|
|
|
I've just started to read about this. seems like custom controls can have relected messages. so a regular old button added from the toolbox is not able to do reflection?
Thanks,
ns
|
|
|
|
|
anonymous wrote:
so a regular old button added from the toolbox is not able to do reflection?
All controls can use reflection.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
The article I was reading was adding handlers for messages starting with = via the classwizard. One selects the class of the control and then handles the = message. Since I added my button through CW I dont have a control class for it in my CW. Thats why I incorrectly deduced that standard controls couldnt refelect.
Thanks,
ns
|
|
|
|