1
votes

I'm confused about WinRT and .NET.

These namespaces: http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx exist in WinRT but they are not complete (for example System.IO does not exist).

For socket programming there are two namespaces:

1- System.Net.Sockets in .NET library.

2- Windows.Networking.Sockets in WinRT.

Should I use the WinRT APIs in a .NET project? If the answer is 'yes' then why should I use WinRT APIs instead of the .NET APIs?

2
You should only use the WinRT specific classes when you intend to write a Metro program. Which at the least requires you to have the preview edition of Windows 8 so you can test your code. Your program will not run on any earlier version of Windows.Hans Passant
I believe filesystem IO is done using the Windows.Storage namespace (and its descendants.)millimoose

2 Answers

5
votes

If you are writing a normal .NET application (i.e. traditional windows desktop application, ASP.NET web site, WCF service, and so forth) then you will use the standard .NET profiles and WinRT won't be an available option.

If you are writing a Metro style application for Windows 8 then you are restricted to the Metro profile of .NET. This removes a lot of usual namespaces you are used to and replaces them with the WinRT APIs. This is a deliberate choice by Microsoft to improve the security, portability and responsiveness of Metro applications.

2
votes

you need to use WinRT API's if you want to develop apps that run in the Metro environment in Windows 8 (and are therefore potentially available in the windows 8 marketplace). The .NET CLR runs in an 'API restricted' mode on top on WinRT to allow the metro app to be properly sandboxed. File IO is missing because this is not allowed in the metro sandboxed environment.