Thursday, January 29, 2015

Getting started with Ninject for ASP.NET MVC and ASP.NET Web API

If you are using ASP.NET MVC or ASP.NET Web API, you are probably interested in using a Dependency Injection Framework such as Ninject to help you with Unit Testing your Controllers.

Well, fortunately, getting started with Ninject in your ASP.NET MVC or ASP.NET Web API projects is relatively easy!

First, either create an ASP.NET MVC or ASP.NET Web API project.

Once you have done that, you will need to add NuGet packages to your project to add the Ninject reference assemblies.

For an ASP.NET MVC web application, you will want to add Ninject.MVC5 and ninject.extensions.conventions:







For an ASP.NET Web API project, you will want to add Ninject integration for WebApi 2 and ninject.extensions.conventions:


You will also have to add a NuGet package reference for WebActivator:



For your Web API project, the NinjectWebCommon.cs file will not automatically be added to your project, so you may have to copy and paste it from a sample ASP.NET MVC project.  The NinjectWebCommon.cs file should be placed in the App_Start folder of your ASP.NET MVC web application.

In the NinjectWebCommon.cs file in your project, you can then add your kernel.Bind code to inject all of the appropriate dependencies in the RegisterServices method.

That is all there is to it!!


Training for Microsoft 70-480 certification exam

If you are looking for online training for the Microsoft 70-480 exam, there are several options available:

  1. Microsoft Virtual Academy: http://channel9.msdn.com/Series/Developing-HTML-5-Apps-Jump-Start/Developing-HTML5-Apps-Jump-Start-01a-HTML5-Semantic-Structure-Part-1
  2. CBT Nuggets: https://www.cbtnuggets.com/it-training-videos/course/msft_70_480/
  3. PluralSight: http://blog.pluralsight.com/learning-path-programming-in-html5-with-javascript-and-css3-microsoft-exam-70-480
Of the 3 options, only CBT Nuggets offers a comprehensive review of the topics for the 70-480 exam.  Microsoft Virtual Academy covers most of the topics but ignores other topics completely such as use of the jQuery library which is extensively covered on the actual exam.  While PluralSight has a curriculum geared towards prepping you for the exam, the courses are not geared or targeted specifically for certification so it provides you with numerous hours of training which may not be directly relevant for the exam. 

Of course, if you don't mind reading the material, then these Microsoft Exam Prep books will cover the material necessary for the exam, but if you are not already familiar with the material, it will require lots of hands-on practice:

  1. http://smile.amazon.com/Training-Guide-Programming-JavaScript-Microsoft/dp/0735674388/ref=sr_1_2?ie=UTF8&qid=1422574546&sr=8-2&keywords=70-480
  2. http://smile.amazon.com/Exam-70-480-Programming-HTML5-JavaScript/dp/0735676631/ref=sr_1_1?ie=UTF8&qid=1422574546&sr=8-1&keywords=70-480

Of the 2 books, I would recommend purchasing the Training Guide over the ExamRef since the Training Guide covers much more material and therefore seems more comprehensive.

Camel casing DTO objects in ASP.NET Web API

 

If you are creating DTO (Data Transfer Objects) in ASP.NET Web API, chances are, you are using Pascal Casing for the names of your Properties/Members according to C# conventions.

However, as you may already know, JSON uses a convention of Camel Casing.

So how do you solve this discrepancy between the 2 platforms when your DTOs are serialized into JSON by Web API?

Well, fortunately, Microsoft has provided a very easy solution to this!

You can simply add the following code to your WebApiConfig.cs file in the App_Start folder of your Web API project (or the Startup class in Project Katana):

//Convert Pascal casing of DTO objects to Camel Casing to be supported by JavaScript clients
var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().FirstOrDefault();
jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();


Now when you use Pascal Casing for your Properties in your DTOs, they will automatically be converted to Camel Case when Web API serializes your objects into JSON thereby matching the JSON naming convention!


How cool is that???

Windows 10 First Look

I just installed Windows 10 for the first time today and I started playing around with it to see the hype about all of the new features especially the fact about the return of the Start menu.

Well, as it turns out, there are definitely some nice new features that are an improvement over Windows 8/8.1, but still does not bring back the comfort and ease-of-use of Windows 7.

The Windows button is back and it sports a whole new Start Menu that basically brings the Metro screen into the Start menu and gets rid of the Charms bar altogether:





Unlike the earlier versions of the Start menu in Windows 7, you will notice that there is no "Programs" menu option.  Instead, there is an All apps menu option.




The All apps menu option provides an alphabetized version of all of the Apps/Programs on the system.

If I want to expand the display of the Metro Apps, I can click on the 4-arrow icon in the upper right hand corner to expand the Start menu to fill the screen similar to the Metro Start menu in Windows 8/8.1:



Unfortunately, all of the categorizations for separating Administrative tools from common tools are not present in this structure.

If I right click on the Start menu, I get a set of menu options that provide me with some Administrative Tool options but certainly not the comprehensive set:


I still miss the ability to customize the Start menu the way I could easily do in Windows 7 with different menus and options for Favorites, Links etc.  Maybe they will bring back those features before the RTM release of Windows 10...

In the new Taskbar, you will see a fixed search bar which allows you to search your entire computer without directly opening the Start menu:


One of the tools that ships with Windows 10 is the Snipping Tool that functions like a screen capture utility such as TechSmith SnagIt:

This tool will definitely come in handy for all those users that simply need quick and easy screen capture capabilities and don't want to go through the hassle of copying and pasting into MS Paint or MS Word to achieve this functionality.


Windows Explorer has a slightly updated and refreshed look, but it is not significantly different from what Windows Explorer looked like in Windows 8/8.1:

This new version of Windows ships with Microsoft.NET Framework v. 4.6 (as is to be expected).

In addition, the overall boot time and performance of this OS seems significantly better than any of its predecessors, but that might change as I begin to install more and more programs/applications into the OS.  Even Windows 8/8.1 booted faster than Windows 7 initially, but as soon as I began using it heavily, the performance degraded significantly just like every other Windows OS previously so I will just have to wait and see.

There are numerous Windows UserVoice feedback items about installing applications in "registry free" mode or getting rid of the Windows Registry in a manner similar to OS X, but I don't think those ideas will see the light of day with the release of Windows 10.  An idea like that would require a radical overhaul and breaking changes to all existing applications which might take several years before such an OS emerges from the Microsoft team.









Wednesday, January 28, 2015

Open source/free ASP.NET E-Commerce engines

Nowadays there are very many open source and free ASP.NET E-Commerce engines available on the web.

Some of these offerings have both open source as well as licensed versions while others are completely supported by the open source community.  In addition, some of these offerings are based on newer technologies such as ASP.NET MVC while other products are based on the older ASP.NET platform.

Here are just some of the available ASP.NET E-Commerce engines that I have found:


Free Code School access!

Code School is offering free access to numerous courses as part of its recent partnership with PluralSight.

Code School offers a different methodology of teaching/training than traditional online courses in that each module offers hands on exercises directly within the browser for you to try out as you are going through the content in the course which makes it very easy to learn any technologies that involve development/coding.

If you want to check out Code School for yourself, this free access is for just a limited time (ends this Friday 01/30/2015), so it is best to act fast!

https://www.codeschool.com/pluralsight?utm_source=pardot&utm_medium=email&utm_campaign=codeschool72_as

 

Tuesday, January 27, 2015

Windows 10 Free Upgrade for Windows 7 and Windows 8.1 Users

If you are anxiously awaiting the release of Windows 10, Microsoft has just announced even better news for the release of this new OS--it will be a FREE Upgrade!!  Woo hoo!!

You can sign up to receive an e-mail notification about this FREE Upgrade here: http://windows.microsoft.com/en-us/windows-10/about

If you want to read more about the Windows 10 Free Upgrade, you can read about it here: http://www.pcworld.com/article/2873214/windows-10-will-be-a-free-upgrade-for-windows-7-and-8-users.html

Location of SQL Server ConfigurationFile.ini

If you have installed SQL Server recently and you are looking for the ConfigurationFile.ini file, you can immediately find it at the end of the installation as shown below:





Of course, if you need this ConfigurationFile.ini file AFTER you have installed the application for another SQL Server installation, then you will need to remember where it was stored initially.

You can find the ConfigurationFile.ini file in this standard location:

C:\Program Files\Microsoft SQL Server\120\Setup Bootstrap\Log\

Since the folders are organized by date, you may have to dig around the folders to find the original folder that was created at installation time, but the ConfigurationFile.ini file should be in one of the earliest dated folders you can find in the file system.

The above location is for SQL Server 2014, but for SQL Server 2012, the folder location will be respectively:

C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\

Now when you need to perform a secondary installation of SQL Server, you can simply use that ConfigurationFile.ini file to run through your installation without having to provide any additional data in the dialogs!!

Generating a Code Signing Certificate on Windows

If you are requesting a Code Signing Certificate to sign your code such as your .NET Assemblies or your installation packages, you may see an article such as https://support.godaddy.com/help/article/7282/generating-a-certificate-signing-request-for-code-signing-certificates?locale=en

As you can tell, it is asking you to use OpenSSL in order to generate your Certificate Request and your Private Key.

However, if you are using a version of Windows that supports IIS such as Windows Server 2012 or Windows Server 2012 R2 (client OSes such as Windows 8.1 also support it), then you can generate your Code Signing Certificate directly through the IIS Management Console!

  1. Open up the IIS Management Console (inetmgr)
  2. Click on the server name
  3. In the Features view, click on Server Certificates
  4. Click on Create Certificate Request in the Actions pane
  5. Fill out the necessary information in each of the dialogs.  Make sure you set the Bit length to 2048
  6. Open up the generated CSR request text file and use that to request/order your Code Signing certificate.





Free online Microsoft Training!

If you haven't heard about or seen the Microsoft Virtual Academy website, you should definitely check it out!  It has hundreds of free online videos and training courses for Microsoft-centric content.  It even has courses which cover preparation for Microsoft Certificate exams such as the 70-480 exam!

You can check out Microsoft Virtual Academy here: http://www.microsoftvirtualacademy.com/

If you are looking specifically for preparation for the 70-480 course, you can check out that course here: http://www.microsoftvirtualacademy.com/training-courses/learn-html5-with-javascript-css3-jumpstart-training

Microsoft Fakes for all Visual Studio editions

If you have read about or heard about the Microsoft Fakes framework, you may know that it is the successor to Microsoft Pex and Moles.

Microsoft Pex and Moles was originally made freely available as a download from the Microsoft Research site.  Unfortunately, however, Microsoft Fakes was only originally included with Microsoft Visual Studio Ultimate edition.  Later on, Microsoft made a concession and included it also with Visual Studio Premium edition and above.

