Using the NuGet Package Explorer to Create, Explore and Publish Packages

Nuget

Although there is often some debate regarding its pronunciation, I believe that most of us can agree that NuGet is pretty great.

In the past few years, NuGet has become one of the easily and most commonly used tools within a .NET Developers bag of tricks and rightfully so. Long gone are the days of searching for a DLL file in some shady site and hoping that it doesn’t brick your application. Now you can find just about every possible reference you would want to include within your application in just a few clicks (and letting it sort out all of the dependencies).

Most developers have likely interacted through NuGet within Visual Studio, however this post is going to introduce another way to interact, explore and even publish your own NuGet packages called the NuGet Package Explorer.

What is the NuGet Package Explorer?

The NuGet Package Explorer is a open-source product of NuGet developer Luan Nguyen and was developed as an extremely user-friendly GUI application for easily creating and exploring NuGet packages. After installing the ClickOnce application, you can simply double-click on a NuGet Package file (.nupkg) to access all of its content or you can load packages directly from the official NuGet feed.

How to use it?

First, you’ll need to visit the NuGet Package Explorer page on CodePlex, where the tool is currently available and download it. After a short download, you can launch the ClickOnce application and be presented with the following screen :

JustLaunched

These are your primary options when it comes to creating or exploring the contents of any available NuGet packages (in addition to simply clicking on any NuGet Package files as mentioned earlier). The easiest approach to get started would probably be to open up a package from the feed, which will present you with a searchable dialog with all of the most popular NuGet packages :

PopularPackages

After clicking on a package, you can choose the particular version you wanted to explore :

allversions

You also have the option of manually opening up any packages that you might have locally installed, but simply grabbing them from the feed is usually going to be the way to go.

Exploring a Package

Once you select a package that you want to explore a bit more, you can just double-click on it to present the details about that package :

An example of exploring the EntityFramework NuGet Package.

An example of exploring the EntityFramework NuGet Package.

While exploring a package, you’ll see many of the summaries, details and descriptions that you might be accustomed to seeing when managing your NuGet packages through Visual Studio along with a bit more.

You’ll see an area called Package Contents, which display all of the files that are contained within the package and it can help give you an idea of the different versions of the framework that it targets, any transformations that will be applied to configuration files and any additional utilities or executables that might be run when the package is installed :

PackageContents

This is where you can really actually explore the packages by digging into the contents a bit more. By simply double-clicking on a file within the contents, you will be shown a preview (if available) of the contents :

ContentsDetails

This can be done for just about any kind of file that would normally support previews and it can be extremely useful if you wanted to see exactly what is going down inside some of these packages.

Creating a NuGet Package

The Package Explorer isn’t limited to just exploring existing packages. It provides a very easy-to-use interface to allow you to create your own packages and upload them to NuGet to share with others.

With a simple click of the File > New option menu or by using the CTRL+N shortcut :

started

You’ll be transported to a new package screen to begin building your own NuGet Package. You can click the Edit Metadata icon ( EditMetadata) to began actually editing information about your package :

MetaData

You can find a complete reference of all of the available fields listed above and exactly what they are used for by visiting the Nuspec Reference page here.

After defining all of your metadata, supported assemblies and dependencies, you will then be ready to add your files and content to your packages. You can do this by just clicking a file within the File Explorer and dragging it into the Package Contents area on the left :

SampleFile

All of the DLL files that are entered will be placed into the lib directory and all other basic content will be placed into an aptly named content directory as seen below :

PackageContent

Additionally, if you need to add other folders (or any other “special” types of folders), you can do so by using the Content menu :

OtherContent

 

You can continue to add all of the additional files and folders for your package in this same manner until your package is complete.

Publishing to NuGet

Publishing to NuGet is fairly simple after you have build your package.

The first thing that you’ll need to do is Register and Sign In to the NuGet Gallery, which takes a matter of seconds. This will provide you with an API key that you will need to use in order to publish packages to NuGet :

Api

After you have your API Key, you’ll just need to use the Publish option (File > Publish) within the NuGet Package Explorer :

Publish

Just enter in your API Key in the Publish dialog and hit Publish and you are done!

 

 

Calculating Business Hours in Javascript

js_business

Time is money, especially when that time is spent handling things like calculating hours worked and filling out time-sheets.

Recently, a user on the forums posed a question about how to go about calculating the number of hours worked between two specified dates. The request required that it must be handled through Javascript and that it must be as “exact as possible” down to the minute. So I wrote up the following very sub-optimal solution and thought I would post it here on the off-chance that anyone encounters the same issue.

Let’s take a look at what information we need :

  • Define the work hours during the day (ie 9AM-5PM)
  • Define a starting and ending date to calculate between.
  • Determine if weekends are counted.

Using this information I threw together the following (and I have annotated to help specify what is going on) :

// Simple function that accepts two parameters and calculates the number of hours worked within that range
function workingHoursBetweenDates(startDate, endDate) {
    // Store minutes worked
    var minutesWorked = 0;
  
    // Validate input
    if (endDate < startDate) { return 0; }
    
    // Loop from your Start to End dates (by hour)
    var current = startDate;

    // Define work range
    var workHoursStart = 9;
    var workHoursEnd = 18;
    var includeWeekends = false;

    // Loop while currentDate is less than end Date (by minutes)
    while(current <= endDate){          
        // Is the current time within a work day (and if it occurs on a weekend or not)          
        if(current.getHours() >= workHoursStart && current.getHours() <= workHoursEnd && (includeWeekends ? current.getDay() !== 0 && current.getDay() !== 6 : true)){
              minutesWorked++;
        }
         
        // Increment current time
        current.setTime(current.getTime() + 1000 * 60);
    }

    // Return the number of hours
    return minutesWorked / 60;
}

or if you would prefer to pass in all of your variables as parameters, you could use :

// Simple function that accepts two parameters and calculates the number of hours worked within that range
function workingHoursBetweenDates(startDate, endDate, dayStart, dayEnd, includeWeekends) {
    // Store minutes worked
    var minutesWorked = 0;
  
    // Validate input
    if (endDate < startDate) { return 0; }
    
    // Loop from your Start to End dates (by hour)
    var current = startDate;

    // Define work range
    var workHoursStart = dayStart;
    var workHoursEnd = dayEnd;

    // Loop while currentDate is less than end Date (by minutes)
    while(current <= endDate){      
        // Store the current time (with minutes adjusted)
        var currentTime = current.getHours() + (current.getMinutes() / 60);
             
        // Is the current time within a work day (and if it occurs on a weekend or not)                   
        if(currentTime >= workHoursStart && currentTime < workHoursEnd && (includeWeekends ? current.getDay() !== 0 && current.getDay() !== 6 : true)){
              minutesWorked++;
        }
         
        // Increment current time
        current.setTime(current.getTime() + 1000 * 60);
    }

    // Return the number of hours
    return (minutesWorked / 60).toFixed(2);
}

or if you want a minified version thanks to Google's Online Closure Compiler :

function workingHoursBetweenDates(a,b,e,f,g){var c=0;if(b<a)return 0;for(;a<=b;){var d=a.getHours()+a.getMinutes()/60;d>=e&&d<f&&(g?0!==a.getDay()&&6!==a.getDay():1)&&c++;a.setTime(a.getTime()+6E4)}return(c/60).toFixed(2)};

Basically, it simply starts at the beginning time and iterates until the end (while monitoring the number of minutes worked during this period). By no means is this optimal, but it should serve as a very basic example of how to calculate such a value within Javascript. Please feel free to post any improvements or optimizations within the comments section as this was just a hastily thrown together solution to solve the issue at hand.

You can find a working example here :

You can play around with an interactive example within JS Fiddle

You can play around with an interactive example within JSBin

The Circle of Life…cycle of MVC Applications

MVC-Lifecycle

One of the common challenges for developers migrating from the Web Forms environment to MVC is learning how to adjust to a different application life-cycle. Web Forms had a very well defined chain of events that would be triggered prior to a page being rendered, however the lines aren’t as clear within MVC.

Earlier this month I stumbled upon the following document from Cephas Lin provided both a high-level overview and a detailed view of the general life-cycle within an MVC application and I thought I would share it :

MVC Lifecycle

Basically the life-cycle, it could be summarized (very simply) as follows :

  1. The Application is started (through Application_Start) and the appropriate Routes are wired up and configured.
  2. An HTTP Request comes in and MVC takes over.
  3. Your Controller that cooresponds to that Route will be created, instantiated and any authorization filtering will be handled (if failed it will send back a failed request).
  4. Any model binding will occur from the Request to any parameters to populate your values.
  5. The logic of your Action will be executed as expected and it will find a View that corresponds to the one specified in the Action and pass it the appropriate Model.
  6. The Model will populate the View and it will be served to the user.
  7. The Result will be executed and the Controller will be disposed of.

This is a very generalized summary (it doesn’t go into detail about ActionFilters etc.). Hopefully it might help developers that are just migrating to MVC better understand what is going on behind the scenes.

If you wanted a more detailed exploration of it, I would recommend reviewing over the detailed view of the document above and checking out the following other related resources :

An Interesting List of Development Stuff (May 2014)

ILODS

In this month’s installment of the ILODS, we will take a look at all of the exciting announcements from Microsoft’s TechEd 2014 event as well as the usual collection of all sorts of other development-related news. Exciting things are ahead!

How Scott Hanselman Changed My Life

If you are a software developer working under the Microsoft umbrella, you are probably familiar with Scott Hanselman (and if you aren’t, you should be). This blog post from Noah Addy discusses how Scott inspired him to pursuit his dreams in the realm of technology. It’s a great read and it’s extremely inspiring story about how our heroes (even our development heroes) can help shape and improve our lives.

Meet vNext.

While I could probably spend an entire series introducing vNext (and I eventually will), I’ll give you the gist of it.

Probably one of the largest development announcements from Microsoft was the introduction of ASP.NET vNext. vNext is a complete revamp of the ASP.NET stack with a focus on being “leaner” and providing a better foundation for building both web-applications and those designed for Azure and the cloud. vNext flips the script and completely merges all of Web Pages, MVC and Web API into a single housing (MVC) and takes a very George R. R. Martin-equse approach to System.Web.

Actually - here are some of the release notes about it :

  • MVC, Web API, and Web Pages will be merged into one framework, called MVC 6. MVC 6 has no dependency on System.Web.
  • ASP.NET vNext includes new cloud-optimized versions of MVC 6, SignalR 3, and Entity Framework 7.
  • ASP.NET vNext will support true side-by-side deployment for all dependencies, including .NET for cloud. Nothing will be in the GAC.
  • ASP.NET vNext is host agnostic. You can host your app in IIS, or self-host in a custom process.
  • Dependency injection is built into the framework.
  • Web Forms, MVC 5, Web API 2, Web Pages 3, SignalR 2, EF 6 will be fully supported on ASP.NET vNext
  • .NET vNext (Cloud Optimized) will be a subset of the .NET vNext Framework, optimized for cloud and server workloads.
  • MVC 6, SignalR 3, EF 7 will have some breaking changes:
    • New project system
    • New configuration system
    • MVC / Web API / Web Pages merge, using a common set of abstractions for HTTP, routing, action selection, filters, model binding, and so on
    • No System.Web, new lightweight HttpContext

If you want to learn more about vNext, you can visit the vNext area of ASP.NET or you can check out Jon Galloway’s incredible collection of vNext resources here.

It’s Codin’ Season and I’m Huntin’ Code

Last year, I wrote up a post discussing Microsoft Research and the work that they have done with Pex. Pex, if you are unfamiliar with it, is a tool designed to help with white-box and unit-testing however it’s a bit more playful than that. The folks at MS Research elaborated on it a bit more and decided to make a game out of it called CodeHunt. CodeHunt is essentially a puzzle-based game that helps introduce people to coding through solving different challenges and progressing onto more difficult stages. It’s an interesting concept and I am sure that it could use a bit of work – but it is a step in a good direction to get people interested in coding (in a fun way).

A SQL Join Cheat Sheet

“You put your left-join in, you take your left-join out, you put your left-join in and you shake it all about.”

With the abundance of different kinds of SQL Joins out there, it can often get confusing when using them (if you don’t do so regularly). This cheat sheet filled with Venn diagrams might be worth printing out and laminating for the DBA in your life.

A Primer on Machine Learning : Differentiating between Magic and Machine!

If you have an interest in Machine Learning or frankly don’t know anything about it. Adam Geitgey provides a fairly concise and accessible introduction to the topic in this blog post. He details the different types of learning that a machine can do and even provides a few examples to demonstrate it as well. It’s not only an excellent primer on the topic, but if you find yourself interested he provides several links to continue your learning on the subject.

Change your Mind-set : Transitioning from jQuery to Angular

I stumbled across this excellent discussion on Stack Overflow which is worth reading for anyone working with Javascript frameworks. The question itself is from a developer that has a significant amount of experience with jQuery and is planning on making the transition to AngularJS. The discussion details some of the changes in mind-set and different hurdles that can be expected for anyone doing the same.

11 Across. I hate myself Down.

I’ve always been a fan of puzzles, but this is certainly not for everyone. Maria Pedersen and Ole Michelson created Regex Crossword, another puzzle site that torments its visitors by solving crossword puzzles through Regular Expressions (and they get crazy). It’s a nice switch from something like Suduku and you might find yourself learning a bit more about Regular Expressions in the process.

It sadly will not teach you when and when not to use them however.

If Shakespeare was in a rap battle…

If you remember that scene in Office Space where Michael Bolton (played by David Herman) is rapping, then this might be for you.

I know as a software developer and a fellow fan of rap music that I have often thought about analyzing all of the words within the rap genre to truly find which artist has the most diverse vocabulary. Thankfully I didn’t have to, as Matt Daniels decided to do just that. In one of his many analyses of hip-hop music, he culled through all of the data and compared today’s MCs against OG William Shakespeare to see how they compared. It’s an extremely entertaining read and it will only further reinforce the mantra : “Wu Tang Clan ain’t nothing to f*** with.”

Putting the ‘S’ in Solid : Swiss Army Knife Syndrome

In this short rant, Allan MacGregor discusses “Swiss Army Knife Syndrome” which results when the ‘S’ for single-responsibility in SOLID design principles turns to … well another four-letter ‘S’ word. It’s something that everyone needs to be reminded of now and then and what better way to do it then through a blog post filled with knives.

An Interesting List of Development Stuff (April 2014)

