Clear Silverlight Cache


Overview

I recently had an issue where a Silverlight application was acting up on me. It was an application that I was using, not one I’d developed and I really didn’t have much experience with Silverlight at that point. It was working for other people and other browsers on my computer were experiencing the same problem. I’d already cleared the Internet cache multiple times including cookies and other stuff. I applied all the latest patches, hot fixes and service packs as well as updated my browsers to the latest versions. I finally came to the point where I updated Silverlight thinking it could be related to Silverlight itself. None of this solved the problem.

Finally another developer alerted me to the possibility of clearing the Silverlight cache. Now don’t laugh, but I didn’t know that Silverlight had its own cache. I looked online for quite a while on how to clear the Silverlight cache but came up empty. So, I went looking myself. Here’s how you do it.

Clear Silverlight Cache

  1. Open the Microsoft Silverlight shortcut in your start menu.
    • Depending on what version and how you manage your Start Menu, this could be in various places.
    • You could also just click Run or browse to ”C:\Program Files\Microsoft Silverlight\{VERSION}\Silverlight.Configuration.exe” where {VERSION} equals the version you have installed. For me, as of writing this article, it was 5.1.20125.0.
  2. You will see the Microsoft Silverlight Configuration application come up.
    • Microsoft Silverlight Configuration

      Microsoft Silverlight Configuration

  3. Click on the Application Storage tab and you will see tab contents like this.
    • Silverlight Application Storage

      Microsoft Silverlight Configuration – Application Storage

  4. Click on a web site you want to clear from cache and click the Delete button, or click the Delete all button to clear all web site data from cache.
  5. Click OK

Summary

Congratulations! You’ve just cleared the Microsoft Silverlight cache on your system. If you have any questions or comments please leave a comment below. Have a great day!

Quick-Tip: How to Kill .NET Worker Process


This is a quick-tip on how to kill the .NET worker process. Often when I’m developing web applications I’ll run into an issue where I’ve made a change but it’s not being reflected when I’m running or debugging the software. I’ll clear the browser cache and even restart my debugging session, but still the previous version persists. This can be an issue where the web server or caching mechanism are caching the results. There are numerous other issues that can be resolved by a restart of the .NET worker process.

I’ve found that the quickest way to get around this and other issues related to the .NET worker process, is to simply stop debugging, kill the process and then start debugging again. This causes it to reload the app domain, load fresh data into cache, etc. Here’s how you can do it.

Kill the .NET Worker Process

  1. Open a command prompt via whatever means your version of Windows requires.
    1. Click on Start -> Run -> Type “CMD” -> Click OK.
    2. Click on Start -> Type “CMD” in Textbox -> Press Enter.
    3. Etc.
  2. At the command prompt type “taskkill /IM w3wp.exe /F”.
  3. Press Enter.

Here is what’s happening in the taskkill program.

  • taskkill – This launches the taskkill application which allows you to terminate tasks by process id (PID) or image name.
  • /IM – This tells taskkill to search for a process by image name instead of process id (PID).
  • w3wp.exe – This is the image name we want to terminate. It’s the WWW Worker Process or .NET Worker Process.
  • /F – This tells taskkill to force terminate the process since it may be in use, stalled or otherwise unable to terminate on request.

I simply put this entire command in a shortcut which I keep in my handy list of developer tools folder in my favorites (yes you can keep program shortcuts in your favorites). Then I show my “Links” folder on my task bar by right-clicking my task bar (bottom bar in Windows), selecting Toolbars and then ensuring Links is selected. This causes all of my favorites to be in a small folder that opens upwards when I click on it, making all of my most used programs, web sites, folders, etc. within easy reach.

I hope this helps!

Launch WCF Client from Visual Studio on Debug


Overview

Recently I created a new web project, added some WCF web services to it and tried to debug them. To my suprise the WCF client application (WcfTestClient.exe) didn’t launch when I clicked Debug in Visual Studio. I went through all of the project options, looked online and couldn’t come up with anything. So, I started digging through project files. Here’s what I came up with.