For most development teams that are Microsoft Partners, being restricted to Visual Studio Premium edition or above is usually OK.  However, the big problem with this restriction is that many companies are not Microsoft partners or are instead Microsoft customers which leverage Microsoft tooling to develop their own internal IT solutions.  In Offshore scenarios, this problem is even greater since very few Offshore development companies have access to Visual Studio Premium edition.  Many Offshore development companies are running on thin budgets and only have access to Visual Studio Professional edition.  Therefore, incorporating a framework such as Microsoft Fakes in a distributed development team becomes nearly impossible.

If you believe that Microsoft should make the Microsoft Fakes framework freely available as it formerly did with Microsoft Pex and Moles, you can vote for this UserVoice item here:

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/7017401-make-microsoft-fakes-free-like-pex-and-moles

Monday, January 26, 2015

Setting up PreEmptive Analytics for TFS

If you install PreEmptive Analytics for TFS on your TFS Server, that is actually only part of the solution in order to be able to instrument your applications for Analytics.

The second part of the equation involves using the Dotfuscator tool included with Visual Studio to add Analytics Attributes to your assemblies as described in this article: https://msdn.microsoft.com/en-us/magazine/jj656636.aspx

You basically need to set the following attributes on your Assemblies:
  • ApplicationAttribute
  • BusinessAttribute
  • SetupAttribute
  • TeardownAttribute
  • ExceptionTrackAttribute

Saturday, January 24, 2015

Web API with Windows Authentication

If you want to secure your ASP.NET Web API application with Windows Authentication, you simply have to add the [Authorize] attribute on all of your Web API Controllers, or else you can add the following code to your WebApiConfig.cs class:
 
config.Filters.Add(new AuthorizeAttribute());



However, if you want to pass Windows Authentication credentials from your .NET Client to Web API, you will need to do something like what is outlined in the following article:  http://www.asp.net/web-api/overview/security/integrated-windows-authentication

Of course, this does not provide any guidance on passing Windows Authentication credentials from a Web Application such as an ASP.NET MVC Client.

Fortunately, there is a way to accomplish this even from ASP.NET MVC though it is not readily obvious:




  1. First, set up your ASP.NET MVC Web Application for Windows Authentication
  2. Add an Identity Impersonation element to your Web.config
  3. In IIS, set up your ASP.NET MVC Web Application as well as your ASP.NET Web API Web Application to run in Classic Mode (rather than Integrated mode)
  4. Now when you run your code where you call your Web API Service from your ASP.NET MVC Controller, the Windows Authentication credentials will pass seamlessly between each other!

To set up identity impersonation in your Web.config file, you need to the add the following entry:



<identity impersonate="true"/>
If you forget to set your Application Pools from Integrated Mode to Classic Mode, you will get an error similar to the following:







The code to call your Web API Service from an ASP.NET MVC Controller will look like the following:



public ActionResult Index()
        {
            string webApiUrl = "http://localhost/WebAPI/";
 
            HttpClientHandler handler = new HttpClientHandler()
            {
                UseDefaultCredentials = true
            };
 
            HttpClient client = new HttpClient(handler);
 
            client.BaseAddress = new Uri(webApiUrl);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 
            // HTTP GET
            HttpResponseMessage response = client.GetAsync("api/values").Result;
 
            if (response.IsSuccessStatusCode)
            {
                var model = response.Content.ReadAsStringAsync().Result;
                ViewBag.Message = model.ToString();
            }//if
 
 
            return View();
        }

Visual Studio 2015 First Look

When you first install Visual Studio 2015, you will notice that the options for installation are much, much different than the installation options for Visual Studio 2013 today:








Most notably, you will see a greater emphasis on mobile development with the inclusion of the Tools for Apache Cordova as well as the inclusion of the Android Development tools and Android SDK.  Even more amazing is the inclusion of the Java SE Development Kit!!

Microsoft is definitely taking a much different tactic with this release of Visual Studio than they ever have with past releases of Visual Studio.

When you open the NuGet Package Manager, you will see it has a completely different look and feel than previous releases of Visual Studio:


Interestingly enough, the Extensions and Updates dialog has not received a similar face lift:




The Visual Studio Tooltip Help is significantly improved from prior releases:


Even more exciting are the Diagnostic Tools that immediately display while starting a Debugging session:


All in all, the new version of Visual Studio is turning out to be one of the most exciting releases in recent years and I am anxiously awaiting the RTM release of this brand new IDE!!

Friday, January 23, 2015

CAT5, CAT5e and CAT6 cables

I have been mainly a software developer for most of my career and I knew just enough about networking to set things up in my home office and maybe help a few friends along the way.

However, I had never done much investigation into the cabling used in Networking such as the differences in CAT5, CAT5e and CAT6 cables.  I just figured that if I was using Gigabit hardware (Gigabit routers, Gigabit switches and Gigabit network cards) I would be running a Gigabit network--right???  Wrong!!!

After I was experiencing extremely slow performance copying files from my NAS device over to my home computer I began investigating some possible solutions.  Many articles recommended checking the cabling on my network to verify I did not have any bottlenecks in my network.

In the past, I always thought that CAT5 was the standard and really didn't know anything about CAT5e nor CAT6 cables.

