@functions "This is not a valid location for a breakpoint" in Visual Studio 2013

Working with Visual Studio 2013 and I tried to set a breakpoint in "@fucntions" bout got back an error message that read:

This is not a valid location for a breakpoint.

image

That's funny, because it works in Visual Studio 2012. See:

image

Oh well, as a work around, move the @functions block up to the beginning of the cshtml razor view, and you should be able to once again set breakpoints:

image

Why? Who knows. :/

-Brian

Installing Freelan on Windows Server 2012

So, I was trying out Windows Server 2012. I tried installing freelan (http://www.freelan.org) as a service. If you know me, I'm a big fan of freelan, but for some reason, after every cold boot, there was no connectivity to the node over VPN. Specifically, this problem was only occurring on Windows Server 2012.

Generally speaking, I think it has to do with the freelan acquiring the OpenVPN TAP adapter. Changes in the operating system driver infrastructure in Windows Server 2012 somehow goofs up the freelan application as it tries to initialize itself and the driver.

Turns out, you need to force the TAP adapter to a connection state of "Always Connected". Somehow, when the TAP adapter is set to "Always Connected", Windows then makes the TAP adapter available to the OS networking infrastructure. So when freelan tries to initialize it, it's available for use. Network problem solved.

Here's how to do it. First, open the TAP adapter status, then click Properties.

image

Next, click Configure.

image

Set the Media Status to Always Connected.

This probably has a lot to do with people generally using OpenVPN's TAP adapter on Windows 8 or 8.1 too. Or, maybe freelan is just packaged with an old out-dated OpenVPN TAP adapter.

https://forums.openvpn.net/topic12865.html

https://forums.openvpn.net/topic10013-15.html

Clicking Outlook links open Blank/Empty Page in Chrome

Quick Note

google-chrome-about-crash Under the following conditions:

  • Google Chrome set as the default browser.
  • Microsoft Outlook running in "Windows XP" compatibility mode.

Clicking on links inside emails (or any hyperlink even inside contacts), Google Chrome will open up in a blank "Untitled" tab. UI menus and the ominibox are completely unresponsive.

Turns out, running Microsoft Outlook in "Windows XP" compatibility mode will cause Google Chrome to fail to open links in Outlook.

So, disable "compatibility mode" and all should be well.

image

Hope that helps,
Brian Chavez

Cleaning up Network Connections in Windows 7

image Windows makes a mess of all the network adapters when installing NIC cards. Sometimes, you remove network adapters, and you're left with something like "Local Area Network 3" that can't be renamed back to "Local Area Network". The problem is, Windows remembers the previous adapter (even if it is physically removed), so you can't rename the adapter, otherwise it would conflict with previously named adapters. View & remove all previously (non-connected) NIC adapters:

set DEVMGR_SHOW_NONPRESENT_DEVICES=1
devmgmt.msc

View > Show Hidden Devices

Now, you can remove any adapters that were previously installed (but no longer present) in windows.

After doing so, you should now be able to rename the network adapters back to "Local Area Connection".

Extra Tip 1: Using the "Network and Sharing Center", click on the icon to change the icon and network name.

Extra Tip 2: Start "Local Security Policy". Go to "Network List Manager Polices", and you'll be able to assign profiles to these networks.

Extra Tip 3: Click on an "Unidentified network"s icon, and click "Merge or delete network locations" to delete any previously remembered "networks".

Hope that helps,
Brian Chavez

Setup latest Redis on Ubuntu

image Setting up latest Redis on Ubuntu

  • add-apt-repository ppa:rwky/redis
  • apt-get update
  • apt-get install redis
  • nano /etc/redis/redis.conf
  • service redis-server restart

Extra: Ensure Durable Redis

(make Redis durable on every dataset change)

  • nano /etc/redis/redis.conf
  • Comment out:
    # save 900 1
    # save 300 10
    # save 60 10000
  • Change:
    appendonly yes
    appendfsync always
  • Ensure:
    no-appendfsync-on-rewrite no
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 64mb

Cleanup: delete /var/lib/redis/dump.rdb since we're not using snapshots.

The AOF file is in /var/lib/redis/appendonly.aof; this is your dataset on disk.

Log files are in /var/log/redis/redis.log

Hope that helps,
Brian Chavez

HTTPie doesn't honor --style colors in mintty/cygwin

Be sure to check our $TERM variable.

cowboy@bigcowboy:~$ echo $TERM
xterm-256color

It should have the words "256color" before you can use httpie's --styles.

Specifically, the offending code is in httpie models.py: Line 25

colors = 256 if '256color' in os.environ.get('TERM', '') else 88

image

Hope that helps,
Brian Chavez

Compiling Kernel Modules for Raspberry Pi

image I tried loading rpi-pwm on my Raspberry Pi, but ran into some issues. After some tinkering I was able to compile rpi-pwm.c on the Raspberry Pi, but I kept running into Invalid Format issues anytime I tried to insmod rpi-pwm.ko which had the following dmesg:

rpi_pwm: disagrees about version of symbol module_layout

I guess this generally means I need to compile my module in the same way the kernel is compiled on the Raspberry Pi. Otherwise, the kernel will reject the module.

I've found that cross-compiling works best. This means, building your kernel and modules on a different platform rather than on the Raspberry Pi hardware directly. I did NOT have any luck compiling my kernel module directly on Raspberry Pi hardware.

In detail, first you'll want to cross-compile the Raspberry Pi Linux kernel so it builds Module.symvars and other intermediates. You won't actually use the kernel that is being cross-compiled, just the intermediates to compile your module. Next, you'll cross-compile your module using those intermediates. Once your module is cross-compiled, copy the .ko module to your running Raspberry Pi and you should be able to load it along with the stock kernel. The following is a quick how-to cross-compile the Raspberry Pi Kernel modules on Ubuntu 12.04:

First, know what version of RPi you're running:

uname -r and uname -a

root@raspberrypi:/# uname -r
3.2.27+
root@raspberrypi:/# uname -a
Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux

I've downloaded everything into a directory called ~/rpi on my Ubuntu machine.

1. Compile the Kernel

For 3.2.27+:

(instructions generally flow from: http://elinux.org/RPi_Kernel_Compilation)

  • Install Ubuntu
  • Get the rpi-3.2.27.tar.gz tarball
  • Get the tools tarball
  • tar xzf rpi-3.2.27.tar.gz and tar xzf master.tar.gz (tools)
  • Set the environment variable CCPREFIX:
    export CCPREFIX=
    /home/cowboy/rpi/tools-master/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-
  • Set the environment variable KERNEL_SRC:
    export KERNEL_SRC=/home/cowboy/rpi/linux-rpi-3.2.27
  • In KERNEL_SRC: execute "make mrproper" to ensure you have a clean kernel source tree.
  • Pull /proc/config.gz from your running Raspberry Pi and extract it into KERNEL_SRC on your Ubuntu machine.

    scp pi@rpiaddress:/proc/config.gz ./ (transfers it to Ubuntu)
    zcat config.gz > .config (uncompresses .config)
    mv .config $KERNEL_SRC (moves the uncompressed .config to KERNEL_SRC) 

  • On Ubuntu: Prime kernel with the old config:
    make ARCH=arm CROSS_COMPILE=${CCPREFIX} oldconfig
  • On Ubuntu: Build the kernel:
    make ARCH=arm CROSS_COMPILE=${CCPREFIX}

This will produce a fresh Module.symvers and since you're using the cross-compile tools, the intermediates the tools generate should be binaurally compatible with Raspberry Pi.

2. Compile your kernel module

Next, make a separate directory outside of KERNEL_SRC (or example: ~/pwm) and write a quick Makefile for your kernel module:

obj-m += rpi-pwm.o

all:
    make ARCH=arm CROSS_COMPILE=${CCPREFIX} -C /home/cowboy/rpi/linux-rpi-3.2.27 M=$(PWD) modules

clean:
    make -C /home/cowboy/rpi/linux-rpi-3.2.27 M=$(PWD) clean

(learn more about compiling Linux kernel modules here)

When you're ready to compile your module, go ahead and execute "make" and you should be gold. Copy your rpi-pwm.ko to your RPI then use modinfo rpi-pwm.ko to review the module information:

root@raspberrypi:/# modinfo rpi-pwm.ko
filename:       /home/pi/temp/rpi-pwm.ko
alias:          platform:bcm2708_pwm
author:         Sean Cross <xobs@xoblo.gs> for Adafruit Industries <www.adafruit.com>
license:        GPL
srcversion:     44D62553C321E91B0CB1996
depends:       
vermagic:       3.2.27 preempt mod_unload modversions ARMv6

Last but not least, you should be able to insmod rpi-pwm.ko without any problems. My dmesg:

root@raspberrypi:/# dmesg | tail -5
[18852.504621] rpi_pwm: disagrees about version of symbol module_layout
[19043.461377] rpi_pwm: disagrees about version of symbol module_layout
[21401.160720] rpi_pwm: disagrees about version of symbol module_layout
[22026.927225] rpi_pwm: disagrees about version of symbol module_layout
[26733.475758] Adafruit Industries' Raspberry Pi PWM driver v1.0

If you want your module to auto start:

  • Copy your .ko module to /lib/modules/3.2.27+
  • Edit /etc/modules and append your module to the end of the list.
    Mine looks like:

    # /etc/modules: kernel modules to load at boot time.
    #
    # This file contains the names of kernel modules that should be loaded
    # at boot time, one per line. Lines beginning with "#" are ignored.
    # Parameters can be specified after the module name.

    snd-bcm2835
    spi-bcm2708
    i2c-bcm2708
    i2c-dev
    rpi-pwm

  • Next, run: depmod -a
  • Next, run: modprobe <yourmodulename>

Then reboot and your module should auto start on boot.

Hope that helps!
Brian Chavez

Rip Page Inspector out of your Web Site Projects now

Page Inspector causing multiple calls to HttpApplication : Application_Start in Web Site Projects

image

I had a mysterious problem receiving multiple calls to Application_Start on almost every HTTP request to IISExpress. Upon further investigation, I found Visual Studio 2012's Page Inspector causing the problem.

Inside the default machine's Web.config located at: Windows\Microsoft.NET\Framework\v4.0.30319\Config, XPath: \System.Web\compilation\assemblies has an assembly "Microsoft.VisualStudio.Web.PageInspector.Loader", which dynamically loads itself via [assembly: PreApplicationStartmethod(typeof(RuntimeLoader),"PreApplicationStart"] attribute.

The ASP.NET BuildManager's hash of the compiled web site project kept changing upon the first & subsequent request to IISExpress. Somehow the dynamically loaded PageInsepctor.Runtime caused the HttpApplication to shutdown, startup, in an oscillating fashion (hence, the mulitiple Application_Start calls) as requests were being processed. Specifically, Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.
    SelectionMappingExecutionListenerModule.PreApplicationStart
()'s call to BuildManager.AddCompilationDependency() caused root compilation hash to change.

Disabling and removing Microsoft's Page Inspector feature removed the restarting interference. Here's how to remove the entire feature from your project:

Disable Visual Studio 2012 Page Inspector

To disable visual studio Page Inspector remove the assembly inside your Web.config located in configuration/compilation/assemblies:

Code Snippet
  1. <compilation debug="true" targetFramework="4.5">
  2.   <assemblies>
  3.     <remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader,
                          Version=1.0.0.0, Culture=neutral,
                          PublicKeyToken=b03f5f7f11d50a3a"
    />
  4.   </assemblies>
  5. </compilation>

Alternatively, you can add this to your appSettings:

Code Snippet
  1. <appSettings>
  2.   <add key="PageInspector:ServerCodeMappingSupport" value="Disabled" />
  3. </appSettings>

Hope that helps,
Brian Chavez

Modify Visual Studio 2012 Dark/Light Shell Themes

UPDATE: 9/7/2012 - An "official" theme editor for VS2012 is now available in the VS extension gallery available here:
http://visualstudiogallery.msdn.microsoft.com/366ad100-0003-4c9a-81a8-337d4e7ace05
The remainder of this post is for archival purposes and is out-dated.

imageSo, Visual Studio 2012 is nice but I ran into some serious usability issues. I like the dark theme, but it was too dark. Something between light and dark would have been perfect.

In my current setup:

  • I turn down my monitor's contrast to the lowest setting.
  • I turn down my Nvidia driver contrast down to the lowest setting.

I spend a lot of time on the computer so it is important to  keep these settings where they are. I don't want fiddle with these nobs back and forth just to use Visual Studio.

After some research and play, I found where Visual Studio 2012 was storing and reading theme / color data. Specifically here:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config\Themes

Notice, there's a Data value in each sub-key category. This Data value is binary-byte packed with color values and color names. I wrote a small tool that that reads Data for each category and allows you to inject your own colors.

image

 

Visual Studio 2012 Theme Editor

Play it safe: Please backup your registry before using this. You can backup your current theme by using the green "Backup Theme to File" button.

Visual Studio 2012 Themes


Visual Studio 2012 Icon Patcher



FAQ

  • Can I change the ALL CAPS menu?
    Yes,
       1. Close Visual Studio
       2. Launch regedit and navigate to
         HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\General 
       3. Create a DWORD value named SuppressUppercaseConversion with value 1.
    That should suppress the upper casing on the FILE, EDIT, VIEW menu area in Visual Studio 2012.
  • Can I change the Visual Studio 2012 Icons?
    Yes, See the link above: http://vsip.codeplex.com/
  • I changed a color, it doesn't work. What's wrong?
    Keep trying. There's hundreds of colors VS uses so it might take some time to find the color you're trying to modify. Most of Visual Studio's Shell colors are in the Environment category - take a look in there. Also, keep in mind, Visual Studio uses many colors, and sometimes colors get "brushed over" others.
  • How do I reset my theme?
    Click on the Reset Theme link in the main program to go back to stock colors.
  • There's a bug in your program. Can you fix it?
    Probably. I didn't spend much time creating a bulletproof UI. I just needed something quick to hack these color values. Since it's open-source, feel free to fork, download, fix, and push me a patch.
     

For me, some important colors that I needed to adjust:

  • Environment > CommandBarMenuBorder
  • Environment > CommandBarMenuBackgroundGradient(Start/End)
  • Environment > CommandBarMenuItemMouseOver

 

Hope that helps, happy coding! 
Brian Chavez

22 Comments Filed Under [ Tips & Tricks ]
ASP.NET .refresh DLLs Not Updated (or copied) In WebDeployment .wdproj Projects

success_baby-kidThis is primarily used as notes for me …

As the title suggests, I had a problem with *some* DLL references inside Project.Web\Bin\*.refresh files not being copied during the .wdproj build process.

There were a few blogs out there that offered some solutions like editing the Microsoft.WebDeployment.targets file and removing the Copy “Condition” inside _ResolveReferences target (Line 862). But these solutions bothered me because it did not explain the root cause of the problem.

What was most strange about this problem was that all my builds worked before, so something must have goofed up the build process.

It turns out, your .wdproj file may be out-of-sync with your .SLN file. Double check the following XML elements inside your .wdproj file:

  • <SourceWebPhysicalPath> -- You need to triple check that this path is correct,
  • <SourceWebProject>GUID|ProjectURL/Name</SourceWebProject> -- The GUID in the <SourceWebProject> XML element must match the web-project GUID in your .SLN file. Also, the ProjectURL/Name should also match the string that follows the web-project GUID in your .SLN file too.

It turns out, if you were using Visual Studio’s built-in Cassini web server, then switched to IIS Express at a later date, your .wdproj may contain stale reference information located in the two XML tags listed above. Specifically, the format of the <SourceWebProject> tag using Cassini is “GUID|ProjectPath”, and “GUID|ProjectURL” for IIS Express. When you convert a website from Cassini to IIS Express, the website’s GUID changes and ProjectPath becomes ProjectURL in the .wdproj. The website GUID and ProjectURL values can be found inside the .SLN file after the change has been made.

If you’re unsure of what GUID|ProjectURL values are needed, simply remove the .wdproj deployment project from solution and add it again (overwriting your previous .wdproj), and Visual Studio will recreate the necessary values inside your .wdproj. Just remember to refresh your .wdproj when switching between IIS Express and Cassini.

Additional Tip 1

Double check your .SLN “E24C65DC-7377-472B-9ABA-BC803B73C61A” (Website Projects) sections of your .SLN file and ensure the AspNetCompiler.PhysicalPaths are correct.

Additional Tip 2

Make sure your website project is set to “build” in the Configuration Manager for your Release configuration.

image   image

This is important because, during the build process, MSBuild creates “meta projects” (.metaproj) for your website projects that are derived from your .SLN file. The reasoning is, website projects (which differ from Web Application projects) do not have an accompanying “.csproj” project file (which are essentially MSBuild scripts). Project settings for website projects are stored in the .SLN file and the .SLN file is used to create an intermediate (.metaproj) MSBuild script on-the-fly. You never see the resultant intermediate build script emitted from MSBuild by default.

To see the intermediate build script for your website project:

  • set MSBuildEmitSolution=1
    (via command-line - environment variable)
  • msbuild MyProject.sln /property:Configuration=Release /target:Rebuild
    (run MSBuild on your solution)

If your website project is set to build in Release configuration as shown in the pictures above, you should see a few files similarly named “localhost.metaproj” and “MyProject.sln.metaproj” emitted from MSBuild as it transformed your website project settings into intermediate MSBuild scripts. The “localhost.metaproj” files contain MSBuild tasks that read .refresh files and copy .refresh references into your Project.Web\Bin folder.

Ultimately, this will ensure all .refresh files are honored & copied before your .wdproj deployment build script executes.

Additional Tip 3

Ensure your website project and .wdproj has the correct build order in your solution:

image

Your .wdproj should be somewhat last and definitely after your website project build.

Additional Tip 4

If you want to avoid the extra aspnet_compile from enabling the “build” in tip 2 and you really feel up for modifying your Microsoft.WebDeployment.targets file, simply remove the ! operator from the Copy Condition in:

image

Removing the ! from the Copy Condition will copy the DLL references into your Web\Bin directory and all should be well.

Hope that helps,
Brian Chavez