ILODS - April

In this month’s installment of the ILODS, we take a look a quite a few announcements that were made at Microsoft’s Build conference, articles to help you figure out if you are over-thinking your development projects or if you are simply blaming the guy that was there before you, the Heartbleed bug, Javascript, open-sourcing, New Orleans and much, much more.

Knowing Too Much to Code

It’s not very often that we associate experience with in inability to get something done, however it may be the case in what Scott Hanselman calls “Analysis Paralysis”. In this blog post, Scott discusses how more experienced developers might “over-think” many sometimes simple applications and make them far more complex than they need to be. He reminds us to ask ourselves “are we going to need that” throughout the development process to help curb this paralysis from affecting our productivity.

From “Potent Potables” to the Human Genome

Although it isn’t directly development-related, it’s always fun to see what development can actually result in. Any fans of Jeopardy should remember the cerebral beat-down served by IBM’s Watson to trivia wizards : Ken Jennings and Brad Rutter (primarily thanks to its insane robot buzzer reflexes). However, it now appears that Watson is now on our side and it’s opponent is a nasty one : cancer.

IBM hopes that Watson will be able to analyze millions of medical records and find correlations between cancer patients that might be impossible for human analysis to discover. Hopefully, this data-first approach may lead to new treatment methods and may help Watson solve one of our generations most challenging questions : finding a cure to cancer.

Extensions. Extensions Everywhere!

In his talk at //Build this yearMads Kristensen discussed the myriad of different tools and extensions available for Visual Studio that can help developers be more productive and in general make their lives easier. The list has extensions that cover a wide variety of topics such as productivity, templating, styling and more. I would highly recommend checking it out to see if you discover anything that makes you say “I’ve been looking for something like that!”.

And the Two Become One : Durandel and Angular Converge!

In this article, Rob Eisenberg (the creator of Durandel) discusses the differences and similarities between Durandel and the popular Angular Javascript frameworks in hopes of providing a response to “Which one should I use?”. He covers an ideal framework that merges many of the stronger features from each framework and how this convergence will help shape the futures of both of the respective libraries.

Change Your Password. Probably. 

One of the largest stories of this month has been the uprising of a nasty bug known as Heartbleed. The Heartbleed bug itself is a vulnerability within the popular OpenSSL cryptographic library and it basically leaves systems using it “exposed” and allows virtually anyone access to any secrets that might be housed behind the normally secure SSL walls if exploited.

If you are unsure if you might need to change your password or if you would like an idea at the popular systems that were affected, you may want to check out this link which details many popular sites to determine if you need to change your password. Additionally, you will want to ensure that you don’t change your password until the affected site has been properly patched and their certificates have been renewed.

Since this is a .NET specific blog, I will note that if you are using IIS then you have nothing to worry about as Microsoft uses schannel to handle all of its SSL needs.

Meet New Orleans.

This has nothing to do with the city in my home state and has everything to do with building highly-scalable Azure based applications. In this article, the ASP.NET team reintroduces project “Orleans”, which provides an approach to building high-scale applications using a service-based model. The project was used heavily within the popular Halo game series to help it achieve its massive scalability needs. It’s openly available currently, so you can head over an visit the project on CodePlex and check out if it may fit the bill for the needs of one of your current or upcoming projects.

Building Javascript Applications like a Superhero!

If you like Javascript and you have a strong desire to build them like a superhero, then this might be just the thing for you. The team at Superhero.js compiled a huge assortment of  resources relating to building and maintaining large-scale Javascript applications, organizing your code and utilizing the appropriate patterns, testing your applications and much, much more.

Introducing IdentityManager

In this post, security guru Brock Allen introduces his most recent creation : IdentityManager, a tool to help manage user identity data through the new ASP.NET Identity or his own MembershipReboot library. IdentityManager provides an extremely easy to use interface that should replace the recently departed ASP.NET Web Site Administration tool that many developers were extremely fond of in Visual Studio 2012. It supports user creation, password changes, e-mail, phone, claims and much, much more.

Passing the Blame.

Shamoon Siddiqui discusses why the latest developer at your company might seem like a wizard when compared to your previous developer. This piece covers a wide array of reasons why developers shouldn’t always be compared to one another or why one shouldn’t be necessarily blamed for decisions that were made at the time (hindsight is 20/20). It’s a solid article for any developer that can often be caught blaming others for their decisions without necessarily knowing what it was like being in their shoes.

The .NET Foundation and Open-Source

Another major announcement at the Build conference was the introduction of the .NET Foundation, a collection of open-source technologies and Microsoft’s development framework. It was established to help foster community involvement, collaboration and development with regards to open-source applications and to help bolster the relationship between Microsoft and the open-source community.

A wide range of Microsoft’s technologies within the .NET stack have already been open-sourced such as ASP.NET MVC, SignalR, Web API and even the powerful Roslyn compiler-as-a-service. If you want to dig around the source and see how some of the technologies were established, visit the link above and dive into the technology of your choice.

