Author Topic: Mixed/Managed C++ dll's, passing objects.  (Read 14564 times)

0 Members and 1 Guest are viewing this topic.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Mixed/Managed C++ dll's, passing objects.
« Reply #45 on: January 14, 2010, 10:23:28 PM »
woot! Thanks Dan.

Just having trouble with the database now, I'm passing in a Database^, this is what I have -

#define GetDb(database) (reinterpret_cast<AcDbDatabase*>(&(database)))

but no worky

this mixed/managed stuff has sooo many subtle tricks to watch out for, I'm almost there though!
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8661
  • AKA Daniel
Re: Mixed/Managed C++ dll's, passing objects.
« Reply #46 on: January 14, 2010, 10:32:21 PM »
The casting only works for managed value types. for ref types you need to do something like   


Code: [Select]
AcDbDatabase *pnDb =  pmDb->UnmanagedObject.ToPointer();

//and

Database ^pmDb = dynamic_cast<Database^>(DisposableWrapper::Create(Database::typeid,(IntPtr)pnDb,false));

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Mixed/Managed C++ dll's, passing objects.
« Reply #47 on: January 14, 2010, 10:40:38 PM »
hmm, I think I'm getting the db ok but as I'm creating a new one in C# I think it's open for write and I'm trying to add abjects to it in native code, I'll dig a bit deeper and let you know, thankis again :)
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8661
  • AKA Daniel
Re: Mixed/Managed C++ dll's, passing objects.
« Reply #48 on: January 14, 2010, 10:51:16 PM »
Cool! May your pointers all point to the same instance  :lol:

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Mixed/Managed C++ dll's, passing objects.
« Reply #49 on: January 14, 2010, 10:57:10 PM »
woot!

Thanks Daniel, working fine now with a small adjustment, cheers.

pDb = (AcDbDatabase*)dbout->UnmanagedObject.ToPointer();
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien