Skip to main content

Posts

Showing posts from June, 2012

Visual Studio 2010 Web Deploy improvements

Microsoft announced some important improvements in the Visual Studio 2012 Web Deploy . I noticed that when you install the new Windows Azure SDK for Visual Studio 2010 , you will also get the same updates for the Visual Studio 2010 Web Publishing Experience. These updates include some of the following  features: Updated Web Publish dialog Support to import publish profiles ( .publishSettings files ) Support to configure EF Code First migrations during publish Support to create web packages in the publish dialog Publish profiles now a part of the project and stored in version control by default Publish profiles are now MSBuild files Profile specific web.config transforms After installing the SDK, you get a new Publish dialog: You can now import a .publishsettings file(provided by many web host sites and by Windows Azure) and you can also manage your publish profiles. One of the things I like the most is that these publish profiles are now st...

TFS: Automatically exclude from Source Control

When you try to add items to TFSsource control, it automatically excludes certain folders and files: But what if you want to change the default list of excluded folders and files? In Visual Studio 2010 you can do this by changing the following two registry keys: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\TeamFoundation\SourceControl\AddOptions\ExcludeMasks HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\TeamFoundation\SourceControl\AddOptions\ExcludeMasks Add or remove some items from the list separated by a semicolon. Next time you’ll open Visual Studio, the list will be changed.

Coolest OneNote feature EVER: search text in images

Last week at Community Day 2012 , in his session Little productivity tools every professional developer should know about , Dennis Doomen shared a great tip about one of the cool features inside OneNote.  OneNote automatically does an OCR scan on anything you inserted into OneNote. Right-clicking on any picture or screenshot you inserted. Select “Make Text in Image Searchable” and then make sure the correct language is selected. Now, you can copy text from the Picture. Simply right-click on the picture, and select “Copy Text from Picture”. To make this even cooler, OneNote will index all OCR results and make them available through the search function.  Simply enter your search query in the search box on top right, and OneNote will automatically find all instances of that term in all of your notebooks. It even highlights the search term in the image! Thanks Dennis for the great tips!

Testing for Continuous Delivery

The Microsoft Patterns & Practices team released a new document about ‘Testing for Continuous Delivery with Visual Studio 2012 RC’ . “This guide describes how testing has been changing over the years and how the testing infrastructure you can build with Visual Studio 2012 RC will help you achieve continuous delivery of your software projects. This guide provides an end-to-end walkthrough of the testing scenarios supported by the Visual Studio 2012 RC infrastructure. It will help testers and developers use Team Foundation Server effectively as an application lifecycle management solution for testing and supporting products. This guide helps you Understand how testing is changing with the new tools available to testers. Set up the testing infrastructure. Use the tools for unit testing. Understand how the lab environment works and how it supports a project. Understand the power of the manual testing tools. Learn to use the tools for auto...

NHibernate error: Possible non-threadsafe access to the session

The moment you think you’ve seen all possible NHibernate errors, a new one pops up . A colleague asked me to have a look at a query he created using the QueryOver syntax. But instead of getting the correct results, the query failed with the following error message: “Possible non-threadsafe access to the session.” I was 100% sure that we were working on a single thread, so I had no idea what caused this error. Even stranger is that when I switched from an  IStatelessSession to a normal ISession, the error disappeared… The NHibernate JIRA brought the solution: In a stateless session, queries load objects in a two-phase process: in the first phase, a temporary persistence context is populated with empty objects; in the second phase, the objects' member data is read from the database. If an object contains an association or a collection, the query performs a recursive call to the session's get() method. This clears the temporary persistence context. If the p...

Waterfall neither works for User Interface design

For a recent project we hired a design agency to help us create and design an attractive user interface for our users. So after some meetings with our end users, a few weeks of designer magic, the big moment was there, they going to present us ‘THE DESIGN’. So I entered the meeting full of anticipation, eager to learn about the cool things the designers have created. So after a few PowerPoint slides, we got to see nicely designed and polished screens of our user interface, followed by the obvious question; “And guys, what do you think?”. There wasn’t much we could say, it certainly looked nice and the whole design was finished. But it doesn’t seem there was much room left for discussion or change. After leaving the meeting, I didn’t feel satisfied. Although the result looked good, something was missing… Last week at NDC I had to think again about this meeting when I was following the Creating User Experiences: Unlocking the Invisible Cage session by Billy Hollis. In this sessi...

Git(hub) for .NET developers

If you missed our session at Community Day 2012 or you want to get the slides, I’ve uploaded the presentation to Slideshare. I want to thank Gill and co for the speaking opportunity and Kristof Mattei to help me making this a great session! Git(hub) for windows developers View more presentations from bwullems .

Optimize the performance of your web applications: Don’t use runAllManagedModulesForAllRequests="true”.