Additionally, the entire source of the .NET Framework is available as well that interests you and can be accessed through the Reference Source site here.

 

Debugging Deeper through Reference Source

Debugging Deepr

A little over a month ago, the ASP.NET team announced several changes and updates to the .NET Reference Source and in this post we are going to discuss how to actually integrate it into Visual Studio so that you can step into the actual .NET Framework source when debugging your applications.

What is Reference Source again?

Reference Source, if you are unfamiliar with it, was a project that Scott Guthrie and his team started back in 2007 in hopes of releasing the .NET Framework source to allow developers to easily reference it (without all kinds of decompilation and mischief) to see what was really going on under the hood. Shortly after that release, the team made a few changes that would allow developers to actually step through the source code which was a major step in a very cool direction.

One of the major difficulties with managing something that is constantly evolving like the .NET Framework is purely the fact that it is “constantly evolving”. Updating documentation usually takes time and with a project of this magnitude, it could simply be something that is “left over until the end” or simply doesn’t get done :

Reference Source circa 2007.

Reference Source circa 2007 via Scott Guthrie

Reference Source Meets Roslyn.

As part of this year’s announcement regarding Reference Source, it was mentioned that it would be joining forces with Microsoft’s latest development wonder, Roslyn.

Roslyn is a managed compiler-as-a-service that has really flipped the script in the .NET world recently. It provides all kinds of wonderful features that were simply not possible in previous years and has already been used not only by Microsoft but in many other arenas such as .NETFiddle, Bing Code Search, Semantic Merge and more. Roslyn was used to help generate a semantic index of the entire .NET Framework source to allow it to be searched through with the greatest of ease.

Currently, .NET 4.5.1 is indexed and readily available on the Reference Source site and the ASP.NET team announced a commitment to keep things updated with each upcoming release as they occur to prevent any stagnation that may have plagued the previous versions of the tool. So you can be relatively sure that whenever you are accessing the latest version of the Reference Source that it should be the latest and greatest. The improvements were not limited to just performance either.

The UI received a very stylish overhaul as well and yield some of the nicest looking documentation that you’ll come across :

The New and Improved Reference Source

The New and Improved Reference Source

Another undocumented feature is the tiny snippets of entertaining comments that you can find scattered throughout the source as well :

An example of one of the many entertaining comments throughout the source.

An example of one of the many entertaining comments throughout the source.

Putting it to Good Use.

Let’s actually put the Reference Source to use along with Visual Studio 2013 and use it to debug an application by not only stepping through our own code, but into the source of the .NET Framework as well.

To get started, there are a few changes we need to make within Visual Studio that will allow us to target the Reference Source (which will primarily consist of enabling and disabling a bunch of properties in the Options menu).

Open up Visual Studio and navigate on over to the options menu (Tools > Options > Debugging > General) as seen below :

You'll need to enable and disable the following options within the Debugging Options in Visual Studio

You’ll need to enable and disable the following options within the Debugging Options in Visual Studio

and then you are going to disable the following options :

  • Just My Code
  • Step over Properties and Operators (Managed Only)
  • Require Source Files to Exactly Match the Original Version

and enable these ones :

  • Enable .NET Framework Source Stepping
  • Enable Source Server Source

After making the changes, your options menu should look like this :

This is what your Debugging Options should look like prior to stepping through Reference Source

This is what your Debugging Options should look like prior to stepping through Reference Source

Then, you’ll need to make sure that when debugging that you are targeting the actual Visual Studio Reference Source. You can do this by visiting the Symbols area under options (Tools > Options > Debugging > Symbols) :

You'll need to access the Symbols area in order to use Reference Source when debugging

You’ll need to access the Symbols area in order to use Reference Source when debugging

From here, you’ll want to target the Reference Source symbols available at http://referencesource.microsoft.com/symbols. You’ll need to click the Add Symbols option within the Symbols area and add the previously mentioned URL :

Click the Folder icon and add the appropriate symbols reference for Reference Source

Click the Folder icon and add the appropriate symbols reference for Reference Source

What I have found to be a safer and more reliable approach however, is to simply download the source and reference it locally from the following location :

http://referencesource.microsoft.com/DotNetReferenceSource.zip

After making those changes, you’ll need to ensure that the project that you are going to be debugging is targeting .NET 4.5.1. Debugging through Reference Source is going to currently be limited to 4.5.1 and above since those are the only actual versions of the .NET source that have been indexed so far.

Looking Under the Hood.

Now that we have configured everything, let’s make a really simple program to demonstrate traveling through the source.

// Generate a collection of values (1-100)
var numbers = Enumerable.Range(1, 100);
// Order them randomly
numbers = numbers.OrderBy(n => Guid.NewGuid());
// Store these values in an array
var numberArray = numbers.ToArray();
// Sort the array
Array.Sort(numberArray);

