Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

.NET 4.5: David Kean and Mircea Trofin - Portable Libraries

Download

Right click “Save as…”

The Portable Class Library project enables you to write and build managed assemblies that work on more than one .NET Framework platform. You can create classes that contain code you wish to share across many projects, such as shared business logic, and then reference those classes from different types of projects.

Using the Portable Class Library project, you can build portable assemblies that work without modification on the .NET Framework, Silverlight, Windows Phone 7, or Xbox 360 platforms. Without the Portable Class Library project, you must target a single platform and then manually rework the class library for other platforms. The Portable Class Library project supports a subset of assemblies from these platforms, and provides a Visual Studio template that makes it possible to build assemblies that run without modification on these platforms. [Source = MSDN]

The portable libraries project ships as part of Visual Studio 11 Developer Preview. You can build portable .NET class libraries by simply creating a Portable Class Library project (template provided for you) and choosing the platform targets. The IDE will then create the appropriate reference assemblies for you and you can then program as you normally would. 

Here, we meet Portable Libraries project developer David Kean and program manager Mircea Trofin to learn more. Whiteboarding included.

Tags:

Follow the Discussion

  • felix9felix9 the cat that walked by itself

    the 'spring cleanup' for .NET framework, sounds good. Smiley

  • JedrekJedrek

    "Portable Libraries" looks like a great idea.

    As far as I know one of the reasons why open source is so popular is the lack of binary compatibility on the on the Unix/Linux platform. I am not a big fun of open source but source code allow recompilation of each specific platform which allow high portability of the program.

    Maybe it is possible to provide the source code together with the application (like in "src.rpm" files)
    but in order to protect intellectual property it is possible to encrypt the source.

    In this case it should be possible to recompile the application
    when it is necessary and no source code is shared.
    In this model it should be possible to write the program which work on any platform (at least in theory) in the native code or .net or whatever.

    Probably somebody already did it...
    it would be nice to have such oportunity. One program runs everywhere ...

  • CKurtCKurt while( ( !​succeed=try​() ) ) { }

    Great project! I'm hoping one can just switch a DLL he created to be a Portable one (somewhere in project settings) and try to recompile it, and have good compiler warnings why it does not work and what you can do to change it.

    The introduction says "multiple . NET platforms" and here I tought .NET was a single platform. It's a shame you had to do this as an aftertought (instead of starting from that) and i think the question "Why did SilverLight go the other way?" like Charles asked is still a great one. It's a shame mscorlib is not the same everywhere and there is more then one network stack in the .NET Framework!

    I would love to see the .NET 4.5 poster with the collections of profiles on them (SL , Phone, Metro) and see the overlap/intersections. Also see how the Client Profile and the Portable 'Profile' overlap.

  • Fantastic news.  This has been a major issue for the development team to which I belong, so we are very much looking forward to this.

    It sounds like this supports full "server" .NET, the client profile, the metro profile, Silverlight, phone, and XBox.  There's at least one other .NET-based platform that doesn't seem to have received much love recently (but got a really quick mention in this video): .NET Compact.  The company I work for has TONS (as in many, many thousands) of rugged mobile devices that run Windows Mobile 5 and more recently, Windows Embedded Handheld 6.5.  These devices have to last for many, many years (upwards of 7).  But the .NET version is still stuck at 3.5, and the development tools still stuck at VS2008.

    Given that Windows Mobile is still supported and sold on new devices today, and that Windows Embedded Handheld still seems to be a current, supported platform, I would hope there are plans in place to bring .NET Compact to a current level (v4.0 or even v4.5), to support rugged device development in Visual Studio 11, and to add support for .NET Compact to the Portable Library Tools.  We would love to share code between our ASP.NET apps, Silverlight apps, and .NET Compact apps but we can't due to lack of support in VS2010, and the lack of support in Portable Library Tools.

    But still -- overall great news and great progress in the right direction!

  • Hi guys, nice work! @compupc1: in fact I exactly worked 5 yrs ago with WinCE based industrial handheld barcode terminals and during my rewrite/redo of old C app for MS-DOS based models (requirement to have EXACTLY the same UX even on new WinCE ones for NO workers reeducation!) I quickly realized that new terminals has not emulator support for custom devices as barcode, beeper, various keyboard layouts, wifi-control etc.. so I wanted to debug application in desktop environment, even if compiled against NETCF. And it worked! Using common subset of UI controls (perfectly fine with keyboard only navigation, effectivelly disabling touchscreen, exactly as on old terminals, loosing support from manufacturer soon) it was possible to design UI in grid 240x240 and rescale controls recursivelly duriing app startup to final configured 320x320, with some issues, of course (real reason for wpf/sl is impossibility to zoom native checkbox Smiley). Even desktop UI designer worked well with some #IFDEFS, quite fine in fact, there was just one Form and all screens was managed Panels powered by extensible FSM engine triggered by keyboard, barcode and timer, for better performance not using any reflection-based databinding etc.

    But real "portable executable" thing was done this way, with desktop attachable debuger to NETCF compiled thing running on desktop. To be even more usefull, I built some little "compile time microkernel" with base PInvoke layer against kernel32 and coredll (power management status, touch disable, wifi driver on/off, etc) after platform detection and late assemblyloading of managed "driver wrappers" against desktop emulated barcode reader (even with little UI popups) and target device SDK managed libraries (bound to terminal native drivers, but abstracetd on my level). On top of that, there was "shared services" assemblies, compiled as always for NETCF, but working well also on desktop (for example NETCF modified very nice event driven Genesis UDP P2P library from codeproject) and of course SQLCE support (on desktop targeting its desktop verison, but in first revisions of this beast, I even used full mssqlserver, everything abstracted). Final managed NETCF exe launched either on desktop or terminal detected the platform and lately referenced/classloaded/used appropriate drivers and services, exposed as common api for final industrial application, which in fact replaced explorer.exe in HKLM/Init even indirectly through ns.exe script based "bootloader" for full locked kiosk-mode, auto-reinstall and storage optimizations after coldboots etc... It was fun to work with this, it allowed to work even if real dev handhelds was borrowed by business dept for shows and customers meetings, allowed independecy on single handhelds manufacturer (even never portedd to different brand, Symbol/Motorola ís great!!) ...It simply was my little child Smiley and it bound me to love for .NET. Forever Smiley. It was 2005-7 and unfortunatelly, I was wery much expecting mobile Silverlight native Xaml UI extensions to be here faster and its big fault of MS to not focus primarily on this NETCF and lately its subset CoreCLR/SL quickly. Hope all you are going well for future with WP7, Win8 and all new great stuff!!

  • felix9felix9 the cat that walked by itself

    funny they said 'everything but the xaml are the same', can we have the same xaml too ?

  • shaggygishaggygi

    Good video. Could you provide any details on how Portable Class Library will work with Mono? I thought one of the goals for this project was to work with other projects like MonoTouch and Mono for Andriod? Thanks again.

  • Jedrek: While the Portable Library encourages binary compatibility because it makes deployment and testing easier, nothing stops you from shipping a portable library in source form like existing open source libraries. All we're about, is making it easier for the developer to target a given set of APIs that are known to run on their targeted platforms (if other/newer platforms happen to support those APIs, even better).

    CKurt: Currently the compiler warnings you'd like are errors around missing members & types. :)Thanks for the great suggestion though, I'll take it back to the team.

    petr: Thanks for watching. Sounds like you've had a bit of experience around this sort of thing in the past. Download the bits and tell what you think.

    compupc1: There are no current plans to support .NET Compact Framework with the Portable Library.

    felix9: My team doesn't actually work on the XAML technologies, I'd recommend asking your question around XAML compatibility over on the Metro apps forums over at: http://social.msdn.microsoft.com/Forums/en-us/category/windowsapps.

    Shaggygi: Plans with Mono changed a little when Novell was acquired earlier this year. We're still talking around this, however, I don't know of any firm dates around when this would be fully supported.

  • Aaron StainbackAceHack AceHack

    So with the splitting of the type class will there be reflection performance gains?  Cci is pretty fast.

  • AceHack: For the current split there are no perf gains or changes to the way assemblies are loaded. However, this split sets us up to improve this in the future (for example, you could imagine that we could replace the under pinnings of Reflection with something like CCI).

  • MichalpMichalp

    The Portable Class Library is a VB/C# project. How about managed C++? Or F#?

  • Regarding F#, see Don Syme's talk at //build/ for an idea of what's to come.  

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.