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

Managed C++/CLI

 
QuestionProject Converted From VS2003 to VS2008, get exception when call dialog.doModal Pin
Andraw Tang5-Aug-11 11:16
Andraw Tang5-Aug-11 11:16 
AnswerRe: Project Converted From VS2003 to VS2008, get exception when call dialog.doModal Pin
Richard MacCutchan5-Aug-11 22:32
mveRichard MacCutchan5-Aug-11 22:32 
GeneralRe: Project Converted From VS2003 to VS2008, get exception when call dialog.doModal Pin
Andraw Tang8-Aug-11 4:37
Andraw Tang8-Aug-11 4:37 
GeneralRe: Project Converted From VS2003 to VS2008, get exception when call dialog.doModal Pin
Richard MacCutchan8-Aug-11 7:02
mveRichard MacCutchan8-Aug-11 7:02 
GeneralRe: Project Converted From VS2003 to VS2008, get exception when call dialog.doModal Pin
Andraw Tang8-Aug-11 7:18
Andraw Tang8-Aug-11 7:18 
GeneralRe: Project Converted From VS2003 to VS2008, get exception when call dialog.doModal Pin
Richard MacCutchan8-Aug-11 7:38
mveRichard MacCutchan8-Aug-11 7:38 
AnswerRe: Project Converted From VS2003 to VS2008, get exception when call dialog.doModal Pin
Arun Parthasarathy22-Aug-11 1:27
Arun Parthasarathy22-Aug-11 1:27 
Questionpin_ptr on value struct is needed? Pin
Dusan Paulovic3-Aug-11 6:51
Dusan Paulovic3-Aug-11 6:51 
Hi all, I am working on class to wrapp unmanaged pointer. I am just confused, whether pinning of value struct is needed in C++/CLI, i.e. whether if I will not do it, it can cause some problems.

In C#, I am not able to fix structs:
C#
Point pntA = new Point(10, 25);
Point pntB = new Point();

unsafe
{
  // Error	4	
  // You cannot use the fixed statement to take 
  // the address of an already fixed expression	
  fixed (Point* ptrA = &pntA, ptrB = &pntB)
  {
    ptrB->X = ptrA->X;
    ptrB->Y = ptrA->Y;
  }
}


but, I can simply use address-of operator:
C#
Point pntA = new Point(10, 25);
Point pntB = new Point();

unsafe
{
  // Correct
  Point* ptrA = &pntA, ptrB = &pntB;
  ptrB->X = ptrA->X;
  ptrB->Y = ptrA->Y;
}


What is confusing me is that pin_ptr lets me pin structures as well as use address-of operator:

C++
// /clr
generic <typename T> where T : value struct
T GetValueA(void* ptr)
{
  T val = Activator::CreateInstance<T>();

  pin_ptr<T> valPtr = &val;
  memcpy(valPtr, ptr, sizeof(T));
  return val;
}

generic <typename T> where T : value struct
T GetValueB(void* ptr)
{
  T val = Activator::CreateInstance<T>();

  memcpy(&val, ptr, sizeof(T));
  return val;
}


My questions are:

Is pinning needed in C++/CLI functions to fix value struct
before using its pointer in unmanaged function?

Are value structs allocated in the unmanaged heap?

Thanks all,
Dusan
QuestionHow to disable a Checkbox created using MFCRibbonCheckBox? Pin
MeghaJoshi1-Aug-11 18:20
MeghaJoshi1-Aug-11 18:20 
QuestionTCP packet sniffer Pin
itaybo24-Jul-11 19:26
itaybo24-Jul-11 19:26 
AnswerRe: TCP packet sniffer Pin
Richard MacCutchan24-Jul-11 21:15
mveRichard MacCutchan24-Jul-11 21:15 
AnswerRe: TCP packet sniffer Pin
Albert Holguin25-Jul-11 4:26
professionalAlbert Holguin25-Jul-11 4:26 
RantRe: TCP packet sniffer Pin
Richard MacCutchan25-Jul-11 5:59
mveRichard MacCutchan25-Jul-11 5:59 
GeneralRe: TCP packet sniffer Pin
Albert Holguin25-Jul-11 6:26
professionalAlbert Holguin25-Jul-11 6:26 
RantRe: TCP packet sniffer Pin
Richard MacCutchan25-Jul-11 6:31
mveRichard MacCutchan25-Jul-11 6:31 
GeneralRe: TCP packet sniffer Pin
Albert Holguin25-Jul-11 6:33
professionalAlbert Holguin25-Jul-11 6:33 
Questioncliext relative to pair and managed types [modified] Pin
SomewhereEverywhere20-Jul-11 15:19
SomewhereEverywhere20-Jul-11 15:19 
AnswerRe: cliext relative to pair and managed types Pin
John Schroedl21-Jul-11 4:25
professionalJohn Schroedl21-Jul-11 4:25 
GeneralHow to generate wsdl in CLR console application? Pin
aupres8-Jul-11 21:17
aupres8-Jul-11 21:17 
QuestionRe: How to generate wsdl in CLR console application? Pin
Mark Salsbery9-Jul-11 6:33
Mark Salsbery9-Jul-11 6:33 
Questionhow to use crystal report in c++/clr ? Pin
Mahdi.mpst7-Jul-11 0:24
Mahdi.mpst7-Jul-11 0:24 
AnswerRe: how to use crystal report in c++/clr ? Pin
thatraja9-Jul-11 18:40
professionalthatraja9-Jul-11 18:40 
QuestionTypical issues in managed c++ Pin
sukumarvg4-Jul-11 2:03
sukumarvg4-Jul-11 2:03 
AnswerRe: Typical issues in managed c++ Pin
ian__lindsay4-Jul-11 5:45
ian__lindsay4-Jul-11 5:45 
GeneralRe: Typical issues in managed c++ Pin
sukumarvg6-Jul-11 22:29
sukumarvg6-Jul-11 22:29 

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.