Well, I soon discovered that CAT5 is a reasonably old standard and should be replaced by CAT5e or CAT6 in modern networks.  Apparently, CAT5 maxes out at 100 Mbps while CAT5e or CAT6 supports 1000 Mbps (Gigabit Ethernet).

Well, according to most articles, CAT5 was such an old standard that most networks would only have CAT5e cable anyway.

In any case, I decided to look through the mess of cables in my home network and replace them all with the newer standard of CAT6 cables. 

Fortunately, one of my friends told me that I could tell what type of cable I had on my network by looking at the fine print on the cable.

Well, as I started going through and replacing all of my network cables with CAT6 cables I started reviewing all of my cables to see what type they were.  For the most part, every single cable I came across was CAT5e.

When I finally started disconnecting the final cords in my network, I found a cable that connected my Gigabit router to my Gigabit switch.  As I looked closely at the cable I discovered it was a plain old CAT5 cable!!! 

This was the bottleneck in my entire network that was causing my whole network to run at 100 Mbps rather than the full Gigabit speeds it was capable of running!!

Apparently, I had kept this cable around for many years as I was collecting cables from various networking devices I had purchased over the years.  Every router or modem ships with its own networking cable, so this cable must have come from a very old device that I had purchased long ago. 

As you can guess, once I replaced this cable my network was running smoothly, all of the lights on my Gigabit switch were lit up (2 lights indicate Gigabit, while only 1 light indicates either 10 Mbps or 100 Mbps) and my file copies from my NAS device went from 10 MB/sec to 80 MB/sec!!!  Woo hoo!!






Thursday, January 22, 2015

SQL Server 2014 Management Studio Source Control Options

In previous releases of SQL Server Management Studio (including SQL Server 2012), the option for Visual SourceSafe as a source control plug-in was offered by default (even though the last release of Visual SourceSafe was VSS 2005).

As you can tell in the latest release of SQL Server Management Studio, this issue has been rectified.





Of course, as you can tell, however, there are no plug-ins supported out-of-the-box now!!

Instead of offering Team Foundation Server support out-of-the-box, you now have to download and install any plug-ins that you want on your own to include support for them in SQL Server Management Studio.

You can download the TFS 2013 MSSCCI Providers here:



Microsoft Visual Studio Team Foundation Server 2013 MSSCCI Provider 32-bit

https://visualstudiogallery.msdn.microsoft.com/06c8e056-7f77-4a5c-9b8b-49318c143df8


Microsoft Visual Studio Team Foundation Server 2013 MSSCCI Provider 64-bit
https://visualstudiogallery.msdn.microsoft.com/22d38324-051c-4f04-9379-ff78e7116c8d


The target principal name is incorrect. Cannot generate SSPI context.

I was recently setting up a SQL Server 2014 AlwaysOn Availability Group when I got the following error message while attempting to add a Replica for the Availability Group via SSMS (SQL Server Management Studio) with Windows Authentication:






Interestingly enough, I could log into the SQL Server just fine using SQL Server Authentication, but the authentication was failing while using Windows Authentication.  Of course, for a SQL Server AlwaysOn Availability Group, I needed to use Windows Authentication, otherwise it wouldn't work!

Therefore, I did some research and it seemed that most of the issues regarding this issue dealt with problems regarding the domain.

I remembered that I had joined this particular server to the domain without first removing it from the domain.  From prior experiences, I remembered that this can cause problems if I re-join a computer to the domain with the same exact name. 

Therefore, I decided to do the following:


  1. Leave the domain by joining a workgroup and rebooting the server
  2. Deleting the computer object and all of its children (deleting the subtree) in Active Directory
  3. Re-joining the server to the domain
Once I did that, I was able to successfully log into my other SQL Server using Windows Authentication to add it as a replica for my Availability Group!

Setting up a SQL Server AlwaysOn Availability Group in Windows Azure

If you need to set up a SQL Server AlwaysOn Availability Group hosted in Windows Azure IaaS, then you will want to follow these articles:

Tutorial: AlwaysOn Availability Groups in Azure (GUI)

https://msdn.microsoft.com/en-us/library/dn249504.aspx

Tutorial: Listener Configuration for AlwaysOn Availability Groups

https://msdn.microsoft.com/en-us/library/azure/dn425027.aspx

Wednesday, January 21, 2015

Alternatives to Microsoft Fakes

If your development team is using an edition of Visual Studio lower than Visual Studio 2013 Premium Edition (such as Visual Studio 2013 Professional), you will not have access to using Microsoft Fakes.

Even if you have access to Visual Studio 2013 Premium Edition, you may not be happy with the way in which Microsoft Fakes works compared to Mocking frameworks such as Moq or Rhino Mocks.

Well, unfortunately, one of the limitations of most Mocking frameworks such as Moq or Rhino Mocks is that they can only Mock code that is derived from interfaces or have their methods/members marked as virtual.

If the code does not fit into either of these categories, then a framework such as Microsoft Fakes allows you to fill in those gaps where you do not have control of the code (such as 3rd party code or the underlying .NET Framework classes).

The problem with the way that Microsoft Fakes works, however, is that it requires "Fakes" to be generated from all of the code references that you need to Fake.  This process adds additional time to the overall build process and can differ from developer machine to developer machine which makes it very unappealing overall.  It also does not have the same readability constructs of most Mocking frameworks.

