473,320 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Work only inside debuger?!

get this string when I press CTRL-F5 to run:

ØB-

I get this string when I press F5 to run:

Mobile Intel(R) Celeron(R) CPU 1.50GHz
I started with a 100% C++ unmanaged program and
I wanted to display the processor name, and so I gave the .net framework a try.

So I injected this code in one of the .cpp file (nothing more, nothing less)

#using <system.dll>
#using <System.Management.dll>

using namespace System;
using namespace System::Management;

void Function() {

......

ManagementObjectSearcher* query1 = new ManagementObjectSearcher("SELECT * FROM Win32_processor") ;
ManagementObjectCollection* queryCollection1 = query1->Get();
ManagementObjectCollection::ManagementObjectEnumer ator* queryEnum1 = queryCollection1->GetEnumerator();
queryEnum1->MoveNext();
ManagementBaseObject* object = queryEnum1->get_Current();
Object* cpuName = object->GetPropertyValue(L"Name");

.....

// Emit html with processor name
html.td(AtlHtmlAttrs("%s", cpuName->ToString()));

}

Stephan

Nov 16 '05 #1
7 1214
Hello Stephan,

Thanks for your post. I did some test on my side, and now I'd like to share
the following information with you:

I reviewed your code and built a sample console application, it works
properly on my side with and without VS .NET 2003 debugger.

To narrow down the problem, please tell me what version of VS .NET you are
using, 2002 or 2003. I recommend you create a new console program to check
whether other project will also reproduce the problem on your side.

It the problem only occurs to a specific project, could you please post the
project and I will be glad to check it.

I look forward to hearing from you.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #2
Thanks for looking into it.

I cannot post the project, but will try to inject that code in some already existing MS Win32 SDK sample
and see if it behave the same.

