Debugging Lamda Expressions with Visual Studio 2015

Ladies and gentlemen, we have finally reached the holy grail of debugging!

I don’t know whose idea it was not not mention this during today’s Connect(); event, but here’s one new feature of Visual Studio 2015 that, personally, I feel should have made the keynote. …Continue reading “Debugging Lamda Expressions with Visual Studio 2015” [Debugging Lamda Expressions with Visual Studio 2015]

Vim, for the first time, also in Visual Studio

What is this… Vim…? I’m only just now getting to know you… How did I avoid you for so long? How did you not make yourself known to me previously? And when you finally did make yourself known, via the git command line, why did you not tell me you were more than just a pain in the ass?

Why is your logo so ugly? 

A month ago, I found myself being forced into learning the basics of Vim. It’s the default editor when you install git, and it’s frustrating as snot if you go at it with any sort of “this is how it’s done in Windows” expectation.

A month later, I’m more productive than ever in Visual Studio 2013 thanks to VsVim, a “Vim emulation layer for Visual Studio 2010 and above”.

Even when my fingers are fumbling over the keyboard, incorrectly guessing the key combination for some complex vim task, I still feel more efficient than I used to be.

And, more than anything, my hands hurt less.

 

Connect KendoUI to MVC Web API without ODataController

This is in response to a recent post by Steve Smith (Connect KendoUI AutoComplete to MVC Action).

In his post, Steve stated that using Web API to connect a KendoUI AutoComplete with OData “can present a challenge”.

Yes, ODataControllers definitely present a challenge.. and, I admit.. the first time I tried to get KendoUI to talk to MVC without using an ODataController, I kinda wanted to pull all of my hair out.

But now that I’ve done it a couple dozen times, it’s not so bad.

I’ll walk you through the process now…  …Continue reading “Connect KendoUI to MVC Web API without ODataController” [Connect KendoUI to MVC Web API without ODataController]

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…

https://gist.github.com/alexdresko/bd08881515a0a7a5ad0f

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

https://gist.github.com/alexdresko/774785378673cfa00643

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.