VisualStudio 14 stopped working after upgrading to Windows 10 build 9860?

Upon upgrading to Windows 10 build 9860, the latest Visual Studio 14 preview starting showing this error on startup:

The ‘Microsoft.VisualStudio.Editor.Implementation.EditorPackage’ package did not load correctly.

image

Things didn’t get any better when you try to do anything in the shiny new IDE.. For example, here’s what happens when creating a new C# Console project:

Object of type ‘System.Collections.Generic.List’1[System.Lazy’1+Boxed[Microsoft.VisualSstudio.Text.IExtensionErrorHandler]]’ cannot be converted to type ‘System.Collections.Generic.List’1[System.Lazy’1[Microsoft.Text.IExtensionErrorHandler]]’.

image

Fortunately, I found that repairing Microsoft Visual Studio Professional 14 CTP in Add/Remove Programs seems to fix the problem.. You will get the following error at the end of the repair procedure, but at least I’m able to use Visual Studio again afterwards:

image

Aiming for Pluralsight.com

I recently put in an application to become a Pluralsight author (www.pluralsight.com). I’m hoping they’ll read this and know that I’m very serious about making this happen. I really believe I’m capable of making really great videos for what is already the world’s best resource for developer training.

So, hello Pluralsight application reviewer person! Let’s be friends! :)

update-package… What just happened?

When you run update-package in the package manager console, it is often difficult to determine which packages were actually updated due to all of the output that update -package creates.

I find the easiest way to figure out what happened during the update process is to copy/paste the results into a text editor and run a few regular expressions over the data to shape it into something that makes sense.  …Continue reading “update-package… What just happened?” [update-package… What just happened?]

MemoryCache – Acceptably unpredictable

If you’re not familiar with System.Runtime.Caching.MemoryCache, chances are that the following code does three things you wouldn’t expect…

Take a look at the call to AddOrGetExisting. Here’s the method signature if it helps..

Doesn’t look too suspicious, does it? If you’ve never seen MemoryCache.AddOrGetExisting, you might have made the following incorrect assumptions:

  1. The first time you call AddOrGetExisting, it should add the value, stringToCache in my example, to the cache and return that same value. In other words you might think that yeResult, in my example, would be “tada!!!”, right? Wrong. It’s null the first time you call it.

    Per the documentation:

    Return Value
    Type: System.Object
    If a cache entry with the same key exists, the existing cache entry; otherwise, null.

    Odd at first, but it’s not hard to get around. I’ll try to post another article soon explaining why this happens.

  2. You might think that the parameters we passed to AddOrGetExisting would cause the cache to expire in 10 seconds, right? Wrong. It’s 20 seconds. At least. Per this valuable answer, the internal TimeSpan that periodically checks the cache is configured for 20 seconds. So you can’t expect to set the timeout for anything less than 20 seconds by default.
  3. And I say “at least” above because, in my experience, even if you set the expiration date 20 seconds from now, it might expire in 20 seconds… or it might be 22.. or 27.. or 30… or who knows! It’s unpredictable. I imagine it’s because MemoryCache is doing fancy things behind the scenes. Maybe one day I’ll look into it further.

For my purposes, MemoryCache.AddOrGetExisting works perfectly fine! I just wish someone had told me these things before I started using it.

Writing code – 5 quick steps for getting in the zone

  1. Forget about the code for a moment.
  2. Find your happy place.
  3. Know that you already have all that you need for happiness in this world.
  4. Seek out the fears that might be preventing you from getting in the zone, and let them go.
  5. Imagine the developer you want to be.
  6. Be that developer.

Works for me. J

Don’t accidentally allow unsafe code

Nasty shortcut makes setting this ridiculously easy.

This seems so dangerous. I can’t believe Microsoft has let it slip through QC for the past couple Visual Studio releases.

As a keyboard junkie, I expect ALT+F,C to close the currently open file. Or if I want to save the current file, ALT+F,S should do the trick. That’s not the case if you’re on the Build tab of a project’s properties screen (Figure 1). Here, ALT+F is going to Allow unsafe code!!!

Figure 1

It’s not too hard to catch on that something isn’t right when you use an ALT+F combination on this screen because, typically, the desired action won’t occur. It still throws me off every time it happens, but I’m keen enough to go back and make sure I uncheck uncheck that nasty little checkbox.