In a lot of web applications I’ve seen (and created myself), the runAllManagedModulesForAllRequests is set to true inside the web.config . In a lot of articles, blog posts and so on… this is mentioned as a good idea. It’s even a default when you create a new ASP. NET MVC application.  However last week I was listening to a Hanselminutes podcast with Nathanael Jones where they said that this was really a bad idea and had a negative impact on the overall performance of your web application. <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> Running these modules for all your dynamic content is fine. However doing the same thing for all your static content  is pure overhead and offers no benefits. All your registered HTTP modules run on every request, not just managed requests (e.g. .aspx). This means modules will run on every .jpg,...

dotTrace Memory profiler keeps connecting.

To investigate a memory leak in one of my applications, I'm trying to use  JetBrains dotTRACE Memory profiler . I specified the url of my web application and started a profiling session. But all I got was the following screen: But no luck… instead dotTrace keeps showing ‘Connecting’ but the Mark Memory and Dump Memory buttons never become enabled. I had no idea why this didn’t work. In the end I noticed that dotTrace Memory 3.5 has a x64 and x32 version. And I had installed the 32bit version on my 64bit machine. After removing the 32bit version and installing the 64bit version instead, the "Connecting" got away and I finally was able to trace my application.

RavenDB: accessing a specific database using the HTTP API

RavenDB offers the following options to access it: .NET Client API: The Client API allows easy access to it from any .NET language. The .NET Client API exposes all aspects of the RavenDB server to your application in a seamless manner. HTTP API: RavenDB provides an HTTP API for accessing and manipulating data on the server. This API sits next to the C# Client API, providing most of the same functionality, but with a platform agnostic, web friendly interface. Using the HTTP API, it's possible to write a fully functioning RavenDB application using just Javascript and HTML. For a demo application I’m building I wanted to use the HTTP API but I only had one problem, what’s the correct URL to access data in a specific RavenDB database? To access data(e.g. docs) in the default database, you can use: curl -X GET http://localhost:8080/docs/locations/1 But I created a specific database instance, what’s the impact on the URL? After some trial and error I discovered that the synta...

VS 20120 RC ALM Virtual Machine

Microsoft released an update of the Visual Studio 2012 RC ALM Virtual Machine . This is the fastest way to understand what is new for application lifecycle management in this release.  This virtual machine is pre-configured with all of the necessary software and sample data for you. It includes 18 hands-on-labs / demo scripts. 6 of these were upgraded from the Visual Studio 11 ALM virtual machine, 11 of these were upgraded from the older Visual Studio 2010 ALM virtual machine, and one is brand new, highlighting the PreEmptive Analytics integration in Team Foundation Server 2012.

Searching TFS work items in Visual Studio 2010

Looking for a way to search work items in Visual Studio 2010? Check out the Search Work Items addin . “This plugin for Team System puts a little search box right into Visual Studio to make it easy to find work items. It is an addin for Team Foundation Client (Team Explorer) and is accessible from the Team menu when you're connected to a Team Foundation Server and is also available from a VS Toolbar. You just type in some search text and it runs a work item query for you showing you results across the work item store, or enter a work item ID to immediately open a specific work item.”   After installing it, a work item search box is added to the Visual Studio toolbar.   Enter a search term,hit [ENTER] and a work item query is invoked behind the scenes. By default the query will search for results inside the Title, History, and Description fields of your work items. If you want to modify which work item fields are searchable, type in "--template" (no qu...

IIS: Management Service Delegation not visible

Today I was configuring our new production environment to enable Automating Deployment with Microsoft Web Deploy . The problem was that I couldn’t find the the Management Service Delegation icon on my Windows Server 2008 R2 server. Luckily, the IIS forums brought me the solution. It seems that when you install Web Deploy using the Web Platform Installer, not all features are available. So I went back to the download page but this time I select the x64 link instead of clicking on the big Install button. After downloading the package I chose to change my installation. The IIS 7 Deployment Handler and Management Service Delegation UI were shown as not being installed. So I checked this features and continued the installation. After reloading the IIS manager, the Management Service Delegation was finally there.

Learn by doing: Linq koans

You want to learn Linq, or increase your knowledge about it. Let’s introduce Linq koans . It allows you to learn LINQ by doing. Based on unit tests, you scroll down the class, fixing each test.(You have to replace the ‘___’ with the correct value. Koans allow you to 'try out' aspects of a language while working in the language. In these koans, you just download the project, unzip it and open it in VS2010. Work with source the files in the following order: 1) LinqSynax.cs 2) LinqLambdaSyntax.cs 3) ExtendedLinqLamdbaSyntax.cs As you change the blank (variable) to the correct answer and get the tests to pass, be sure to ask yourself after you get a green bar for each method, 'What did I just learn?' A sample test: [TestMethod] public void LinqResults() { Microwavable result = (from x in ObjectsInMicrowave where x.Name == "Ping Pong Ball" select x).First(); Assert.AreEqual(___, result.Name); }

JSON to C#

