C#

February 24, 2017

Take Control of Code Coverage Analysis with Exclusions

As developers Unit Testing makes our jobs easier, we have consistent tests to validate our work, change management becomes easier, and we can prove the functionality remains the same. In collaboration with various companies, however, I find that often the tooling gets in the way of developers understanding exactly how much of their important code is covered by unit tests. Visual Studio provides unit test coverage tools for reporting, yet often the tool ends up discouraging users due to a lower than expected rate of coverage. In this post, we will investigate a few common areas that can impact your unit test coverage, and how to prevent certain items from changing the reported coverage percentage.

January 25, 2017

Using Entity Framework with Legacy Databases

I find more people are interested in getting started with Entity Framework within their organizations. However, the various documentation and examples that exist don't necessarily give the best overall implementation solutions. I have worked with many people that have thought "we have a legacy database setup, we can't use entity framework" or "we cannot use migrations, so we can't use code first." Both are very common misconceptions, but something that isn't the case. It just takes a bit of work. In this post, we will dive into the specifics of implementing Entity Framework to a legacy database, where we cannot rename tables and other objects without substantial effort. A link to full code will be provided at the bottom.

December 29, 2015

Debugging & Managing NuGet Packages A Lesson Learned

Over the past few years those of us in the .NET development space have been forced to jump on the NuGet bandwagon as it relates to adding certain dependencies to our own projects.  No matter what our individual thoughts are with regards to NuGet we must learn to live with the tool, and use it to the best of our abilities.  Most of the time the packages that we use will be well-formed and managed in a responsive manner.  However, as I recently learned, that isn't always the case.  When things start to go awry it can make your standard diagnostic processes less than successful.  Given these experiences I wanted to share two recent experiences with NuGet, not in an effort to shame any of the involved parties, but to help illustrate the importance of looking at solutions & packages in a different light than your standard development processes.

October 08, 2015

Handing Namespace and Class Changes in Entity Framework

Entity Framework is an amazing set of tooling that helps to manage data access in an efficient manner, however, it seems that when things start to go "funny" it can be a major time-suck.  A recent issue that I experienced that I thought would be worth sharing was an issue related to applying migrations.  Adding migrations is something that has become trivial, yet one day my project reported Unable to generate an explicit migration because the following explicit migrations are pending:.... With every single one of my existing migrations listed.  This was highly curious, as the application has been in use, in production, for the better part of a few months.

September 17, 2015

Don't Fear the Cache

Over the past three to four years I have spent extensive time working with customers to improve performance.  As part of this endeavor I have had the pleasure of working with numerous internal, external and third-party development teams for these companies and the experiences have provided a great deal of insight to how people look at performance with software development.  This experience transcends platforms as the specific concern with this post has been experienced with ASP.NET MVC Projects, DNN Projects, WPF projects, and even those on mobile devices.  Although each platform or process will have different rules and requirements for performance and methods to manage it, there are a few constants. This post is going to be the first of many posts around performance optimization and development. best practices. 

November 03, 2014

Back to the Basics: LINQ and You

This past weekend I was a presenter at IowaCodeCamp, my favorite local .NET event each spring/fall.  My session this year was "Back to the Basics: LINQ and You" and it was much more popular than anticipated!  After spending a lot of time training development teams over the past year I found that although LINQ has been available since 2008 many individuals have either not yet had the chance to use it yet in their projects or those that are using it still didn't fully understand how/why it works the way that it does, and thus my session was born!
February 26, 2013

Creating an ASP.NET 4.5 File Security Process

Often when working with web applications it is necessary to secure access to documents or other user supplied resources.  If you look online you will find a number of different recommendations on how to accomplish this.  Some will recommend a HTTP Handler, some will recommend a simple ASPX, others will have other random ideas.  Regardless of the actual implementation there is always a common area of mixed recommendation, once you have validated that the user has the proper permissions to access the resource, how do you get the item to the user?  In this post I'll discuss a new API that is publicly available in .NET 4.5 that helps with one problem area.
September 05, 2012

My Favorite Visual Studio 2012 Breaking Change

It is not very often that you see the words "favorite" and "breaking change" within the same sentence.  However, I will say with VS 2012 and .NET 4.5 there happens to be one that I thought I would call special attention to here on my blog as I've talked about the old behavior many times in talks throughout the past few years. 

February 29, 2012

