Thursday 30 July 2015

Other net commands

Apart from oft-used net use, there are also other great commands like:

net accounts
net computer
net config
net continue
net group (Only available on a Windows domain controller)

net use

Type net use at the command line and you get a list of network connections.

Suppose you want to delete a mapping for the K: drive. Simply do:

net use K: /delete

Then you can map again to another directory/resource on the same machine.


Developing understanding of the runtime element of the app.config (and why it is useful)

Utlizing the Runtime Settings Schema in your app.config is (primarily) about customizing run-time execution of your program to facilitate optimal performance.

Introduction to the runtime element and implementation in .NET 1.1

The runtime element of the app.config file appears as a sub-element of the configuration element. It defines how the .Net runtime should behave when running your application. The exciting thing is you can change the runtime behaviour of your application, insofar as it relates to the .Net runtime, by customising the runtime element of your app.config file, without recompiling your application.

The Runtime Settings Schema was first introduced in .Net 1.1 with the feature of being able to enable or disable garbage collection on a separate thread (gcConcurrent enabled="true"). The setting in app.config overrides the corresponding setting in the machine.config. A simple use case for this feature would be a GUI application with significant user interaction, which you wouldn't want interrupted by gc pauses. Therefore, you would set gcConcurrent to true.

The runtime element also supported from an early stage, assembly binding redirection, henceforth referred to as ABR. This was (and still is) done via the assemblyBinding child element of runtime.

To explain ABR (and how it relates to strong-named assemblies) -

Assume you have built your .Net application against a specific version of a strong-named .Net assembly. Note: you cannot redirect versions of assemblies that are not strong-named.

The application will surely use that assembly at runtime!

Suppose you want to refer to a newer version of this assembly. Yes you can via the app.config runtime->assemblyBinding element. In addition to app.config, machine.config or publisher policy file are also valid ways of implementing ABR for your application.

With gcConcurrent and assemblyBinding elements fully described, we conclude our discussion on .NET 1.1 features implemented in the runtime element of the Configuration File Schema.

.NET 2.0 Features of the runtime element (Recognition of Multicore)

With .Net 2.0 the gcServer element came into being. This specifies whether the Common language runtime runs server garbage collection. This makes sense when you have more than two CPUs.

.NET 4.0 UseSmallInternalThreadStacks

This is a request to the CLR to reduce memory usage by using explicit stack sizes (instead of the default stack size it uses internally).

Saturday 25 July 2015

app.config Quiz -BASIC LEVEL - What is the TOP-LEVEL element of an app.config file for a .NET application?

This is a test for the .NET app.config aficionado.

The ROOT element in EVERY configuration file used by the .NET runtime i.e. EVERY app.config,  is <configuration>. After the OPENING XML ELEMENT, the next most likely thing you'll see is  <configuration>.  And at the end, the most likely thing you'll see is </configuration>.