Using the simple program above, we will create a collection of numbers, randomly order them, store them in an array and then finally sort them using a variety of methods.

Let's place a breakpoint on the first line and run the program.

When you hit your first breakpoint, right-click on the method (in this case System.Linq.Enumerable.Range) and you should see an option within the context menu called "Step Into Specific" which will allow you to send the debugger into the .NET source for that particular method as seen below :

You can use the "Step into Specific > (Your Method)" option to debug through the .NET source.

You can use the "Step into Specific > (Your Method)" option to debug through the .NET source.

After selecting the method to step into through "Step into Specific", you'll see that the debugger jumps into the related .NET source and you can step through the method as you would expect within any other .NET application being debugged :

After using the "Step into Specific" option, you'll be presented with the source for your specific function, which you can debug as expected.

After using the "Step into Specific" option, you'll be presented with the source for your specific function, which you can debug as expected.

And that's basically all you need to know about using Reference Source within Visual Studio to debug your applications. You should be able to jump into any of the assemblies that are currently supported within Reference Source without any issue.

Considerations

A few other considerations if you are having trouble :

  • Debugging through Reference Source currently ONLY works for full versions of Visual Studio 2013 (sorry no Express versions). I've spoken with several members of the Visual Studio team and they are looking into possibly removing this restriction in the future.
  • Ensure that the assembly that you are attempting to step into is one of the available assemblies for debugging mentioned here.

If you still continue to encounter any errors or something isn't working that you believe should - contact the Reference Source Feedback team via the "Feedback" link on the Reference Source page.

An Interesting List of Development Stuff (March 2014)

march2014

In this St. Patrick’s day installment of an Interesting List of Development Stuff, we dive into a more .NET-centric approach (with a majority of the topics at least being in the realm of .NET) but as usual, there should be something for everyone. The Roslyn compiler continues to make waves and appears in several of the articles (which we may see as a trend as it continues to grow in popularity) and there’s also a few articles pertaining to games (if that’s your thing).

Depixelizing Pixel Art

Microsoft Research is always doing cool stuff and this article is no exception. It discusses an algorithm that was developed to help smooth the appearance of pixelated images (mostly involving Nintendo-related characters) and it yielded some really neat results. I am sure that nothing excites people more than smooth pixels, but this article has everything : badass-looking video game characters (that we have always wondered what they would look like in their unpixelated glory), legit scholarly work on algorithms, splice curves and more (again decorated with video game characters) and its all packed into 8 pages.

I would highly encourage anyone interested to read through the actual paper itself and if that isn’t your thing, at least take a look at the supplemental material to see it in action.

ElasticLinq

Brad Wilson and Jim Newkirk of Tier 3 introduce their latest creation ElasticLinq, which is an open-source project that aims at integrating elastic-searching using LINQ syntax within .NET. It’s a tool that was originally developed in-house at Tier 3 to help ease the transition for developers with traditional database backgrounds to NoSQL-based databases and now hopefully it can help you make the transition as well!

How Roslyn and Azure Helped Create .NET Fiddle

I’ll use this as a pseudo-followup to my post last year on .NET Fiddle. .NET Fiddle has really taken off and added all kinds of awesome new features such as NuGet support, MVC support and all kinds the general badassery that one would look for in an online developmental sandbox. This short article isn’t so much about the merits of .NET Fiddle, but more of a look behind the scenes at how it came to be; you can think of it as a love story between Azure and Roslyn.

Open-source Projects! Come on down!

If you are a big fan of open-source software or you have an open-source project, then listen up. OSSPerks.com features a large listing of available services and APIs that are offered free of charge to open-source projects. They vary in scope but there are a lot of very well known vendors involved – so if your project needs a little extra something and your pockets are light, check it out.

There’s a new operator in town.

It looks like one of the most popular suggestions to appear within Microsoft’s UserVoice system is finally coming to fruition. The Safe Navigator operator (?.) will be likely introduced within the next iteration of C# and Visual Basic and should aid in warding off those NullReferenceExceptions that always find a way into our lives, hearts and applications.

Atom, the completely hackable Editor

The folks at github set the web ablaze with all kinds of chatter and backroom deals when discussion of their Atom editor broke out. Atom was designed as a completely “hackable” editor that could be easily extended to do – really whatever you wanted it to do. It’s still a project that is very early in its infancy, but it is something to keep your eye on.

Meet Reference Source

The great Scott Hanselman discusses another one of the recent offspring from the seemingly promiscuous Roslyn compiler in the form of Reference Source. This incredible innovation will now allow developers to step through the actual source of the .NET Framework while debugging their applications (so if you have ever wondered just what kind of sort was going down in that Array.Sort() method, here is your chance). It’s certainly a tool worth keeping your eye on – and if you want to hear and see more about it, you can check out this post from the MSDN team as well.

Walking through the Code of Games

