Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a reference profile and its purpose?

I'm reading about WinRT (Windows Runtime) in C# 5.0 in a Nutshell and I found some fundamental terms in .NET development: reference assembly and reference profile. So, I have a doubt respect to the last term: What is a reference profile and its purpose?

Additionally, I paste the entire paragraph that describes the overlap between .NET Framework libraries and WinRT libraries (I think that this describes the need to create a reference profile):

The WinRT libraries support the new Metro user interface (for writing immersive touch-first applications), mobile device-specific features (sensors, text messaging and so on), and a range of core functionality that overlaps with parts of the .NET Framework. Because of this overlap, Visual Studio includes a reference profile (a set of .NET reference assemblies) for Metro projects that hides the portions of the .NET Framework that overlap with WinRT. This profile also hides large portions of the .NET Framework considered unnecessary for tablet apps (such as accessing a database). Microsoft’s application store, which controls the distribution of software to consumer devices, rejects any program that attempts to access a hidden type.

like image 736
InfZero Avatar asked Nov 03 '22 19:11

InfZero


1 Answers

Like the book says, reference profile is just a collection of reference assemblies. For example, there are separate profiles for WinRT apps and for normal .Net 4.5 applications.

Reference assembly is an assembly that contains definitions of types and their members, but doesn't contain any code. These reference assemblies are used at compile time but at runtime a runtime assembly, which does contain code of methods is used.

For example, the mscorlib reference assembly for WinRT won't contain the Type.GetMethod() method, because doing reflection this way is not allowed under WinRT. But at runtime, both WinRT apps and normal .Net applications will use the same mscorlib runtime assembly, which does contain that method.

The purpose for all this is to have one set of runtime assemblies, while also having different “views” that limit some of the functionality. This is useful when you want to create a limited profile (like WinRT) or when you want to upgrade the runtime assemblies with new functionality, while keeping the ability to target only the old stuff (e.g. you upgrade your runtime assemblies from .Net 4.0 to .Net 4.5, but you still have .Net 4.0 reference assemblies, so you can still work on .Net 4.0 projects without accidentally polluting them with things from .Net 4.5).

like image 129
svick Avatar answered Nov 27 '22 14:11

svick