Click here to Skip to main content
15,886,689 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Assembly Version Pin
jashimu2-Mar-11 3:29
jashimu2-Mar-11 3:29 
GeneralRe: Assembly Version Pin
Richard MacCutchan2-Mar-11 4:00
mveRichard MacCutchan2-Mar-11 4:00 
QuestionGet OS Name [modified] Pin
pix_programmer2-Mar-11 2:03
pix_programmer2-Mar-11 2:03 
AnswerRe: Get OS Name Pin
Richard MacCutchan2-Mar-11 3:18
mveRichard MacCutchan2-Mar-11 3:18 
GeneralRe: Get OS Name Pin
pix_programmer2-Mar-11 20:22
pix_programmer2-Mar-11 20:22 
GeneralRe: Get OS Name Pin
Richard MacCutchan2-Mar-11 22:49
mveRichard MacCutchan2-Mar-11 22:49 
Questiongcnew and delete Pin
John Robert Wilk27-Feb-11 6:10
John Robert Wilk27-Feb-11 6:10 
AnswerRe: gcnew and delete Pin
N a v a n e e t h27-Feb-11 6:32
N a v a n e e t h27-Feb-11 6:32 
John Robert Wilk wrote:
My question is can memory allocated with gcnew be deallocated before the garbage collector deallocates it using the delete operator
No. delete on a managed object won't remove the instance from CLI heap. All it does is call the destructor of the object. GC will reclaim the memory later.

You can cleanup the resources that you have used, like connection object or any other native handles deterministically. But the object will be deallocated only by garbage collector. On a garbage collected environment, you don't have to worry about cleaning up the memory allocated. All you have to ensure is no strong references exists to the object that will prevent GC from collecting.

For cleaning the resources, C++/CLI provides methods like "Stack semantics". In which the compiler implements IDisposable on the type and create code to call Dispose() method when the scope ends. You can write your cleanup code inside the Dispose() method. This is the recommended way of cleaning up managed objects. For native objects, you have to call delete on them.

John Robert Wilk wrote:
The problem is that the database connection is made in the constructor of the database class
Usual pattern for database access is, opening connection, executing query and closing the connection. ADO.NET has connection pooling built in and connection instances are created from there. Unless you have a good reason for initializing the connection on the constructor, the pattern explained should be followed.

Smile | :)
Best wishes,
Navaneeth

GeneralRe: gcnew and delete Pin
John Robert Wilk27-Feb-11 6:48
John Robert Wilk27-Feb-11 6:48 
QuestionEquivqlent of MSXML.XMLHTTPRequest Pin
T.RATHA KRISHNAN25-Feb-11 0:18
T.RATHA KRISHNAN25-Feb-11 0:18 
AnswerRe: Equivqlent of MSXML.XMLHTTPRequest Pin
N a v a n e e t h27-Feb-11 6:35
N a v a n e e t h27-Feb-11 6:35 
GeneralRe: Equivqlent of MSXML.XMLHTTPRequest Pin
T.RATHA KRISHNAN28-Feb-11 0:26
T.RATHA KRISHNAN28-Feb-11 0:26 
QuestionConfusing between Native and Managed !?? Pin
anti.AS23-Feb-11 1:28
anti.AS23-Feb-11 1:28 
AnswerRe: Confusing between Native and Managed !?? Pin
N a v a n e e t h23-Feb-11 17:45
N a v a n e e t h23-Feb-11 17:45 
GeneralRe: Confusing between Native and Managed !?? Pin
anti.AS24-Feb-11 7:10
anti.AS24-Feb-11 7:10 
QuestionReading an XML file Pin
T.RATHA KRISHNAN20-Feb-11 22:29
T.RATHA KRISHNAN20-Feb-11 22:29 
AnswerRe: Reading an XML file Pin
John Schroedl21-Feb-11 4:31
professionalJohn Schroedl21-Feb-11 4:31 
QuestionIs there a better way to do this? Pin
John Schroedl18-Feb-11 10:34
professionalJohn Schroedl18-Feb-11 10:34 
AnswerRe: Is there a better way to do this? Pin
Philippe Mori10-Mar-11 15:08
Philippe Mori10-Mar-11 15:08 
GeneralRe: Is there a better way to do this? Pin
John Schroedl10-Mar-11 15:20
professionalJohn Schroedl10-Mar-11 15:20 
QuestionNetwork Communication Pin
pix_programmer17-Feb-11 18:50
pix_programmer17-Feb-11 18:50 
AnswerCross-post warning Pin
Peter_in_278017-Feb-11 19:48
professionalPeter_in_278017-Feb-11 19:48 
QuestionHow to perform the debugging operation in visual studio 6.0 in Windows 7 64-bit environment. Pin
lucky_122116-Feb-11 22:26
lucky_122116-Feb-11 22:26 
Questionstatic_cast vs cli::safe_cast Pin
pix_programmer16-Feb-11 20:18
pix_programmer16-Feb-11 20:18 
AnswerRe: static_cast vs cli::safe_cast Pin
ian__lindsay16-Feb-11 22:02
ian__lindsay16-Feb-11 22:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.