Growl for Windows + Visual Studio 2013

This is the second time I’ve wanted to get Grows for Windows working with Visual Studio 2013.

The Visual Studio plugin hasn’t been updated since since 2010, so it takes just a little bit of effort to get it working

The key, every time I do this, is to find this old post.

You may have noticed hat post talks about fixing the plugin to work in Visual Studio 2012. Of course, making it work in 2013 is about as simple as you can imagine.

  1. Install the current Growl For Visual Studio plug in
  2. Open up %APPDATA%\Microsoft\MSEnvShared\Addins\GrowlExtras.VisualStudioAddIn.AddIn in notepad
  3. In the <Extensibility> node, add the following
    <HostApplication>
      <Name>Microsoft Visual Studio Macros</Name>
      <Version>12.0</Version>
    </HostApplication>
    <HostApplication>
      <Name>Microsoft Visual Studio</Name>
      <Version>12.0</Version>
    </HostApplication>
  4. Save and close the file
  5. Might have to close and restart Visual Studio for it to actually register with Growl.

Time saver – Audible page load notifications

We devs… We write code, save, flip over to the browser, press F5 to refresh the page… and wait. And wait. And probably wait some more.

That’s no way to live. Some sites can take quite a while for the page to load, typically due to background processes that need to get warmed up before the site beings to act smoothly.

Personally, I want to be doing other things while I wait for that page to load. But I don’t want to forget that I was ever waiting for the page to load. I want an audible notification that the page was ready for me to work with. And I want it to be a generic tool I can tweak to work with any website/page I’m working on, without having to modify the actual website.

And so I installed Tampermonkey in Chrome. I guess it’s like Greasemonkey, but I’ve never used that either. :)

Turns out, I was able to get exactly what I want relatively easy.

I don’t even understand how that beep() function works, but it does. Smile The important thing is the @match line at the top that instructs Tampermonkey to run the beep function when that page is finished loading.

Now I can press CTRL+F5 in VisualStudio and switch over to responding to emails until I hear the beep that lets me know the webpage has finished loading.

Advanced nuget command line ninjary

Small post here, but I just wanted to post something. It’s been too long. Smile

I had a need yesterday to reinstall a group of nuget packages and didn’t want to go through 8 pages of packages in VisualStudio, hand picking the ones I wanted to reinstall. Nor did I want to type update-package <package name> –reinstall for every single page, mostly because I couldn’t easily remember the names of all the packages that needed reinstalling.

Also, update-package doesn’t have a way to specify a wildcard, so you can’t do something like update-package *DefinitelyTyped*.

But then I remember that there’s power in PowerShell.  Behold…

get-package | where Id -like “*DefinitelyTyped*” | foreach { update-package $_.Id  -reinstall }

Pretty rad. I had never heard of get-package before I wrote that line. So then I though, can I install every DefinitelyTyped package at once?

And just for fun, what if I wanted to install every DefinitelyTyped package related to Bootstrap?

get-package -ListAvailable | where {($_.Id -like “*DefinitelyTyped*”)-and ($_.Id -like “*bootstrap*”) } | foreach { install-package $_.Id }

Done.

What other clever ways have you combined PowerShell and nuget?

Finding duplicate code in C#, VB.Net, ASPX, Ruby, Python, Java, C, C++, ActionScript, or XAML

Whether you realize it or not, you need a tool that finds duplicate source code in your applications. In fact, if you’ve never used one before, you probably don’t realize how much you need an automated solution to this problem. It’s nearly impossible to manually locate the types of duplicate code that such a tool can easily bring to the surface. Even if you think you’re intimately aware of an application’s code base, every line of code you write contains the potential to awaken the duplicate code dragon.

To combat the problem, we have Atomiq – what I consider to be the best solution for finding duplicate/similar code in C#, VB.Net, ASPX, Ruby, Python, Java, C, C++, ActionScript, and XAML.

…Continue reading “Finding duplicate code in C#, VB.Net, ASPX, Ruby, Python, Java, C, C++, ActionScript, or XAML” [Finding duplicate code in C#, VB.Net, ASPX, Ruby, Python, Java, C, C++, ActionScript, or XAML]