Skip to main content

Posts

Showing posts from May, 2013

LayoutIt!: A drag & drop interface builder for Bootstrap

Bootstrap is a great framework for building good looking and powerful websites. However in the hands of developers, most Bootstrap sites end up looking the same. Enter LayoutIt! , a drag & drop interface builder that let you easily design your own sites by using the Bootstrap functionality. It allows you to drag & drop your template together and download the required HTML, CSS, LESS and JavaScript afterwards.

Microsoft Code Digger

Microsoft Research released their first extension for Visual Studio 2012: Code Digger . Code Digger analyzes possible execution paths through your .NET code. The result is a table where each row shows a unique behavior of your code. The table helps you understand the behavior of the code, and it may also uncover hidden bugs. Through the new context menu item " Generate Inputs / Outputs Table " in the Visual Studio editor, you can invoke Code Digger to analyze your code. Code Digger computes and displays input-output pairs. Code Digger systematically hunts for bugs, exceptions, and assertion failures. You can also try the functionality online through Pex4Fun . Remark: At the moment Code Digger only works on public .NET code that resides in Portable Class Libraries. This limits its usefulness at the moment.

Reporting Services error: Unable to load client print control

Last week, our users send us a bug report mentioning that they cannot print a reporting services report from the web browser. We discovered that printing from the ASP.NET Report Viewer control requires a separate ActiveX to be installed. If you don’t have this ActiveX control installed and the users don’t have the rights to install the ActiveX control themselves, they end up with the following error message: “Unable to load client print control” The browser will ask you to install the required ActiveX control to solve this problem: Remark: Because the printing is using an ActiveX control, you can only print Reporting Services reports from Internet Explorer. If you open the ASP.NET reportviewer in FireFox or Chrome, the print button will not be available.

Get rid of the ‘Missing XML comment for publicly visible type or member’ warning

For a long time, I had the (good?) habit to document all my public API’s. But keeping the documentation up-to-date has always been a long and boring task. After a discussion with my fellow developers, I decided to stop adding documentation. Most developers said they don’t look at the documentation but just read the code or  have a look at my unit tests to understand what’s going on. After removing all the documentation, I’m left with a long list of warnings inside my application complaining about ‘Missing XML comment for publicly visible type or member’ .  How to remove these warnings? There are 2 ways to remove these warnings: Turn off the comment generation: Go to the Project properties(Right click on your project and choose Properties from the context menu) Go to the Build tab Uncheck the XML documentation file checkbox Repeat this for every project in your solution Disable the warning: Go to the Project propert

PostMan: an easy-to-use REST client to test all your Web API’s

  PostMan is a REST client available as a  Chrome application. It’s a very easy-to-use and developer friendly tool to test and try your Web API’s. You have lots of options to manipulate the request and it has integrated support for multiple authentication mechanisms.  Download it here .     Features Create requests quickly Compact layout HTTP requests with file upload support Formatted API responses for JSON and XML Open responses as an HTML file in a new window HATEOAS support Image previews Request history Basic and OAuth 1.0 helpers Autocomplete for URL and header values Key/value editors for adding parameters or header values. Works for URL parameters too. Use environment variables to easily shift between settings. Great for testing production, staging or local setups. Use Global variables for values which are common throughout APIs Use the quick look feat

UnitTestIsolationException when using ReSharper

In a previous post I introduced the Microsoft Fakes framework. However when I tried to use this framework inside my tests, they always failed with the following message: Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: UnitTestIsolation instrumentation failed to initialize. Please restart Visual Studio and rerun this test   I discovered that it failed because I was running my tests through the ReSharper test plugin. When I used the Visual Studio Test runner instead, everything worked fine… Anyone who knows how I can get this working using ReSharper?

Visual Studio 2012: Testing the untestable using Microsoft Fakes