Enable WCF Client on Debug

  1. Open Windows Explorer (Win+E).
  2. Navigate to your project’s folder (where the .csproj/.vbproj file is).
  3. Open the ProjectName.csproj file in your favorite editor.
  4. Navigate to the following XML location.
    1. /Project/ProjectExtensions/VisualStudio/FlavorProperties/WebProjectProperties
  5. Insert a blank line just above the closing </WebProjectProperties>
  6. Paste the following in the blank line.
    1. <EnableWcfTestClientForSVCDefaultValue>True</EnableWcfTestClientForSVCDefaultValue>
  7. Save the project file and exit.
  8. Reload the project. Visual Studio will probably notify you that the project file has been modified.
  9. Ensure the WCF project is set as the Startup Project
    1. Right-click the project and select Set As Startup Project.
  10. Ensure the service you want to debug is set as the Start Page.
    1. Right-click the service file (.svc) the select Set As Start Page.
  11. Click Debug.

Summary

This should cause the WCF Client to run when the project is debugged. Happy Testing!

SQL Checks Outer Table First


Overview

I recently ran into a subtle issue with one of my SQL scripts. Unfortunately this issue caused it to delete all of the data in all of the tables it touched. Fortunately for me, we were still in DEV with the script so the impact was minimal. I spent quite a bit of time debugging the script and tracking down theories just to end up right where I started. Since this was a very simple script, I was feeling really dumb right about then. Here’s the issue and what I found was the problem. Hopefully you can learn the lesson I did without the pain involved.

The Project

Due to circumstances I won’t bore you with, I found myself in a situation where I had to identify some data that fell within a certain range of dates and delete all records in all tables that related to the identified records. I wrote the script, but found that instead of deleting only the records that fell within the date range specified, it deleted all records in the tables it touched. Not fun.

The Script

In the script I created a table variable (I don’t like temp tables) that would contain only one column. This column would contain the primary key of the main table to which most of the other tables related. Into the temp table I inserted all of the primary key values from the records in the main table that met a number of criteria. Then I used a DELETE statement to remove records from each related table where the record’s foreign key referenced a value that was in the table variable.

DECLARE @tv TABLE (
PKVal INT NOT NULL
)
INSERT @tv (
PKVal
)
SELECT PK_Val
FROM   MainTable
WHERE  CriteriaAreMet = 1
DELETE RelatedTable1
WHERE  FKVal
IN     (SELECT  PK_Val
FROM    @tv)

DELETE RelatedTable2
WHERE  FKVal
IN     (SELECT PK_Val
FROM @tv)

The Problem

It turns out that the real problem was a simple typeographical error. In the DELETE statements, within the WHERE-IN statement’s sub-SELECT statement, I added an underscore (“_”) between “PK” and “Val”. The implications of this issue though were far reaching. Initial thoughts about this incorrectly named column might be that SQL Server Management Studio should notify you about the mistake, or at worst the sub-select statement wouldn’t return any data and therefore the DELETE statement wouldn’t delete anything.

These would be incorrect assumptions though. The problem is that the RelatedTableN contains a column called “PK_Val” with the underscore. Due to ANSI standards, SQL always checks the outer table BEFORE it checks the inner table. In this case it found a column called “PK_Val” in the outer table. Since the inner table contains at least 1 record, a match was found for every record and the result was that it deleted every record in each of the tables it touched.

Summary

