- It implements the new Metro look.
- Has a simple UI programming model for Windows developers (You do not need to learn Win32, what an HDC, WndProc or LPARAM is).
- It exposes the WPF/Silverlight XAML UI model to developers.
- The APIs are all designed to be asynchronous.
- It is a sandboxed API, designed for creating self-contained, AppStore-ready applications. You wont get everything you want to create for example Backup Software or Hard Disk Partitioning software.
- The API definitions is exposed in the ECMA 335 metadata format (the same one that .NET uses, you can find those as ".winmd" files).
Search this Blog:
WinRT(Windows Runtime)
CLR Hosting in Native Applications
- LoadLibrary mscoree
- GetProcAddress for CLRCreateInstance. If you get NULL, fall back to legacy path (CorBindToRuntimeEx)
- Call CLRCreateInstance to get ICLRMetaHost. If you get E_NOTIMPL, fall back to legacy path (same as above)
- Otherwise, bank on the ICLRMetaHost you just got
Microsoft Sync Framework
- Database synchronization providers: Synchronization for ADO.NET-enabled data sources
- File synchronization provider: Synchronization for files and folders
- Web synchronization components: Synchronization for FeedSync feeds such as RSS and ATOM feeds
A change is reported when any of the following properties has changed:
The last modification time on a file.
If hashing is enabled, the value of the hash that was computed for the file.
The file size.
The file or folder name. This check is case-sensitive.
Any of the file attributes that are handled by the provider.
A file move or rename is reported when a file is found that has the same creation time, size, and hash value (when hashing is being used) as a previously known file, but the file has a different name or path. If more than one file is found that meets these criteria, Sync Framework acts as if the original file was deleted and new files were created.
Sync Framework treats a folder move or rename as if the old folder was deleted and the new folder was created. The files in the folder are reported as moves. Therefore, in this case, file data does not usually have to be re-sent.
C# .Net Books
Professional .NET 2.0 Framework by Joe Duffy is very similar to Richters book, so I like it for the same reasons
C# in Depth by Jon Skeet is an excellent treatment of all the stuff that the two others do not cover
Programming C# By Jesse Liberty
C# 4.0 in a Nutshell. Excellent reference
Effective C# - Best Practices
More Effective C# - Best Practices
The C# Programming Language by Anders Hejlsberg
Programming .Net components by Juval Lowy
Pro ASP.NET 2.0 in C# 2005
Fast User Switching(FUS) - Ensure Only One Version of Your Application Is Running
Fast User Switching enables multiple-user sessions to run at the same time.
There are several parts of the operating system that interact with the Fast User Switching feature:
1.Winlogon: This is the logon subsystem of Windows XP. Winlogon includes Winlogon.exe, Msgina.dll, and other components that provide user identification and authentication services to the operating system.
2. Windows user subsystem: This contains support for the desktop programming interfaces that support the creation of multiple desktops and the setting of the currently visible desktop.
3. Security subsystem: This contains the security functionality of Windows, which includes support for access control lists (ACLs) and user security tokens.
4. Windows shell: This is the user interface of Windows. It contains the Start menu, the taskbar, the file and folder management user interface, and Control Panel.
To log on to a computer that has the Fast User Switching feature enabled:
1. When the computer first restarts, it starts at the Welcome screen. At this screen, the user enters the appropriate identification information and, if necessary, enters a password. The Welcome screen is on a desktop known as the Winlogon desktop, which is sometimes referred to as the secure desktop because other programs cannot be run on this desktop.
2. After the user has entered the appropriate identification information, the credentials of the user are authenticated by Winlogon.
3. The token and profile information of the user are returned to Winlogon by the Msgina.dll file.
4. Winlogon checks the list of users that are currently logged on to the computer. If the user is already on the list, Winlogon switches to the existing desktop of the user, and the logon process is complete.
5. If the user is not already logged on to the computer, Winlogon creates a new thread for this user and transfers the information to that thread.
6. The thread of the user creates a new desktop for this user, sets up the user environment, and then starts the user shell on the newly created desktop. The thread and desktop information are added to the list of users that are currently logged on to the computer. Winlogon switches to the new desktop of the user, and the logon process is complete.
To log off from a computer or switch users to a computer that has the Fast User Switching feature enabled:
1. The threads of the user wait for the log off from event that is associated with the thread that is going to be signaled (which occurs when the user logs off from the computer). When the user logs off from the computer, the thread of the user is finished.
2. At any point prior to logging off from the computer, the user can initiate an action (for example, Switch User) that can return the computer to the Welcome screen without signaling to the thread of the user that a log off from event has occurred. When this behavior occurs, the user desktop continues to run and all programs that have been started on that desktop continue to run. The user is unable to observe any of these programs because the desktop is hidden. The desktop is reported to be "switched out", but it is still active.
3. When the computer displays the Welcome screen, any user can be identified and authenticated. If a user already has an active desktop that is switched out, that desktop becomes the active desktop. The state of the program of the user is maintained because none of the programs needed to be shut down when the user had been switched out. If the user does not have a switched-out desktop, a new desktop is created for that user.
The following services use the Fast User Switching feature:
1. Terminal Services: This provides a multiple-session environment that enables multiple users to be logged on to the computer at the same time. If this service is not started, only one user can log on to the computer at a time.
2. Fast User Switching Compatibility Services: Some programs had been designed only to run in a single-user environment. This service provides assistance to many of those programs to enable them to run in a multiple-user environment
Sample Code in .Net(C#) for Ensuring One Version of Your Application Is Running
Using Mutex is the standard way to solve this problem in .NET
I'd be concerned that MyApplicationMutex would go out of scope and get garbage collected. To prevent this, you should store the Mutex in a static field. You don't need to WaitOne on the mutex. The usual way of doing this is to make use of the createdNew output parameter of the Mutex constructor.
Sample Code in C#
static class Program
{
private static Mutex m_Mutex;
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
m_Mutex = new Mutex(true, "Global\\MyApplicationMutex", out createdNew);
if (createdNew)
Application.Run(new Form1());
else
MessageBox.Show("The application is already running.", Application.ProductName,
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
gc.KeepAlive(m_Mutex);
}
}
ref:
Microsoft Windows XP Fast User Switching: Design Guide for Building Business Applications - http://msdn.microsoft.com/en-us/library/ms997634.aspx
How to write an application that supports fast user switching in Windows XP - http://support.microsoft.com/kb/310153
Launch your application in Vista under the local system account without the UAC popup -
http://www.codeproject.com/KB/vista-security/VistaSessions.aspx?display=PrintAll&fid=406624&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=51&select=2022539
Displaying a UI That Works with Fast User Switching -
http://msdn.microsoft.com/en-us/library/ms802203.aspx
How To Use the Fast User Switching Feature in Windows XP - http://support.microsoft.com/kb/279765
Why isn't Fast User Switching enabled on domains -
http://blogs.msdn.com/oldnewthing/archive/2003/11/21/55799.aspx
Microsoft Windows XP Fast User Switching: Design Guide for Building Business Applications -
http://msdn.microsoft.com/en-us/library/ms997634.aspx
User Accounts with Fast User Switching and Remote Desktop -
http://msdn.microsoft.com/en-us/library/bb776783.aspx
Displaying a UI That Works with Fast User Switching - http://msdn.microsoft.com/en-us/library/ms802203.aspx
Get information about the currently logged-on user - Part 1 -
http://www.codeproject.com/KB/IP/LoggedOnUSer.aspx
Get information about the currently logged-on users - Part 2 -
http://www.codeproject.com/KB/IP/LoggedOnUsersPart2.aspx
Memory Leaks in .Net Managed Code
What is a Memory Leak:
A Memory Leak occurs when memory is allocated in a program and is never returned to the operating system, even though the program does not use the memory any longer. The following are the four basic types of memory leaks:
- In a manually managed memory environment: Memory is dynamically allocated and referenced by a pointer. The pointer is erased before the memory is freed. After the pointer is erased, the memory can no longer be accessed and therefore cannot be freed.
- In a dynamically managed memory environment: Memory is disposed of but never collected, because a reference to the object is still active. Because a reference to the object is still active, the garbage collector never collects that memory. This can occur with a reference that is set by the system or the program.
- In a dynamically managed memory environment: The garbage collector can collect and free the memory but never returns it to the operating system. This occurs when the garbage collector cannot move the objects that are still in use to one portion of the memory and free the rest.
- In any memory environment: Poor memory management can result when many large objects are declared and never permitted to leave scope. As a result, memory is used and never freed.
When the amount of memory that a program is using continues to increase during the execution, this is a symptom of a memory leak. (You can watch this count of memory through a performance monitor.) The amount of memory that the program uses can eventually cause the program to run out of resources and to crash.
Common Causes of Memory Leaks in Managed Applications:
- GC Class
- Memory Performance Counters
- Automatic Memory Management
- Interoperating with Unmanaged Code
- Holding references to managed objects
- Failing to release unmanaged resources
- Failing to dispose Drawing objects
ref:
How to identify memory leaks in the common language runtime -
http://support.microsoft.com/kb/318263
Identify And Prevent Memory Leaks In Managed Code -
http://msdn.microsoft.com/en-us/magazine/cc163491.aspx
Three Common Causes of Memory Leaks in Managed Applications -
http://blogs.msdn.com/davidklinems/archive/2005/11/16/493580.aspx
CLR Profiler for the .NET Framework 2.0 download -
.Net Memory Profiler - http://memprofiler.com/
Redgate ANTS Performace Profiler - http://www.red-gate.com/products/ants_performance_profiler/index.htm
How To: Use CLR Profiler(allows developers to see the allocation profile of their managed applications) -
http://msdn.microsoft.com/en-us/library/ms979205.aspx
Tracing memory leaks in .NET applications with ANTS Profiler -
Tracing memory leaks in .NET applications with ANTS Profiler -
http://www.c-sharpcorner.com/Reviews/DisplayReview.aspx?ReviewID=41
Memory Leak Detection in .NET -
http://www.codeproject.com/KB/dotnet/Memory_Leak_Detection.aspx
Detecting .NET application memory leak - http://www.codeproject.com/KB/dotnet/BestPractices5.aspx
.NET Memory Leak: To dispose or not to dispose, that’s the 1 GB question –
Detecting .Net Memory Leaks -
Identifying Memory Leak With Process Explorer And Windbg –
Finding Memory Leaks In Silverlight With WinDbg -
http://davybrion.com/blog/2009/08/finding-memory-leaks-in-silverlight-with-windbg/
Troubleshooting ASP.NET using WinDbg and the SOS extension –
http://support.microsoft.com/kb/892277
Debugging Native Memory Leaks via LeakDiag -
(does its magic by using Detours technology to intercept memory allocators calls) -
ftp://ftp.microsoft.com/PSS/Tools/Developer%20Support%20Tools/LeakDiag/
The Debug Diagnostics 1.1 tool (is designed to help troubleshoot performance issues in any Win32 user-mode process) –