Well, fortunately, there are alternatives to using Microsoft Fakes:

  1. Telerik JustMock: http://www.telerik.com/products/mocking.aspx - This Mocking Framework is provided by Telerik who also provides a host of controls for the Visual Studio IDE.  It offers the same types of capabilities as are offered by Microsoft Fakes with the readability of standard Mocking frameworks and the requirement to generate "Fakes" files for all assembly references.
  2. TypeMock Isolator: http://www.typemock.com/ - TypeMock has been around for a number of years and has long been a choice for many developers that needed to work around the limitations of most other Mocking frameworks.
Both Telerik JustMock and TypeMock Isolator offer free versions of their Mocking libraries, however, the free versions have many of the same limitations as the free, open-source versions of Mocking frameworks such as Moq and Rhino Mocks making the free versions limited in their usefulness.

You can compare the editions yourself here:

JustMock Edition Comparison

http://www.telerik.com/justmock/free-mocking

TypeMock Isolator Edition Comparison

http://www.typemock.com/isolator-product-page




Tuesday, January 20, 2015

Unit Test Generator for Visual Studio 2013

If you used to use Visual Studio 2010 for creating Unit Tests, you may have noticed a major feature that was pulled out of Visual Studio 2012 and Visual Studio 2013 and that was the ability generate Unit Tests!

Well, fortunately, this feature was so heavily missed that Microsoft finally re-released this functionality as an extension in the Visual Studio Gallery.

You can get the Unit Test Generator extension here: https://visualstudiogallery.msdn.microsoft.com/45208924-e7b0-45df-8cff-165b505a38d7

FxCop included with Visual Studio 2013

If you have used FxCop in the past, you may have noticed that there is no longer a shipping standalone version of FxCop as there has been in the past.  Instead, FxCop is included with Visual Studio (at least Premium edition or above).

You can find FxCopCmd.exe at the following location:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe


Failed to register because the farm or partition is already registered with a workflow service

I was recently training a colleague on administering SharePoint and he was encountering issues with being unable to publish SharePoint Workflows after he applied an SSL certificate to his SharePoint site.

Well, immediately after checking his IIS bindings and his AAM settings, the next thing I thought of was that he would have to re-register his SharePoint site with the Workflow Service.

Of course, he ran the following command:

Register-SPWorkflowService -SPSite "https://spse/sites" -WorkflowHostUri "https://spse:12290" 

But he received the following error message: 
Failed to register because the farm or partition is already registered with a workflow
service


Well, fortunately, there was an easy solution to this!!  All he had to do was run the command with the -Force parameter:

 Register-SPWorkflowService -SPSite "https://spse/sites" -WorkflowHostUri "https://spse:12290" -Force

That was all that was needed to resolve his issue!! 

Monday, January 19, 2015

How to integrate StyleCop with Jetbrains TeamCity

If you want to integrate StyleCop with Jetbrains Teamcity, unfortunately, there is no built-in Runner for StyleCop in Jetbrains TeamCity, but you can use a combination of these tools in order to execute your StyleCop tasks and generate a report that can be displayed through the TeamCity Web User Interface:

  1. Download MSBuild Extension Pack from here: https://github.com/mikefourie/MSBuildExtensionPack/releases
  2. Once you have downloaded and installed MSBuild Extension Pack, if you have not already done so, download and install StyleCop:  https://stylecop.codeplex.com/
  3. You will then need to copy the MSBuild.ExtensionPack.StyleCop.dll into the StyleCop directory
  4. Download the StyleCop.xsl file from this location: https://github.com/kopelli/VICI/blob/master/tools/StyleCop/v4.4.0.12/StyleCop.xsl
  5. Within an MSBuild Target, use the MSBuild Extension Pack StyleCop Task to generate your StyleCop report.
  6. Then use the XslTransformation Task in MSBuild to transform the StyleCop XML Report file against the XSL file you downloaded, to produce an HTML Report.
  7. Use these instructions to create a Report Tab in TeamCity for your StyleCop Report: https://confluence.jetbrains.com/display/TCD8/Including+Third-Party+Reports+in+the+Build+Results 
  8. Use the TeamCity MSBuild Service Tasks to publish information about your StyleCop results such as your StyleCop Artifacts, your Report Statistics or if you want to fail the build: https://confluence.jetbrains.com/display/TCD9/MSBuild+Service+Tasks
That is all that is required to be able to publish your StyleCop results in TeamCity!

Running the StyleCop Task using the MSBuild Extension Pack

If you are attempting to use the StyleCop Task included with the MSBuild Extension Pack, you may encounter problems with executing the task due to an undocumented feature requirement for the MSBuild Extension Pack:

You need to copy the MSBuild.ExtensionPack.StyleCop.dll to the StyleCop installation directory!! (usually C:\Program Files (x86)\StyleCop 4.7)

Once you do this, you will be able to successfully execute the StyleCop Task included with MSBuild Extension Pack.

Saturday, January 17, 2015

Performing a SQL Server Repair operation

If for some reason your instance of SQL Server stops working or starts encountering problems, you might think that by running a "Repair" from the installation dialog will resolve the issue.





Unfortunately, a Repair only repairs the installation if you have all of your databases intact including the master database.  If one or more system databases such as the master database have become corrupted, a Repair operation is not really for you.

Instead, you will have to try and figure out some other method of restoring the system databases (hopefully you have system database backups) such as by running a Rebuild of the System databases such as outlined in this article: http://msdn.microsoft.com/en-us/library/dd207003.aspx