Visual Studio 11 Caller Member Info Attributes

If you have been paying attention to what is going on in the Microsoft Community today you will notice is a big day.  Visual Studio 11 Beta as well as Windows 8 Consumer Preview were both released this morning, for those of us developers it means tons of new tools to try out and lots of new functionality that we can use in our applications as well as productivity and language improvements with.NET 4.5.  With this, I'm starting a new blog series highlighting some of the new items that I find helpful, cool, or otherwise interesting with VS 11 Development.  Today's installment talks about Caller Member Info Attributes.
November 07, 2011

Force User Roles Update via DotNetNuke

One of the things that I have been finding that I do a lot recently is updating user security roles based on actions either taken by the users or actions that have been taken by others.  Doing so is quite simple from a DotNetNuke API perspective but how do you go about actually forcing the role membership change right away?  That is what I'll talk about in this post.

August 12, 2011

Improving the C# Debugging Experience - DebuggerDisplay

In an effort to start blogging more about the "helpful" items that I have encountered over the years this is one of my first "Quick Tips" related to improving the life of the developer.  We all have had those times where we are tracking down a complex problem within an application and all along the way we have to spend endless time mousing over individual classes to find out what their values are when most commonly we just want to know about one or two key values.  Well in this post, I'll show you a neat trick using the "DebuggerDisplay" attribute to help make this process easier.

April 09, 2011

.NET Memory Management and You!

I teach introduction and advanced .NET development courses for a local community college and one item that I always cover in each class is a discussion around Memory Management and Garbage Collection. I am often asked by my students if this is something that they really should be concerned about and my opinion has always been yes, but I know that many developers feel that having an intimate understanding of how Garbage Collection is completed is unnecessary. Finally after a number of constant reminders from students, I thought I would actually put out my "simple" version and explanation out here that I give my students each semester and gather some feedback from my blog readers on their thoughts on the manner.

March 01, 2011

DotNetNuke Going to C# - My Thoughts

Well, as I'm sure that most of you have figured out already, DotNetNuke Corporation announced yesterday that starting with Version 6.x of DotNetNuke the core will be using C# as the programming language.  This change is something that has been talked about at community events in the past and various people have shared their comments on the potential decision, and even since yesterday people have voiced their opinions on it now that the change is official.  With this post I'm going to share a few of my thoughts on this, and hopefully take a slightly different approach.

January 04, 2011

C# Quick Tip: Try/Finally Block

This post is the first of a series of "quick tip" blog postings.  These will be shorter articles focused on providing quick tips on various topics.  Each posting will be tagged with a single category as well as the "Quick Tips" category to indicate it is a quick tip.

For the first Quick Tip I want to focus on a language feature of both C# and VB.NET that is not always something people think of.  Everyone should be familiar with the Try/Catch/Finally and Try/Catch blocks of code.  These are key concepts that are discussed in introduction to .NET classes.  However, there is another flavor of exception handling that can be used which is a Try/Finally block. In this post I will show a simple example.

March 23, 2010

Selecting the Right .NET Language the VB or C# Debate

Now first of all, before I get into the true content of this blog posting I do NOT want to start another round of the religious war that always seems to happen when you start talking about the usage of Visual Basic or C#.  The purpose of this blog posting is to put a little perspective into why I choose to work with a specific language for different projects, and the evaluation criteria that I use when making the choice for individual projects.  Yes, I'm a C# MVP, C# is my preferred .NET language, but I'll be the first to admit that there are times and places where VB is a necessary language.  In this article, I'll start out by providing a bit of background as to WHY I'm blogging about this, the evaluation criteria that I use when looking at a project and some other general information that I've found over the years.  Keep in mind the disclaimer found at the bottom of this posting, these are my thoughts, and mine alone, if you don't like them, which I'm sure many of you will not that is fine, but I wanted to put a bit of perspective on my take for the common argument.

October 09, 2009

Using LINQ to Aggregate and Group

Recently when I was presenting at Tech Days Canada I was preparing some examples of how LINQ could be used to do in-memory manipulations of data to help avoid repeated database calls. In the presentation I showed some quick code samples, and I thought that I would follow this up with a few simple examples here in a blog post. Before I start I wanted to share that the code shown here is actual production code that is being used to run the reporting on MyWebKeepAlive, the keep alive service offered by my company IowaComputerGurus.

July 03, 2009