To recap the problem: I have a win32 (100% unmanaged C++ project, with inline assembly and all) and
want to use some of the new API in it. I'm at the stage where it compile (after allot of project setting massage)
and link (with warning... for example I lost my "edit and continue" :(( ) and run fine when the debugger is invoked.

Stephan

"Tian Min Huang" <ti******@online.microsoft.com> wrote in message news:O8**************@cpmsftngxa06.phx.gbl...
Hello Stephan,

Thanks for your post. I did some test on my side, and now I'd like to share
the following information with you:

I reviewed your code and built a sample console application, it works
properly on my side with and without VS .NET 2003 debugger.

To narrow down the problem, please tell me what version of VS .NET you are
using, 2002 or 2003. I recommend you create a new console program to check
whether other project will also reproduce the problem on your side.

It the problem only occurs to a specific project, could you please post the
project and I will be glad to check it.

I look forward to hearing from you.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #3
AtlHtmlAttrs seems to be expecting unmanaged strings of some sort, and
you're giving it a managed string. They certainly aren't guaranteed to be
the same thing (although for some odd reason, as you've found out, in debug
mode they are interchangeable).

You'll need to use something like this (*NOTE* untested!):

inline CString ToStr( System::String *strParam )
{
using System::Runtime::InteropServices::Marshal;
System::IntPtr ptr = Marshal::StringToHGlobalAnsi( strParam );
CString str = static_cast<LPCTSTR>( const_cast<void*>(static_cast<const
void*>( ptr ) ) );
Marshal::FreeHGlobal( ptr );
return str;
}

.....

html.td(AtlHtmlAttrs("%s", ToStr(cpuName->ToString())));
Hope that helps,

Stu

"Stephan Schaem" <ss*****@seriousmagic.com> wrote in message
news:e7****************@TK2MSFTNGP10.phx.gbl...
get this string when I press CTRL-F5 to run:

ØB-

I get this string when I press F5 to run:

Mobile Intel(R) Celeron(R) CPU 1.50GHz
I started with a 100% C++ unmanaged program and
I wanted to display the processor name, and so I gave the .net framework a
try.

So I injected this code in one of the .cpp file (nothing more, nothing less)

#using <system.dll>
#using <System.Management.dll>

using namespace System;
using namespace System::Management;

void Function() {

......

ManagementObjectSearcher* query1 = new ManagementObjectSearcher("SELECT *
FROM Win32_processor") ;
ManagementObjectCollection* queryCollection1 = query1->Get();
ManagementObjectCollection::ManagementObjectEnumer ator* queryEnum1 =
queryCollection1->GetEnumerator();
queryEnum1->MoveNext();
ManagementBaseObject* object = queryEnum1->get_Current();
Object* cpuName = object->GetPropertyValue(L"Name");

.....

// Emit html with processor name
html.td(AtlHtmlAttrs("%s", cpuName->ToString()));

}

Stephan
Nov 16 '05 #4
Hi Stephan.

Can you send me a standalone repro? (.exe). Also, please indicate which version of the CLR this is.

--
David Notario
Software Design Engineer - CLR JIT Compiler
http://xplsv.com/blogs/devdiary/

"Stephan Schaem" <ss*****@seriousmagic.com> wrote in message news:e7****************@TK2MSFTNGP10.phx.gbl...
get this string when I press CTRL-F5 to run:

ØB-

I get this string when I press F5 to run:

Mobile Intel(R) Celeron(R) CPU 1.50GHz
I started with a 100% C++ unmanaged program and
I wanted to display the processor name, and so I gave the .net framework a try.

So I injected this code in one of the .cpp file (nothing more, nothing less)

#using <system.dll>
#using <System.Management.dll>

using namespace System;
using namespace System::Management;

void Function() {

.....

ManagementObjectSearcher* query1 = new ManagementObjectSearcher("SELECT * FROM Win32_processor") ;
ManagementObjectCollection* queryCollection1 = query1->Get();
ManagementObjectCollection::ManagementObjectEnumer ator* queryEnum1 = queryCollection1->GetEnumerator();
queryEnum1->MoveNext();
ManagementBaseObject* object = queryEnum1->get_Current();
Object* cpuName = object->GetPropertyValue(L"Name");

....

// Emit html with processor name
html.td(AtlHtmlAttrs("%s", cpuName->ToString()));

}

Stephan

Nov 16 '05 #5
Just to make sure, you might want to verify the different compiler options
between the release build and the debug build..
Of course, you might want to check errors in every step .. :)
--
Girish Bharadwaj
"David Notario" <dn******@online.microsoft.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Hi Stephan.

Can you send me a standalone repro? (.exe). Also, please indicate which
version of the CLR this is.

--
David Notario
Software Design Engineer - CLR JIT Compiler
http://xplsv.com/blogs/devdiary/

"Stephan Schaem" <ss*****@seriousmagic.com> wrote in message
news:e7****************@TK2MSFTNGP10.phx.gbl...
get this string when I press CTRL-F5 to run:

ØB-

I get this string when I press F5 to run:

Mobile Intel(R) Celeron(R) CPU 1.50GHz
I started with a 100% C++ unmanaged program and
I wanted to display the processor name, and so I gave the .net framework a
try.

So I injected this code in one of the .cpp file (nothing more, nothing less)

#using <system.dll>
#using <System.Management.dll>

using namespace System;
using namespace System::Management;

void Function() {

......

ManagementObjectSearcher* query1 = new ManagementObjectSearcher("SELECT *
FROM Win32_processor") ;
ManagementObjectCollection* queryCollection1 = query1->Get();
ManagementObjectCollection::ManagementObjectEnumer ator* queryEnum1 =
queryCollection1->GetEnumerator();
queryEnum1->MoveNext();
ManagementBaseObject* object = queryEnum1->get_Current();
Object* cpuName = object->GetPropertyValue(L"Name");

.....

// Emit html with processor name
html.td(AtlHtmlAttrs("%s", cpuName->ToString()));

}

Stephan
Nov 16 '05 #6
I never tested the release build... The binary code executed is the same,
the diference betwen both result is if the visual studio debugger is running
or not.

Stephan

"Girish Bharadwaj" <girishb.at.mvps.dot.org> wrote in message
news:uo****************@TK2MSFTNGP12.phx.gbl...
Just to make sure, you might want to verify the different compiler options
between the release build and the debug build..
Of course, you might want to check errors in every step .. :)
--
Girish Bharadwaj
"David Notario" <dn******@online.microsoft.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Hi Stephan.

Can you send me a standalone repro? (.exe). Also, please indicate which
version of the CLR this is.

--
David Notario
Software Design Engineer - CLR JIT Compiler
http://xplsv.com/blogs/devdiary/

"Stephan Schaem" <ss*****@seriousmagic.com> wrote in message
news:e7****************@TK2MSFTNGP10.phx.gbl...
get this string when I press CTRL-F5 to run:

ØB-

I get this string when I press F5 to run:

Mobile Intel(R) Celeron(R) CPU 1.50GHz
I started with a 100% C++ unmanaged program and
I wanted to display the processor name, and so I gave the .net framework a
try.

So I injected this code in one of the .cpp file (nothing more, nothing less)
#using <system.dll>
#using <System.Management.dll>

using namespace System;
using namespace System::Management;

void Function() {

.....

ManagementObjectSearcher* query1 = new ManagementObjectSearcher("SELECT *
FROM Win32_processor") ;
ManagementObjectCollection* queryCollection1 = query1->Get();
ManagementObjectCollection::ManagementObjectEnumer ator* queryEnum1 =
queryCollection1->GetEnumerator();
queryEnum1->MoveNext();
ManagementBaseObject* object = queryEnum1->get_Current();
Object* cpuName = object->GetPropertyValue(L"Name");

....

// Emit html with processor name
html.td(AtlHtmlAttrs("%s", cpuName->ToString()));

}

Stephan

Nov 16 '05 #7
Thank you! this work.

I would like to rant that this is completly insane...

And I would like to see MS post their reasoning behind creating this
complete mess!

This type of complexity to access a string is simply unaceptable.

MS team : Stop making managed only API , you are killing the simplicity,
efficiency, cleaness of
the C++ language !

Stephan

"Stu Smith" <st*****@remove.digita.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
AtlHtmlAttrs seems to be expecting unmanaged strings of some sort, and
you're giving it a managed string. They certainly aren't guaranteed to be
the same thing (although for some odd reason, as you've found out, in debug mode they are interchangeable).

You'll need to use something like this (*NOTE* untested!):

inline CString ToStr( System::String *strParam )
{
using System::Runtime::InteropServices::Marshal;
System::IntPtr ptr = Marshal::StringToHGlobalAnsi( strParam );
CString str = static_cast<LPCTSTR>( const_cast<void*>(static_cast<const
void*>( ptr ) ) );
Marshal::FreeHGlobal( ptr );
return str;
}

....

html.td(AtlHtmlAttrs("%s", ToStr(cpuName->ToString())));
Hope that helps,

Stu

"Stephan Schaem" <ss*****@seriousmagic.com> wrote in message
news:e7****************@TK2MSFTNGP10.phx.gbl...
get this string when I press CTRL-F5 to run:

ØB-

I get this string when I press F5 to run:

Mobile Intel(R) Celeron(R) CPU 1.50GHz
I started with a 100% C++ unmanaged program and
I wanted to display the processor name, and so I gave the .net framework a
try.

So I injected this code in one of the .cpp file (nothing more, nothing less)
#using <system.dll>
#using <System.Management.dll>

using namespace System;
using namespace System::Management;

void Function() {

.....

ManagementObjectSearcher* query1 = new ManagementObjectSearcher("SELECT *
FROM Win32_processor") ;
ManagementObjectCollection* queryCollection1 = query1->Get();
ManagementObjectCollection::ManagementObjectEnumer ator* queryEnum1 =
queryCollection1->GetEnumerator();
queryEnum1->MoveNext();
ManagementBaseObject* object = queryEnum1->get_Current();
Object* cpuName = object->GetPropertyValue(L"Name");

....

// Emit html with processor name
html.td(AtlHtmlAttrs("%s", cpuName->ToString()));

}

Stephan

Nov 16 '05 #8

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

Similar topics

15
by: Bob | last post by:
I've tried everything; and I can't seem to get past this VERY (seemingly) simply problem. I want to work with an array variable within a function(s). I can't get it to work; if I: 1) global...
5
by: Anders Dalvander | last post by:
os.popen does not work with parameters inside quotes, nor do os.popen. At least on Windows. import os cmd = '"c:\\command.exe" "parameter inside quotes"' os.popen4(cmd) Results in the...
3
by: Paul Thompson | last post by:
When I put a <div ...> inside a <table> specification, functionality is not there. When I put the <table> inside the <div> everything works. Why is that?
0
by: Tod Johnson | last post by:
Hello, does anybody know how to integrate Debuger funktionality into the WinForms Application. I'm using CodeDomProvider to generate scripts on the fly and want to add possobility to debug this...
1
by: s | last post by:
Hi All .. thank you for entering teh subject.. I am tring to write some C# code ... and I am facing few problems ... usually i sove them by usign the debuger which is: Ctrl + F10 but in...
1
by: feng | last post by:
Hi, I am trying to debug my asp.net project in VS.Net. What I am getting is a error message that says "Error when trying to run project: Unable to start debugger on the web server. you do not...
5
by: nagrik | last post by:
Hello group, Last week I picked up a thread, which pointed out that if a copy constructor is created with pointers instead of reference, there is a danger of it going in infinite recursion. ...
9
by: =?Utf-8?B?Sm9obiBCYWlsZXk=?= | last post by:
I have a ASP .Net page that allows moving around items on the page through javascript. This page works fine in IE. In FireFox however, I have found that if the page is using XHTML 1.0...
1
by: Marcel Nihon | last post by:
Hello, I develop an application in Access 2003. The whole of the modules and modules of class contains approximately 9700 lines of code VBA / ADO. In the editor Visual BASIC, the "Debug -...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.