Setting up a SQL Server 2014 AlwaysOn Availability Group

I recently had a requirement to set up a SQL Server 2014 AlwaysOn Availability Group for a customer and so I decided to follow this article since it says "Step-By-Step":

http://blogs.technet.com/b/canitpro/archive/2013/08/20/step-by-step-creating-a-sql-server-2012-alwayson-availability-group.aspx

Unfortunately, it leaves out a lot of steps!!

Therefore, I encountered numerous error messages throughout the entire installation process which required reading through numerous other articles.  One of the biggest roadblocks to beginning the installation was missing a comprehensive set of system requirements/prerequisites before getting started with the configuration.

Here is a list of some of the requirements before getting started with SQL AlwaysOn High Availability:

  1. 2 SQL Server Enterprise edition installations
  2. 2 identical Windows Servers running Windows Server 2012 or preferably Windows Server 2012 R2
  3. 1 or more Windows Servers to host your Windows File Shares needed for SQL AlwaysOn HA
  4. 4 available IP Addresses (2 for each SQL Server installation, 1 to host the Windows Failover Cluster and 1 for the SQL Server Availability Group Listener). 
  5. 2 File Shares hosted on computers other than the 2 SQL Server installations.  (1 to host the Windows Failover Cluster Share and 1 to host the SQL Server HA File Share)
  6. Running the SQL Server Service Accounts using a Domain account rather than the standard MSSQL account.
  7. Permissions on Active Directory to create Computer objects.
  8. Turning on the Remote Registry service on both computers
  9. Turning off the Windows Firewall or making exceptions for the Remote Registry/Remote Administration service to be allowed so that both computers on the Windows Failover Cluster can communicate with each other.   
  10. Make sure that all of your databases are in Full Recovery mode and have had recent backups before they can be added to the AlwaysOn configuration.
One of the first error messages that I encountered while setting up SQL AlwaysOn was the error outlined in this article: http://askadba.blogspot.com/2012/08/quorum-error-when-creating-alwayson.html

This required me to turn off the AlwaysOn setting in SQL Server for both servers and then re-enable them.

The next issue that I encountered prevented me from connecting to the file share and threw a Remote Registry error.

This required me to turn on the Remote Registry service and turn off the Windows Firewall.

The next error indicated that I did not have Administrative privileges on the cluster: http://www.powershell.co.uk/you-do-not-have-administrative-privileges-on-the-cluster/

The next error indicated that I had to remove any local groups from the cluster privileges: http://technet.microsoft.com/en-us/library/cc959947.aspx

This required me to grant Full Control privileges in the Cluster Properties and remove all local users and groups.

The next problem I encountered was a problem with configuring the File Share Witness: http://www.dbaglobe.com/2014/07/fix-issue-when-configuring-file-share.html

This required me to ensure that I had sufficient security privileges on the File Share from both servers.

The final problem indicated that I could not create the Cluster group listener: http://blogs.msdn.com/b/alwaysonpro/archive/2014/03/25/create-listener-fails-with-message-the-wsfc-cluster-could-not-bring-the-network-name-resource-online.aspx

I had to change the permissions in Active Directory and make sure that I had a 4th IP Address available to assign to the Cluster Group Listener.

Installing SQL Server from a Configuration File

When you install SQL Server, you can either create a brand new configuration file by specifying the settings that you want to use for installation and then exiting the installation or you can use the ConfigurationFile.ini file that is generated from an existing installation of SQL Server.

Once you have the ConfigurationFile.ini file available, you can then use the following command to execute your SQL Server installation against the values stored in your configuration file:

Setup.exe /ConfigurationFile=<Your File Path>\ConfigurationFile.ini

Of course, when you run this command, what this essentially does is pre-populate all of the dialogs for you with all of your selections.  Since you are not using a /Q  or /QS switch to perform the installation, the configuration file just saves you the steps of having to re-select all of your options in the installation dialog thus speeding up the overall installation process and ensuring that multiple installations of SQL Server all follow the same installation pattern.

If you want to achieve a truly quiet/silent installation, you will have to provide all of the necessary parameters either in the ConfigurationFile.ini file or at the command line to ensure the installation does not prompt you for any missing parameters.

You can read more about how to perform a SQL Server installation with a configuration file here:  

Install SQL Server 2014 Using a Configuration File


Install SQL Server 2014 from the Command Prompt

Friday, January 16, 2015

Upgrading from Entity Framework 5 to Entity Framework 6

I have some applications that I have been developing for a few years that have been using Entity Framework 5 so I decided to finally refresh them and update/upgrade them to using Entity Framework 6.

Well, fortunately, the upgrade was relatively painless.

Whereas in Entity Framework v. 5.0, I had the following namespaces:

using System.Data.EntityClient;
using System.Data.Objects;


I simply had to change these to the following for Entity Framework v. 6.0:

using System.Data.Entity.Core.EntityClient;
using System.Data.Entity.Core.Objects;


That was pretty much all there was to it!!

Wednesday, January 14, 2015

Configuring IIS for Sitefinity

If you are hosting your Sitefinity website on IIS 7 or above, there are a slew of configuration changes you have to make to IIS in order to be able to properly host Sitefinity without any IIS error messages.

Fortunately, the Sitefinity team has provided a set of PowerShell scripts that you can download from the "Automatic Configuration" section on their Sitefinity Documentation page:  http://docs.sitefinity.com/configure-the-iis-to-host-sitefinity-projects