The learning lesson for me in this case was several fold.

  1. First, it was good to know that outer tables are checked before inner tables. As with anything, knowing exactly how every part of something works helps you be much more proficient working with it. Take for example a car. If you know how everything in the engine works, you can generally deduce what is going on a lot easier from the symptoms you’re seeing.
  2. Second, I use table aliases religiously. However, this particular time I failed to do so and it bit me. If I had been more specific about telling the database engine exactly where I wanted it to look for that column, I wouldn’t have run into this issue. It’s a good reminder… always use aliases where multiple tables are involved. If nothing else, being more clear is always better than more vague.
  3. Always start with the simplest things and work your way to the more complex. A good example I always used as a systems administrator or network administrator is the OSI model. It’s a 7 layer model going from the physical layer (simplest) to the application layer (most complex). Don’t start uninstalling software, reconfiguring the system, etc. when you can’t communicate… check the network cable first. Then ensure the hardware is working (loopback & connectivity tests) and so on. This helps you systematically eliminate things that build the foundation for those above it and can often save you a lot of time. Of course this doesn’t mean to start checking cables when you have a virus or similarly unhelpful steps. Instead it’s a good rule-of-thumb. If in doubt start with the simple and work your way up.

Right-Click Open to File/Folder Command Prompt


Disclaimer: As with any registry action, please make sure you perform a full registry backup first! You are entirely responsible for modifying your registry and by using this registry mod, you agree to hold me, WordPress, affiliates and everyone else completely harmless of anything and everything that happens! In general, you should not download .reg files. If you do, thoroughly review every line (notepad) before running it! As with any site, I encourage you to read each line of this registry mod before running it!

Open Folder in CMDI often find myself browsing some file or folder location in Windows Explorer and find that I need to run something from the command-line (e.g. batch file, command-line utility, etc.). However, the command prompt opens to the current user’s profile folder (e.g. C:\Users\%userprofile%) by default. This is generally far from where I need to be. So I end up having to change directories all the way to the path I was browsing, hoping I remember the entire path.

To make things easier I made a little registry mod that adds an “Open Folder in CMD” option to the right-click menu for folders, files and the desktop. After running the mod, all you have to do is right-click any folder, file or the desktop and select “Open Folder in CMD”. It will then open the command prompt directly to the folder you just right-clicked on! It saves a ton of time and hassle trying to get back into the same folder. Here is what it looks like from the Desktop (at left).

You can use this mod anywhere Windows Explorer exists. Some examples are inside of a File Open or Close Dialog, from auto-search results in the Run box, etc. Below is an example of running it from within Windows Explorer itself. If you click a file, it opens the folder containing that file.

To install this registry modification, simply do the following.

Open Folder in CMD

Open folder in CMD from Folder

  1. Download the file from here.
  2. Open Notepad.
  3. Click File -> Open.
  4. Browse to where you stored the file and click Open.
  5. Review the contents to be sure you’re comfortable with it.
  6. Close Notepad.
  7. Rename the end of the file from .xlsx (Excel) to .reg (Registry Import/Export).
    1. This is required because most modern browsers, antivirus, etc. will not allow download of registry files. So, we had to trick it. If it still won’t download, please leave a comment and I might just have to post the text in this post so you can copy & paste it into your own .reg file.
  8. Double-click the .reg file.

That’s it! You’re all done. It takes effect immediately, without you having to restart Windows. I’ve tried this on Windows 7 and it works great. It should work on others as well, but not sure how far back it’ll work (2000, XP, etc.). If you find out, please let me know in the comments section!

I hope this helps save you time, as it does for me!

Transparent Text Background in Visio


Overview

Have you ever noticed in Visio how the text of your line connectors have white (not transparent) backgrounds by default? This means it “cuts” your line in half. Sometimes the background is good, such as when you have dark text on a dark background. What I want though is to enter text, a blank line and more text then have the line continue between them. Of course that’s not how it works though. It ends up just looking like this.

Here is what I want it to look like.

Here’s how to do it!

  1. Select one or more items you wish to create a transparent text background for.
  2. Right-click the item then select Format and then Text…
  3. In the Text dialog box that appears, select the Text Block tab.
  4. Under the heading Text background on this tag, select the None radio button.
  5. Click OK.

And now you should have a transparent background for the text on those items. Enjoy!