Posted By: Charles | Mar 22nd, 2007 @ 5:07 PM | 31,350 Views | 16 Comments
If you write managed code and interop with unmanaged, you know the pain involved with marshaling string types across runtimes... If you write MFC apps and want to take advantage of new whiz bang shell UI features (aka common controls) without writing more code that specifically targets Vista, for example, well you can. All of this thanks to Sarita and team!

Sarita Bafna is a Program Manager on the VC++ Libraries team. Her current focus is on MFC support for common controls (including Vista's new set of cool common controls) and the new Marshaling library (it marshals managed types to unmanaged types and vice-versa. Only string types are supported in this release) in VC++ "Orcas".

Tune in and learn about these new VC++ constructs available in "Orcas".
Media Downloads:
Rating:
1
0
Only support for strings?  Uhm, that's like saying "Hey, we have this great marshaling library but it only supports strings".  LOL

That's not really a library but more like a code snippet.  Don't get me all excited about interop then give me something so trivial.  Is something wrong with the code below?

Utils::Utils(void)
{
}

const char* Utils::MarshalString( String ^ s )
{
   using namespace Runtime::InteropServices;
   const char* chars = (const char*)   (Marshal::StringToHGlobalAnsi(s)).ToPointer();
   return chars;
}

tcp::endpoint Utils::MarshalEndPoint( System::Net::IPEndPoint ^endpoint )
{
   return tcp::endpoint(Utils::MarshalAddress(endpoint->Address), endpoint->Port);
}

boost::filesystem::path Utils::MarshalFileInfo(System::String ^fullPath)
{
   return boost::filesystem::path(Utils::MarshalString(fullPath));
}

System::Collections::Generic::List<float>^ Utils::MarshalFloatVector(std::vector<float>& data)
{
   System::Collections::Generic::List<float>^ items = gcnew System::Collections::Generic::List<float>;
   for(int i = 0; i < data.size(); i++)
      items->Add(data[i]);
   return items;
}

I think you're being a bit myopic. Developers should have considerably fewer headaches as a result of all the technologies she talked about. Certainly the updated control library, in particular, will be welcomed.

I thought it was a good interview myself. Additionally, I have to say she has some of the nicest whiteboard handwriting I've seen.

Smiley
Yes yes...  I never said the interview was bad or even that the idea was bad.  I was just pointing out that the library does not exist yet.  Sort of like counting your chickens before they hatch, something we all know can cause quite a bit of shoot-self-in-foot action.

My whole intention was to put my code out there and ask what the difference is between their interop and mine, if any.  I was a bit excited to see that there will be some new marshaling classes but was let down when they said "only strings are supported" since that's probably the most trivial aspect.

I really look forward to having a marshaling library that allows for fast marshaling between my native and managed types, without having to focus on it too much.

Good interview and nice handwriting too.

Thanks!

BryanF wrote:
I think you're being a bit myopic. Developers should have considerably fewer headaches as a result of all the technologies she talked about. Certainly the updated control library, in particular, will be welcomed.

I thought it was a good interview myself. Additionally, I have to say she has some of the nicest whiteboard handwriting I've seen.

Smiley
Nice video.  Great to see 'high quality' graphics finally supported.  Does this include > 16 color toolbars by default?

I haven't installed the CTP, but I'm wondering if the performance of the C++ compiler has improved.  The C++ compiler in VC++2005 is quite slow compared to the VC++6.0 compiler.
stevetei
stevetei
Parallel Computing Platform
gsuing wrote:
I haven't installed the CTP, but I'm wondering if the performance of the C++ compiler has improved.  The C++ compiler in VC++2005 is quite slow compared to the VC++6.0 compiler.


The reduced build throughput between VC6 and VC2005 is primarly a result of vastly increased correctness and standards conformance.  In Orcas, we have increased throughput by supporting compilation of multiple translation units in parallel.  We have also done some work to optimize dependency checking for managed/mixed projects.  We blogged about this recently on the VC++ team blog: http://blogs.msdn.com/vcblog/archive/2007/03/12/multi-processor-builds-in-orcas.aspx.

Kosher wrote:
Only support for strings?  Uhm, that's like saying "Hey, we have this great marshaling library but it only supports strings". 


The primary goal of the first version of this library was to design a marshaling framework that could be easily understood, commonly applied and easily extended by users. The second goal was to provide marshaling support for a small and important set of data types. Based on customer feedback we know that strings are the most commonly marshaled set of data types and hence it is important to at least have support for them in the first version. Also, as the library has an extensible model, it can be easily extended by customers with marshaling conversions not currently supported by the library. With future versions of VC we definitely intend to support more marshaling conversions.

I wonder what you think of the design whereby many data types could be marshaled via a single API, marshal_as<to_type>(from), as opposed to calling a different API for every conversion pair. Is the use of template syntax intuitive and natural for C++ programmers? Your opinions greatly appreciated!

Thanks Sarita

PS: In your sample code in MarshalString (String ^ s ) function you could potentially be leaking memory. The IntPtr returned from StringToHGlobalAnsi must be explicitly released using FreeHGlobal or a memory leak results.

Can we have the sample apps available for download? I'm having some problems creating split buttons and looking inside your demo app should help.

Thank you,
Marius Bancila,
Microsoft MVP VC++
Microsoft Communities