I ran the required PowerShell scripts for my installation of IIS (IIS 8.5) and all of the error messages that I was encountering suddenly went away!  Yippee!!

Software Licensing solutions for Microsoft.NET

If you are looking at Software Licensing solutions for your Microsoft.NET Applications, there are 4 major vendors that deal with Software Licensing:

  1. Inishtech - http://www.inishtech.com/
  2. Nalpeiron - http://www.nalpeiron.com/
  3. Flexera Software - http://www.flexerasoftware.com/producer/products/software-monetization/flexnet-licensing/tab/requirements
  4. SafeNet - http://www.safenet-inc.com/software-monetization/software-protection/
  5. Crypkey - http://www.crypkey.com/index.html

Of course, all of the licensing solutions are very expensive, so if you decide to choose one of these solutions, you need to allocate for it in your budget accordingly.

There are numerous cheaper licensing solutions out there as well such as ElecKey - http://www.sciensoft.com/, however, I was looking at their documentation and their documentation, tools and examples are extremely outdated (numerous references and examples are found still referring to Visual Studio 2008).  In addition, I e-mailed them numerous times and I never received a reply back from their support staff.  Therefore, the solution may be cheaper, but you may need to be more reliant on supporting the application yourself rather than expecting good vendor support.

Installation of KeyCheck.NET component for Visual Studio 2013

If you are evaluating or currently using the KeyCheck.NET Component from ElecKey: http://www.sciensoft.com/products/eleckey/, you will notice that the installation instructions for the KeyCheck.NET component still indicate that you have to run the Visual Studio 2005 or Visual Studio 2008 batch file to install the integration for Visual Studio!

Well, if you are like me, you have probably stopped using either of these IDEs years ago and have moved on to the latest and greatest release of Visual Studio 2013!

Fortunately, the batch files can be easily modified to support Visual Studio 2013 by simply changing the line to the following in the Inst_VS2008.bat file:

Tbinst -install KeyCheck Ekc.Comp.dll VisualStudio.DTE.12.0

However, after running the batch file, the installation will only add the KeyCheck section to your Toolbox.

It is still up to you to drag and drop the Ekc.Comp.dll into that section of the Toolbox to be able to use it in your applications.

That is all there is to it!!


Project Rename capabilities coming to TFS 2015!

One of the long desired features for Team Foundation Server has been the ability to rename projects.  Unfortunately, since the 1st release of TFS, this feature support has not been added.

However, with the release of TFS 2015, this feature is currently planned to be added to the release!

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2037605-rename-project-in-tfs

I look forward to see what other new features they are planning to add to TFS 2015!

Tuesday, January 13, 2015

Method Not Allowed error publishing to a Private NuGet Repository

I had recently set up a Private NuGet Repository and when I was attempting to publish my package via Package Explorer, I got the error message "Method Not Allowed".

Well, after doing a bit of digging, I discovered that it was a problem with my IIS Settings and I that I needed to remove WebDAV from my IIS Module and Handler mappings.
 
I could either do that manually from the IIS Management Console or simply add the following entries to my Web.config file:
 
<system.webServer>
    <modules>
        <remove name="WebDAVModule" />
    </modules>
    <handlers>
        <remove name="WebDAV" />
    </handlers>
</system.webServer>


Once I did that, I was able to successfully publish my NuGet packages!

Setting up Project Katana to host ASP.NET Web API in IIS

If you have been reading about Project Katana, you have probably come across these articles: http://www.asp.net/aspnet/overview/owin-and-katana/an-overview-of-project-katana

http://www.asp.net/aspnet/overview/owin-and-katana/getting-started-with-owin-and-katana

http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api

However, the problem with all of these articles is that it demonstrates how Katana can be used to Self Host ASP.NET Web API in a Console Application but provides very little information on how Katana can be used to provide standard OWIN pipeline hosting of ASP.NET Web API in IIS!!

Well, here is some clarification on how to set up a Katana Web Application:

  1. Create an Empty ASP.NET Web Application
  2. Add a NuGet package for Microsoft.Owin.Host.SystemWeb and Microsoft ASP.NET Web API 2.2 OWIN
  3. Add an OWIN Startup Class to your project
  4. Add the necessary code to the Configuration method of the Startup class.  This code will basically be a duplicate of the WebApiConfig.cs file that are normally found in ASP.NET Web API projects with the addition of the Katana specific project code.
  5. Add any references to Web API Class Libraries.
  6. Run your Katana Web Application Host and verify that you can access the required Web API Urls.






Below is the code for the Startup.cs file:

using System;

using System.Threading.Tasks;

using Microsoft.Owin;

using Owin;

using System.Web.Http;

 

[assembly: OwinStartup(typeof(KatanaHost.Startup))]

 

namespace KatanaHost

{

    public class Startup

    {

        public void Configuration(IAppBuilder app)

        {

            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888

            var config = new HttpConfiguration();

 

            // Web API routes

            config.MapHttpAttributeRoutes();

 

            config.Routes.MapHttpRoute(

                name: "DefaultApi",

                routeTemplate: "api/{controller}/{id}",

                defaults: new { id = RouteParameter.Optional }

            );

 

            app.UseWebApi(config);

        }

    }

}
 
 
 

Setting up an ASP.NET Web API Web Host