Testing the untestable To test your code in isolation, Mocking frameworks like RhinoMocks or Moq are an important tool in your toolbox. By using an isolation(mocking) tool, you can replace an existing object by a ‘fake’ implementation. Unfortunately these tools cannot help you solve everything. If your system is not designed with testing in mind, it can be very hard or even impossible to replace an existing implementation with a mock object. Let’s for example take DateTime.Now .  This is a static property on a static class, how are you going to replace this? Let’s have a look how Microsoft Fakes , the isolation framework that Microsoft introduced in Visual Studio 2012. Microsoft Fakes Microsoft Fakes help you isolate the code you are testing by replacing other parts of the application with stubs or shims. A stub replaces another class with a small substitute that implements the same interface. To use stubs, you have to design your application so that each compo

Xamarin Objective Sharpie: a binding definition generator for third party Objective C libraries

Xamarin iOS allows you to consume a third-party Objective-C library. Before you had to use Xamarin.iOS's Binding Projects to create a C# binding to the native Objective-C libraries. Inside this Binding project you’ll find two files: ApiDefinition.cs and StructsAndEnums.cs. The ApiDefinition.cs is where you will define the API contract, this is the file that describes how the underlying Objective-C API is projected into C#. The StructsAndEnums.cs file is the file where you will enter any definitions that are required by the interfaces and delegates. To bind your library you will have to create C# interfaces and annotate these interfaces with attributes to map the C# interface to the corresponding Objective-C class. Although it’s not too hard to do this, expect a lot of work for a moderate size  Objective-C library. To make this job easier, Xamarin introduced a new tool: Objective Sharpie , a very powerful binding definition generator for third party Objective C libraries

Nice quote

“There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies.” - C.A.R. Hoare

Specify a CDN fallback when using ASP.NET Web Optimizations

One of the recommendations to improve your web application performance is to use a CDN(Content Delivery Network). This allows you to load common files(like for example jQuery) from the CDN server instead of your own. Extra advantage is that if the user already loaded the same script for another site, it’s still available in the browser cache. But what if the CDN you’re using goes down? To fix this you can use a CDN fallback. For more details I recommend reading Scott Hanselmans post on the subject. The ASP.NET team added a CDN fallback feature to the latest (prerelease) version of the ASP.NET Web Optimizations library . To use it, specify a CdnFallBackExpression .  This expression will be checked and if the expression fails, the fallback URL will be used(a local reference to jQuery in this sample):

Team Foundation Server 2012: create a direct link to a work item

Team Foundation Server always allowed you to directly browse to a specific work item by calling a very specific URL. In Team Foundation Server 2012, this URL has changed to http://tfsservername:8080/tfs/web/wi.aspx?pcguid={collectionguid}&id={workitemid} Replace the {workitemid} part by the id of the work item and the {collectionguid} part by the GUID of your TFS collection. How to get this collection GUID? The easiest way to know the collection GUID(without querying the TFS configuration database directly) is to follow the steps below: Open Team Explorer Connect to the TFS collection you want to use Open a work item in this collection(doesn’t matter which one) Right click on the work item and choose Copy Full Path   Paste the path into notepad and you’ll find the correct GUID

Entity Framework: Explicit Loading

One of the features that Entity Framework offers is Explicit Loading. This allows you to lazily load related entities, even with lazy loading disabled. The only difference is that you need a explicit call to do it(by using the Load method on the related entity’s entry): But what if you want to filter the child results you get back. For example, imagine that you only want to know the female students in your class(no idea why you would want to know this )  Let’s try to change our code to do this: However if we look at the results we get back, it still contains all students. To enable filtering when using explicit loading, you’ll have to make sure that LazyLoading is disabled. If we change the code to incorporate this, it will work as expected:

SQL Server: see which users are connected to your database

There are multiple ways to see which users are connected to your SQL Server database. Probably the easiest way is to use the built in stored procedure called sp_who2 . To use it, execute the following steps: Open SQL Server Management Studio Connect to the database server you want to monitor Click on the New Query button to open the SQL editor Paste the sp_who2 command in the SQL Editor Click Execute In the results window you’ll find a list of logins, database names, status, command, program name, CPU time, Login time and so on.

Team Foundation Server 2012: Work item link type end '' does not exist