With the increased interested and usage of web(or REST) API’s, sooner or later you’ll have to consume an external JSON-producing service. As a C# developer  it's nice to have locally-defined static types that you can code against. But writing all these classes that match the JSON data is a boring and cumbersome task. Let’s introduce json2csharp This tool will takeover this task and generates C# classes from JSON for you. How to use it? Type or paste a JSON string or a URL that produces JSON into the large text area, then click the Generate button. Let’s take the results from this twitter search( http://search.twitter.com/search.json?q=c%23 ) and convert it to some C# objects The JSON result(looks like a lot of work to convert this ourself)… The generated C#objects(clean and simple)

NDC 2012: a happy grain of sand

I’m just back from an inspiring trip to NDC Oslo . As always it was a great and fun event. I learned a lot and know what I’ll be studying the next few months… It all started with an amazing and funny keynote "A happy grain of sand" by Aral Balkan, where he talks about (user) experience design.If you missed it, check it out(you can skip the first minutes if you don’t want to see the singing… yes, indeed the singing )

System.InvalidOperationException: Dispatcher processing has been suspended, but messages are still being processed.

In a WPF application, when I try to open a specific page, the application crashes with the following error message: “System.InvalidOperationException: Dispatcher processing has been suspended, but messages are still being processed. at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)” When I looked at the code, I was calling a method on my ViewModel when a specific event was triggered on my view. Inside this method I try to open a MessageBox and show a warning. The view code: private void SampleView_Load(object sender, EventArgs args) { this .OnEventTrigger(grdProducts, "SizeChanged") .ExecuteCommand("Open1"); } The viewmodel code:   public void Open1() { _windowManager.OpenMessageBox("Open 1 method called.", false); } The ExecuteCommand() is a piece of functionality I created myself to have a fluent API to link events to...

Cannot convert anonymous method to type 'System.Delegate' because it is not a delegate type

Last week I tried to pass an anonymous method as a parameter to a method that excepted a delegate. As far as I know, an anonymous method is just an alternative syntax for a delegate. So I expected that it should work. However no luck, the compiler complained with the following error: “Cannot convert anonymous method to type ‘System.Delegate’ because it is not a delegate type’.” If anyone can explain me why this doesn’t work, you’re welcome. In the meanwhile, casting did the trick. Before: Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, () => this.Command.Execute(null)); //Does not compile After: Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => this.Command.Execute(null)));

TF80067: The data in the work item is not valid or you do not have permission to modify the data.

When trying to open the Iteration Backlog.xlsm file in Team Explorer, I’m getting the following error: “TFS80076: The data in the work item is not valid or you do not have permissions to modify the data. Please correct the problem and retry.” No idea what I did wrong. The only thing I changed were the iterations. So I renamed the first iteration back from ‘Sprint 1’ to the original name ‘Iteration 1’. Afterwards the document opened fine. Note: Afterwards I found this post on the MSDN forums. There someone mentions that the issue is solved if you also update the related queries after changing the iteration name.

‘Strict Mode’ in JavaScript

If you looked at some of the more recent JavaScript samples or had a look at the Windows 8 JavaScript applications, you’ve probably seen the ‘use strict’ statement before. But what is it and why use it? By applying the ‘use strict’ statement inside your JavaScript, you are enabling Strict Mode. Strict Mode offers a set of enhancements to the JavaScript language and introduces better error-checking into your code. When you use strict mode, you cannot, for example, use implicitly declared variables, or assign a value to a read-only property, or add a property to an object that is not extensible. Restrictions It introduces the following restrictions to your code(source: MSDN ): Language Element Restriction Variable Using a variable without declaring it. Read-only property Writing to a read-only property. Non-extensible property Adding a property to an object whose extensible attri...

Ajax requests are canceled when hitting escape

The default behavior of most browsers is to cancel all ongoing requests when a user hits escape.  Last week this bit us in the foot, as we ‘forgot’ to expect this behavior and requests were never fired again in a single page web app. The clean solution is of course to implement cancellation logic for all requests, but as the users were waiting for a solution, we introduced a quick fix. By handling the keydown and keypress event on the document level, we prevented the Escape from bubbling up to the browser and cancelling all requests. $(document).keypress(function(e) { if(e.keyCode == 27) { e.preventDefault(); } } $(document).keydown(function(e) { if(e.keyCode == 27) { e.preventDefault(); } }

Define a preprocessor variable in TFS

Last week I got the following question from a colleague: Do you have an idea how to define a preprocessor variable in TFS 2010?  Actually, these variables is used by Wix installer in the following project.  Apparently it is not possible to add this as a classical Msbuild argument (it is possible to add a constant but not define its value). In the nant build script, this is defined like this : <msbuild project="${src.dir}\${project.name}.sln"> … <property name="SolutionDefineConstants" value=" Version=${project.version};BinDir=${out.dir}\\ " /> … </msnbuild> There are 2 options I’m aware of to solve this problem: Inside the build definition you can pass the parameter for msbuild like /p: DefineConstants =" Version= 1.2.1.0". If the value you want to provide is only available inside the build definition itself(e.g. the build number), you’ll have to open the Build Definition Template and add an extra...