If you are creating several ASP.NET Web API Class Libraries and you want to host them in a Web Host (i.e IIS), then you can create a separate ASP.NET Web API Web Host project.

Of course, the easiest way to do this is to create a standard ASP.NET Web API Web Application project since it already supports the Web API Web Host libraries.

However, if you want to create your own customized ASP.NET Web Host project without the unnecessary folder structure from Web API and MVC, you can do the following:

  1. Create an empty ASP.NET Web Application
  2. Add a NuGet package for Microsoft ASP.NET Web API Web Host
  3. Add any necessary folders to run your ASP.NET Web API project such as your Global.asax file, App_Start folder etc.  
  4. Since most of your Controllers are probably residing in your ASP.NET Web API Class Libraries, you will not need to create any Web API Controllers in the Controllers folder and instead only use these Controllers for ASP.NET MVC Views that you want to display (such as for authentication against your Web API)
  5. Verify that you can now access all of your ASP.NET Web API Controllers from your Web Host.  If so, then your project is working correctly!  



Creating an ASP.NET Web API Class Library project

If you read about Project Katana and ASP.NET Web API on the Internet, you may see references on creating an ASP.NET Web API project as a Class Library, but there is very little guidance on how to create a Class Library project in this manner.

Fortunately, it is relatively easy to accomplish:

  1. Create a Class Library project
  2. Add a NuGet Package for Microsoft ASP.NET Web API 2.2 Core Libraries
  3. If you want to get all of the context menu actions that you would normally get in an ASP.NET Web API project, edit the project and add the following Project Type Guids:   <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> 
  4. Unfortunately, because it is a Class Library project, you will have to add the necessary folder structure yourself, but you can copy the required folder structure from an existing ASP.NET Web API project. to replicate it.
That is all there is to it!  Now you will have a Class Library project that can be hosted in a standard ASP.NET Web API  Web Host project.




Microsoft Second Shot is back!

For those of you interested in upgrading your existing Microsoft certifications but were afraid to take it without the cushion/buffer of a 2nd shot, you can breathe a sigh of relief!

Microsoft Second Shot is back!  If you fail at your first attempt at a Microsoft certification exam, you can take your second attempt for FREE!

You can sign up for the Microsoft Second Shot exam here: https://www.microsoft.com/learning/en-us/second-shot.aspx

Here are the list of Certification Exams eligible for Microsoft Second Shot: https://www.microsoft.com/learning/en-us/exam-list.aspx

Hosting your own NuGet Server using Visual Studio 2013

If you want to host your own NuGet Server, you can follow this article:  http://docs.nuget.org/docs/creating-packages/hosting-your-own-nuget-feeds

However, as you can probably tell, this article has not been updated in quite a while since it still references screenshots from Visual Studio 2010.

Well, with Visual Studio 2013, the steps are largely the same, however, the screenshots will be different.

Below are the screenshots for setting up a NuGet Server using Visual Studio 2013:








Monday, January 12, 2015

Zendesk integration with Visual Studio Online

If you currently use Zendesk as your Help Desk and Ticketing Management solution and use TFS as your source control repository, you can integrate Zendesk with TFS as outlined here:

http://www.visualstudio.com/en-us/zendesk-and-vso-vs.aspx

Unfortunately, as you can tell from the article, this will only work if you are using the cloud version of TFS (Visual Studio Online).

If you are using an on-premise installation of TFS, unfortunately, you are still out-of-luck for the time being, but you can make your voice heard by voting for this item on the Microsoft UserVoice site to let Microsoft know that you want this feature included in a future release of the on-premise version of TFS: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2266913-integrate-tfs-with-zendesk

Hosting Silverlight in an ASP.NET MVC Web Application

As many Silverlight developers are aware, it is a common practice to host Silverlight in an ASP.NET Web Forms application, but what about if you want to host the application in an ASP.NET MVC Web Application?

Well, if you do some searching on the Internet, it seems there are articles such as this one which indicate that Visual Studio supports hosting Silverlight in an ASP.NET MVC Web Application: http://timheuer.com/blog/archive/2009/02/09/silverlight-as-a-view-in-aspnet-mvc.aspx

However, if you are using a recent version of Visual Studio such as Visual Studio 2013, you will not see such an option:


So it seems that Microsoft has removed the capability to host Silverlight applications in ASP.NET MVC!!

Therefore, if you are like me and would like Microsoft to bring back this feature and capability, you can vote on this UserVoice item here:

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6953798-bring-back-hosting-of-silverlight-in-asp-net-mvc



Saturday, January 10, 2015

Setting up Active Directory Lightweight Directory Services

If you have a need for using some capabilities of Active Directory within your application but do not want to have to set up a Domain Controller every time that you want to set up your application (especially in a multi-tenant hosting environment), then Active Directory Lightweight Directory Services (ADLDS) is probably for you!!

For an overview of ADLDS, you can read here: http://technet.microsoft.com/en-us/library/cc754361.aspx

For additional details about how to set up and install ADLDS, you can read here: http://technet.microsoft.com/en-us/library/cc770639%28v=ws.10%29.aspx

Below are screenshots on how to install and configure ADLDS on Windows Server 2012 R2:





















Of course, if you accidentally make a mistake while creating your instance of ADLDS, you can easily remove it by simply uninstalling it via Add/Remove Programs: http://technet.microsoft.com/en-us/library/cc794886%28v=ws.10%29.aspx