Fabien Sanglard‘s blog is a fascinating place to visit if you haven’t been by (you can get there by just clicking the link). He has a myriad of different articles, book reviews and discussions on algorithms, but the reason I am bringing it up are his source code reviews. Now, I know that most people would cringe at reading a source code review, but these focus on actual commercial games like Doom, Prince of Persia, Duke Nukem 3D and Fabien does a great job of “skipping to the good parts”.

2048.

I’m not saying anything more about this – you’ll likely hate me if you haven’t previously discovered it. It’s digital heroin.

Introducing Bing Code Search, an easy way to find code samples from within Visual Studio 2013

Time is valuable and sometimes taking the time to open up a new browser tab to search for an example of code to do something can be a pain (because we can also be lazy). Thankfully, Microsoft’s Language Experience team created a product just for you: Bing Code Search.

bing

What Does It Do?

Released just this month as an extension for non-Express editions of Visual Studio 2013, Bing Code Search presents some very cool and useful features, which may be especially useful for experienced developers that need a quicker method of accessing examples and resources and for new developers still trying to figure out the code they need to accomplish tasks like reading files or iterating through collections.

After installing the extension in Visual Studio, you’ll see the  a small Bing logo above the native Visual Studio Intellisense. This will allow you to search for and use code examples and snippets from sites like Stack Overflow, MSDN and more without ever leaving your development environment or dragging an open browser onto another monitor :

Using the Bing Code Search to suggest possible solutions to a problem

Using the Bing Code Search to suggest possible solutions to a problem

What is going on here?

Magic!

Just kidding, but in as with most recent Microsoft innovations in the realm of development, the Roslyn compiler is involved (which is a bit magical). Basically, when you begin your search, your specific query is sent up to Bing along with several other important contextual pieces of information related to your project (such as the Project type, contextual keywords and other goodies) and then it returns a filtered and ranked set of results that might best match the code example you are looking for.

Since there isn’t a holy grail website containing all of the latest a greatest code examples, the code search will actually scour a multitude of different Q/A sites along with some other documentation and resources and compile a listing of relevant code examples that the developer can easily use either for documentation or to copy-paste directly into their project.

How Do I Use It?

The Bing Code Search extension is currently only available for Visual Studio 2013 (non-Express editions) and can be easily downloaded and installed from the Visual Studio gallery at link provided below :

If you don’t have Visual Studio 2013 or you just want to get an idea of how the service works, you can access a fully working example running below at Microsoft Research’s CodeSnippet area :

Try it out.

As a free tool that is incredibly easy to use, I would highly recommend giving it a shot if you have a non-Express edition of Visual Studio 2013 installed. It’s still a very early product and will likely continue to improve in the future (hopefully expanding to non-Express editions as well as earlier versions of Visual Studio), but it may be a great tool to consider adding to your development arsenal either as a time-saver if you are an experienced developer or as an excellent learning tool for those just diving into the development world.

An Interesting List of Development Stuff (February 2014)

february2014u

In this installment of my monthly treasure trove of development stuff, we take a slightly more .NET-oriented approach by covering several ASP.NET specific topics, resources and more. But there are quite a few other things that may be applicable to just about any kind of developers (and especially those that may be looking for a job).

Send a Valentine’s Day Math-o-Gram

In honor of Valentine’s Day, the folks over at Desmos decided that rather than sending a crummy card to your loved one, you could give them something that all women really love: math. By creating a very simple Node.js application, you can plug in different formulas and create a customizable “love graph” to send to your significant other.. or just play around with it.

Sidewaffle

No, sadly this is not some new breakfast-related concoction covered with delicious syrup. What is it however is an incredibly useful extension to Visual Studio that adds a bunch of different snippets, templates and other goodies into Visual Studio to help you become a more efficient and productive .NET developer.

Codility Training

Codility is a great site that administers short, automated programming tests for companies that are looking to hire developers. The tests can be performed in a variety of languages and they don’t simply evaluate if the applicant can solve the problem at hand, but how efficient they solved it (considering computational complexity) and if they handled edge cases as well. Now, obviously most readers of this blog are not going to be hiring managers, but Codility offers a free training area to help prepare those that are entering the job market to beef up their problem solving skills. It’s a superb resource for those of you out there that are currently in the job market and want to improve your chops.

Who needs Code Reviews?

A slightly satirical look at the benefits to productivity, developer happiness and deadlines when developers stop working about reviewing code and just start coding.

Strapfork

While it is still just in beta, Strapfork is a new visual editor for developing themes using Twitter’s Bootstrap. It aims to make the entire process of customizing and creating your own themes a cinch by allowing you to adjust every detail from gradients to typography and more. Stay tuned for more!

A Last Look at ASP.NET in 2013 and what to look forward to in 2014!

Jon Galloway covers the good times and the bad times had in 2013 by ASP.NET and how it has grown and continues to develop into a young adult (we are so proud). He reviews over all of the major improvements that have been made in the past year and details what to expect and watch for in 2014.

Do you really need jQuery?