After upgrading a customers TFS environment to Team Foundation Server 2012(Update 2), some minor issues were found. One of the more interesting issues was the following one: When opening the Team Foundation Server Web Access, a specific work item query always failed with the following JavaScript error: Work item link type end '' does not exist.TFS.WorkItemTracking.LinkTypeEndDoesNotExistException: Work item link type end '' does not exist.    at findLinkTypeEnd ( http://servername:8080/tfs/_static/tfs/11/_scripts/TFS/TFS.WorkItemTracking.min.js?__loc=en-US:4:28677)    at getColumnValue ( http://servername:8080/tfs/_static/tfs/11/_scripts/TFS/TFS.WorkItemTracking.Controls.Query.min.js?__loc=en-US:4:30154)    at getColumnText ( http://servername:8080/tfs/_static/tfs/11/_scripts/TFS/TFS.UI.Controls.Grids.min.js?__loc=en-US:4:12128)    at _drawCell ( http://servername:8080/tfs/_static/tfs/11/_scripts/TFS/TFS.UI.Controls.Grids.min.js?__loc=en-U

Useful PowerShell scripts for SharePoint

While converting and merging some SharePoint sites, I created some PowerShell scripts to speed up the process. In case I’ll ever need them again, I post them here: Script 1: Mount a Content database using PowerShell Script 2: Generate a sub site using PowerShell Script 3: Generate a Document Library using PowerShell Script 4: Remove a site collection(without asking for confirmation) using PowerShell

Generate SQL script from Entity Framework Migrations

By default when using Entity Framework Migrations , the Update-Database PowerShell script will immediately apply your changes to your target databases. But what if you just want to generate a SQL script (to give it to your DBA for example)? To do this run the Update-Database command in the Package Manager Console but this time specify the –Script flag so that changes are written to a script rather than applied. Also specify a source and target migration to generate the script for. Update-Database -Script -SourceMigration: $InitialDatabase   Some remarks: If you don’t specify a target migration, Migrations will use the latest migration as the target. If you don't specify a source migrations, Migrations will use the current state of the database. If you want to create a script from the initial state to the latest migration, use $InitialDatabase as the SourceMigration value. Code First Migrations will run the migration pipeline but instead of actually a

SharePoint 2013: “You may be trying to access this site from a secured browser on the server. Please enable scripts and reload this page.”

When I tried to open a Microsoft SharePoint Server 2013 site, not much happened. Instead I got the following error message: “You may be trying to access this site from a secured browser on the server. Please enable scripts and reload this page.” To resolve this problem, enable the JavaScript feature in Internet Explorer. To do this, follow these steps: Open Internet Explorer, go to the SharePoint Server 2013 site, press Alt to reveal the Menu bar, click Tools , and then click Internet Options . On the Security tab, click Custom level . Scroll down to the Active scripting section, and then select Enable . More details at http://support.microsoft.com/kb/2752584

Users can’t login after migrating to SharePoint 2013

After migrating our TFS SharePoint Portal to SharePoint 2013, our users started to complain that they couldn’t login. However when I took a look at the different site permissions, everything looked fine. All users were there as expected… Why can’t users login? This is caused by the new Claims based model in SharePoint 2013. In SharePoint 2010 you still had the choice between claims and the classic security model. in SharePoint 2013 this is no longer the case and therefore  you have to upgrade your users to their claims alternative. As long as you don’t do this, users will not be able to access your sites. To fix this, open the SharePoint PowerShell command line and execute the following script:

Enterprise Library 6 finally arrived

After a long silence, Microsoft Patterns & Practices finally released Enterprise Library 6 . Main goals of the team for this release were: Simplifying the library all around Embracing semantic logging Increasing resiliency to errors Enhancing Unity type registration Supporting Windows Store apps (Unity, Topaz) Streamlining programmatic configuration of all blocks Integrating with other technologies ( ASP.NET MVC and ASP.NET Web API ) Improving ease of learning , ease of experimentation (fast start), and ease of use This release introduces one new application block: the Semantic Logging Application Block. It also contains some updates for the other application blocks and introduces a new programmatic configuration model(in case you don’t like large XML configuration files). This release also means the end of some of the existing application blocks: Caching Application Block Cryptography Application Block Security Applicatio