Improving the Debugger Experience Using Attributes

I have often found that when debugging applications that a lot of time is spent drilling down into the various custom objects to see what the values are of specific instance methods.  In this blog posting I will demonstrate the default behavior of Visual Studio when debugging a class, I will then show how you can improve the debugging experience with the addition of a simple attribute.

May 22, 2009

Development Environment and Tools Used

A very common question that I get asked by people is; what tools do you use to complete your development and what type of system do you use.  Now, I believe I have written a bit about this in the past, but I thought I would take some time to go through and give a bit of a detailed overview of what I use for development and why I have selected the hardware and software that I have.  I will cover this in detail from both the hardware and software point of view.

April 16, 2009

Review of SourceGear Vault Source Control Provider

My last blog article "Selecting the Right Source Control Provider" touched on the evaluation criteria that I use when looking for a source control system. This article is a review of sorts of SourceGear's Vault product, my preferred source control system. I'll start by reviewing vault as it relates to the criteria from the previous article, I will then provide my overall feedback on my experience with Vault.

April 08, 2009

Selecting the Right Source Control Provider

One of the most common questions that I have been getting recently has been "what source control provider do you use and why?".  This article is the first in a series of two articles about source control.  This article takes a quick look at criteria that I believe is important to consider when it comes to evaluating source control systems for use.  The next article in the series will be a review of the source control system that I use, in relation to the evaluation criteria that I list in this article.

January 22, 2009

Avoiding File Locks and Cannot Access File Exceptions

While working through some issues recently with some legacy code written by someone else I was faced with a horrible case of a shared object that was writing to the file.  This was a "custom" logging implementation and opened a file for append, inserted the line, and then closed the file.  Well in times of heavy load the system would encounter errors such as "Cannot access ___ because it is being used by another process".  So in effect the file was either still open, or the lock was not yet released.  This post goes through a bit of the detail on how I resolved the issue.

May 22, 2008

Exporting a DataGrid to Excel The Easy Way

Recently I have answered a number of questions regarding an easy way to export datagrid contents to excel format.  In this blog post I will share a static class that I have created called "ExportHelper" which I use quite often to generate quick Excel exports of datagrid data.  I will outline the process and the code below.  It should be noted that this solution is NOT a DotNetNuke specific solution, I use this for both DotNetNuke and standard ASP.NET solutions.

March 02, 2008

Visual Studio Code Snippets

Recently I have been asked by multiple people what rapid design tools I use, or what types of code generation tools do I use.  Many people are surprised when I tell them that for the most part I don't use any rapid generation tools.  I do use a few home grown tools, such as my Info Class Generator, which is available on this site.  However, that is as far as I go with automated code generators.  However, one thing that I have started using more and more frequently are Code Snippets within Visual Studio.

I have found that creating a few helpful Code Snippets has allowed me to quickly and easily format my code, and build my needed structures in almost no time.  In this blog article I will share two of my most commonly used Code Snippets, if there is a demand I will post future code snippets here as well.

December 20, 2007

Debugging WAP DotNetNuke Modules

A question I have been asked many times recently is how do you debug a DotNetNuke module that has been developed using the WAP (Web Application Project) development model.  This is a question that I have known the general answer to for quite some time, but I have never actually had a need to truly debug one of my custom modules.  During the course of helping a client with an issue today I actually took the time to document all steps necessary to debug a WAP DotNetNuke Module within Visual Studio 2005.  This article will walk you through all steps necessary to debug your project.

September 20, 2007

C# 3.0 Auto Implemented Properties

Part of getting ready for OpenForce '07 involved looking into Visual Studio 2008 and Silverlight.  As happens every time I browse new technology I got quickly sidetracked and sumbled upon a Microsoft document that outlines all of the new features with C# 3.0 which will be released with Visual Studio 2008 as part of the .NET 3.0 framework.  This article will give you a quick overview of the first thing I found, and honestly one of my favorites overall "Automatically Implemented Properties"

Content provided in this blog is provided "AS-IS" and the information should be used at your own discretion.  The thoughts and opinions expressed are the personal thoughts of Mitchel Sellers and do not reflect the opinions of his employer.

Content Copyright

Content in this blog is copyright protected.  Re-publishing on other websites is allowed as long as proper credit and backlink to the article is provided.  Any other re-publishing or distribution of this content is prohibited without written permission from Mitchel Sellers.