Enable or disable FxCop Code Analysis solution wide in Visual Studio Package Manager Console

I really like FxCop. But in a debugging session it can be useful to save time by temporarily disabling the code analysis. Sadly there is no *global switch* to turn it off and on again. So here is my approach: Create a new text file in the directory "C:\Users\{your user}\Documents\WindowsPowerShell" named "NuGet_profile.ps1" and add the following code: Restart Visual Studio. Click the menu "View" | "Other Windows" | "Package Manager Console". Now you can execute the following commands: > Enable-CodeAnalysis > Disable-CodeAnalysis

New Notebook–HP ZBook G2 15 Review

After 4 years it really was time to get a new notebook. Back in the days at newtelligence we had Alienware stuff. Pretty impressive until Dell bought them and keeps them small (in CPU/RAM/...).  So again (this is the 5th) I decided to go for HP: ZBook 15 G2 Some Specs: Intel Core i7-4910MQ 256 GB HP Z Turbo Drive PCIe SSD 15.6" diagonal LED-backlit FHD SVA eDP anti-glare (1920 x 1080) NVIDIA® Quadro® K1100M (2 GB dedicated GDDR5) 4 x USB 3 1 x Thunderbolt 1 x VGA, 1 x Displayport LTE SmartCard reader 2.78 kg WTF: Hewlett-Packard Company is an American multinational information technology corporation headquartered in Palo Alto, California, United States. They are not able to ship me a UK-Layout keyboard! Solution: Go to ebay and search for “HP zbook 15 keyboard backlit US”. There are offers from China that ship within 3 weeks. QWERTY! WTF: Where did the context menu key go? Power users use *the keys* not a mouse! Solution: Download KeyTweak and remap the right ctrl or windows key. WTF: Why can’t I mount a ridiculous amount of monitors to the normal docking station (not advanced!)? Solution: Disable the Hybrid Graphics feature in the BIOS and it’s all fine. Finally I added 2 1TB Samsung evo 840 SSDs to increase the storage amount.

.NET Licensing - ode to monolithic applications?

The Microsoft .NET Framework has a built in licensing technology. It can be found in the namespace System.ComponentModel and System.ComponentModel.Design. Here is a small sample implementation of the minimal required classes: A lot of component producers use this licensing model – so does Tx Text Control – the component that I wanted to use. As a user you just create a *.licx-file, include it into the project as “embedded resource” and add the components that should be licensed by their fully qualified type names – one per line: During the build the LC-Task executes the license compiler (LC.exe). The license compiler is part of the .NET SDK that is part of the Windows SDK. If you have the Windows SDK 8.1 or Visual Studio 2013 installed it can be found at “C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\”. The result is the “Licensing.dll.licenses” file that is embedded by the C#-Compiler (Csc.exe) in the next step. During runtime the LicenseProvider-attribute is evaluated and the defined license provider is handed over to the System.ComponentModel.LicenseManager’s Validate method. This call forwards to the internal method ValidateInternalRecursive which then calls the GetLicense method of the LicenseProvider. The first argument of the GetLicenseCall is of type LicenseContext and at runtime filled with the static held instance of the internal class RuntimeLicenseContext. To resolve the license key the method GetSavedLicenseKey is called on the LicenseContext. The implemention offers two options to resolve the key: Resolve from URI: new Uri(new Uri(AppDomain.CurrentDomain.SetupInformation.ApplicationBase), AppDomain.CurrentDomain.SetupInformation.LicenseFile) Resolve from Embedded Resource: The lookup on references/loaded assemblies is only processed, if there is NO entry assembly - for instance within ASP.NET that is the case. But my intend was to create a build task for MsBuild that converts Microsoft Word’s DOCX files into PDF documents. So I have an entry assembly (MsBuild.exe). The entry assembly knows nothing about TX TextControl – and that is a good thing! I have no control over the entry assembly (MsBuild.exe). A situation I guess to find in every composite UI/modular desktop application. No wonder the monolith is often the preferred architecture especially on the desktop! After an intense debugging session through the framework sources (supported by red gate’s Reflector) I wrote a small helper class. WARNING: I use reflection to access internal types and private fields and modify their values – this means: If Microsoft decides to change their internal implementation it might not work anymore. But as we as can see the code was written for .NET 1.0 and has not been updated in the last 10 years: It’s not very likely that changes will happen. Now I just need to call LicenseLoader.LoadLicensesFromCallingAssembly() before the Tx Text Control component is instantiated the first time and everything works as expected. HTH

Batch processing Visual Studio ProjectItems with the Nuget Package Management Powershell Console

Today I helped a customer to minify and bundle a bunch of JavaScript files. We used WebGrease triggered from MsBuild to do the job. The next thing to do is changing the BuildAction property on all non-bundled-and-minified JavaScript files so that only minified and bundled files are published. Here is my script: Hope that helps