Do you ever wonder if you really need to include that jQuery reference in your project or if there might be another very simple approach that could save you all those delicious kilobytes? Well then this is just the link for you. This site reviews over a bevy of tasks that jQuery typically handles and provides the equivalent code in pure Javascript. It’s a great resource for those that may want to slim down their sites and applications a bit if they are just using jQuery for handling things like AJAX or trivial DOM manipulation.

Nu-Gotta-Get-It

If you develop .NET applications, then you probably are a fan of NuGet (if not, go read about it and then come back when you are a fan). This site helps you find the best and most popular NuGet packages that you might be missing out on and allows you rank existing packages based on quality, documentation and more. It’s worth checking out if you are looking to incorporate a specific feature or package into your application and there are a ton of different choices out there.

Using the Pomodoro Technique and Trello to Lead a More Efficient Life

A great article by John Sonmez using the Pomodoro technique to help dramatically improve your productivity not only in your career, but also to help organize your life.

IdentityReboot and MembershipReboot

Security guru, Brock Allen introduces two of his major projects which aim to improve the existing ways that ASP.NET handles both Identity and Membership from a security perspective. If you have any qualms about weaknesses within ASP.NET and its built-in security mechanisms, you can be almost assured that Brock has addressed those in these two packages. Even if you aren’t a security expert, the introductions are worthy reads that may interest you enough to use them in the future.

When MVC5, SignalR and NuGet Just Won’t Get Along

This is obviously an exaggeration.

This is obviously an exaggeration.

Sometimes things just blow up.

If you have recently attempted to create a new ASP.NET MVC5 project (or any new Web Project within Visual Studio 2013) and decided that you wanted some of that sweet SignalR magic in your application, then you may have encountered the following error :

An exception of type ‘System.IO.FileLoadException’ occurred in Microsoft.AspNet.SignalR.Core.dll but was not handled in user code.

Additional information: Could not load file or assembly ‘Microsoft.Owin, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0×80131040)

This can easily be reproduced through the following steps :

  1. Create a new Web Application Project in Visual Studio 2013 that uses built-in Forms Authentication (Individual User Accounts).
  2. Add the SignalR package through NuGet.
  3. Attempt to add the following code to your Startup.cs file :
    public partial class Startup
    {
            public void Configuration(IAppBuilder app)
            {
                // Add SignalR Mappings
                app.MapSignalR();
    
                ConfigureAuth(app);
            }
    }

If you did everything right, then grab some popcorn because you are about to see this :

FileLoadException

Why is this happening to me?

Of all of the things to blame, we are going to choose NuGet for this one.

This is currently a known issue within NuGet. The reason for this is that SignalR and some other binaries are built with a dependency over Microsoft.Owin Version 2.0.0, however the appropriate assembly binding redirects are not occurring. This causes a problem as the latest available version of Microsoft.Owin in the public NuGet feed is greater than 2.0.0.

Okay. But how do I fix it?

There are two options here, which I have each had success with so I'll start with the easiest approach, installing a specific updated version of Microsoft.Owin (and Microsoft.Owin.Security) and ensuring that you are properly targeting it within your web.config.

You can do this within the following steps :

  • Access the NuGet command-line tool within Visual Studio (accessible under Tools > Library Package Manager > Package Manager Console)
  • Install an updated version of Microsoft.Owin and Microsoft.Owin.Security (2.0.1, 2.1.0, 2.2.0 or any other version) using the following command :
    Install-Package Microsoft.Owin -Version 2.1.0
    Install-Package Microsoft.Owin.Security -Version 2.1.0
  • Ensure that your web.config has the appropriate <bindingRedirect> attributes to target the version you selected as seen below :
    <runtime>
       <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
           <!-- Other Assemblies here -->
           <dependentAssembly>
               <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
               <!-- Notice this targets 2.1.0.0 -->
               <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
           </dependentAssembly>
           <dependentAssembly>
               <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
               <!-- Notice this targets 2.1.0.0 -->
               <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
           </dependentAssembly>
       </assemblyBinding>
    </runtime>

The other longer and seemingly less reliable (in my experience) approach

This method appears to only work if the version of Owin that was installed through NuGet is already greater than one of the dependencies that you already have.

The second option involves creating a Console application and then add the SignalR package to it. Then copy the  bindingRedirects from the app.config file of this application to the web.config file in your previous exception-infested MVC application (as Console applications don't have this same issue).

You really just need to update the oldVersion and newVersion attributes within the <bindingRedirect> sections for your Microsoft.Owin and Microsoft.Owin assemblies within the <assemblyBinding> section of your web.config from :

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <!-- Other <assemblyBinding> elements for your Project -->
        <dependentAssembly>
            <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

to :

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <!-- Other <assemblyBinding> elements for your Project -->
        <dependentAssembly>
            <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

Or more simply, change the <bindingRedirect> sections for each of your Owin-related assemblies from :

<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />

to :

<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />