Posts

Showing posts from 2010

Visual Studio Crash

Visual Studio (2008) crashed on me this morning while loading a solution I worked with yesterday. It said something like System.Windows.Forms.TabPage threw an exception ... that it could not load one of the dependency projects to my user controls. The quick 'n easy TM fix for this, was to delete my solution options file (hidden file with extension .suo in the solution folder). The solution options file contains, amongst other things, which documents you had open last. One of those documents were surely the Main Form, which contained a TabController . Oh, I knew you'd ask - yeah, the solution opened, built and ran just fine after deleting the .suo and re-opening the project. Have a nice day! / Sami

The wonderful DataGrid

Yes, I'm being sarcastic. So, say you have a DataGrid. You have a set of items, and you want to be a good developer and databind those items to the grid. So far so good. Now, let's say that each item need a combobox because a cell value can have a limited sets of values. Fine, so you set up a data source for your items and a data source for your combobox column: dataGrid.DataSource = viewModel.GridItems; comboBoxColumn.DataSource = viewModel.ComboBoxItems; Then you just make sure that the source column in your data grid has the same value as the Value member of your combobox column and you're pretty much home. Now, the fun begins. Say that the data source in question needs different values in the combobox depending on the row. Not so fun anymore, eh? The solution proved to be to bind the grid as usual, but avoid binding the combobox column. Instead, you subscribe to the DataBindingComplete event of the grid, wherein you apply some magic:    int columnIndex = d

Automatically expand a combobox when you click a combobox cell in a datagridview

Oi, that was a long title! Rhymes well with the DataGridView control, though - there are it's a BIG control and has a LOT of associated types. To the point, though: private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { var editType = dataGridView.CurrentCell.EditType; if (editType == typeof(DataGridViewComboBoxEditingControl)) { dataGridView.BeginEdit(false); if (dataGridView.EditingControl is DataGridViewComboBoxEditingControl) { var editingControl = dataGridView.EditingControl as DataGridViewComboBoxEditingControl; editingControl.DroppedDown = true; } } } Hope this helps, // S

Solved: Visual Studio cannot load its own packages

Problem: Visual Studio cannot load it's own packages, eg. the Forms Designer, TFS plugin or resharper. Solution: Reinstall the .NET Framework (I reinstalled .NET 3.5 with SP1). Hopes this saves you time

Encode URLs in XSL

Issue: You are updating a system which relies (too much?) on XSL-transformations to generate web content, and the system in question needs to be outfitted with URL encoding. Furthermore, you are using Microsoft's XSL-transformations (XslCompiledTransform) and hence are forced to use XSLT 1.0. Note: If you are using a system where XSLT v2.0 is available, there is a built-in function called url:encode() that you can use: <xsl:variable name="url-encoded-company-name" select="url:encode($company-name)"/> Oh, back to our problem at hand (or, rather, a solution): In the world of Microsoft and XSL, you can have the magic of JScript to help you out. This is how: Your XslCompiledTransform instances need to allow style sheets to execute scripts: //var transformer = new XslCompiledTransform(pathToFile); var settings = new XsltSettings( enableDocumentFunction: true, enableScript: true); var transformer = new XslCompiledTransform( pathToFile,

More TFS Fun

You try to merge SOURCE_BRANCH with TARGET_BRANCH and get the following error: TF14083: The item '$/xx/yy/zz.cs' has a pending merge from the current merge operation, please resolve and check in the current merge and merge again to pick up this change. Simply merge that specific file separately, check in, and then continue the large merge operation

Rollback on branched changes

Hi kids, Today, we're going to learn how to perform a rollback in a TFS branch where you ONLY want to affect the current branch (i.e. you don't want your rollback to affect branches with whom you branch changes). Scenario We have "contaminated" a (Release) branch with changes that belongs to the next release down the road. An issue arrise in production, which needs immediate hotfixing. The responsisble team makes their change in their dedicated Hotfix branch, but when they are to merge their changes to the Release branch, they realize that the release branch does not look like they left it. (In this scenario, deployment scripts scripts are configured to deploy from the Release branch and nothing else). Technical Solution (You'll need Microsoft Team Foundation Server Power Tools (TFPT)) Sequential rollback of changes in Release Get history of changes in branch CAREFULLY write down the change-set numbers Undo (and shelf) any local changes

StringBuilder vs. String.Concat

Did you know that the String.Concat is really optimized (fast)? I've always seen it as an equivialent of StringBuilder, but as it turns out, String.Concat can be the better choice in many areas. As a recap of earlier blog posts, if you are going to concatenate two strings, you might as well use the add operator ( var result = "Hello " + "World"; ). However, if you want to build a larger string, you might want to consider one of the two constructs discussed in this post. My recommendation is to use String.Concat for average-sized strings, and StringBuilder for larger strings that are built over time: // String.Concat logger.LogError(String.Concat( "Error doing this and that for ", customerId, ", doing action ", action, " with properties ", properties )); // StringBuilder StringBuilder buffer = new StringBuilder(); string line = null; while((line = stream.ReadLine()) != null) { if(buffer.Length

NoSQL For The Rest Of Us

Image
(From CodeBetter.com) NoSQL For The Rest Of Us : " No one would blame you for strictly associating NoSQL with performance. Most of the back and forth about NoSQL - an umbrella term given for non-relational storage mechanisms - has squarely put the focus on performance, sites with massive traffic, and server farms. It’s an interesting conversation, but one that risks alienating NoSQL from the majority of developers. The Problem Does NoSQL provide us simple developers with any tangible benefit? As a matter of fact, it can - one as significant for us as performance is for facebook. First though you need to understand that all of those tools you've been using to access your data, such as DataSets, Linq2Sql, Hibernate, NHibernate, EntityFramework, ActiveRecord, SubSonic SQLAlchemy, are meant to help you deal with the well-known object-relational impedance mismatch . The short description is that data stored in code (typically using an Object Oriented approach) and data stored in

Mono's C# Compiler as a Service on Windows.

(by Miguel de Icaza ) Mono's C# Compiler as a Service on Windows. : " The Mono team is proud to bring you a preview of C# 5.0 a few years before our friends in Building 41 do. A snapshot of the code is available in the demo-repl.zip file. This contains the csharp.exe C# REPL shell and the Mono.CSharp.dll compiler-as-a-service assembly. With Today's code drop all those scenarios now work: Run Mono's C# compiler on .NET Embed Mono's Evaluator in your C# app. Use Mono's REPL with the .NET framework runtime. Background Although we have had a compiler-as-a-service framework since September of 2008 it has been so far limited to Mono users, which effectively means only Linux and OSX users could use our C# REPL and the compiler as a service. The reason is that the Mono's C# compiler uses System.Reflection.Emit as its code generation backend. This API was fine for implementing C# 1.0 but required a few changes to suppo

MSMQ Changing Transaction Mode

Is your MSMQ writer up and running? Is the queue ending up with 0 messages? Getting no error messages? It could be because your reader and queue has changed scemantics and that the queue is no longer transactional! No errors and no messages. So, don't do what I did and forget to change both reader and writer if you are ever reconfiguring a queue from/to transactional.

SCRUM-meetings should be held early in the day

From my experience, SCRUM-meetings should be held early in the day so that the team gets synchronzied from the get-go. For example, at my current client, the team, on average, gets in at 08:30 in the morning. Having the daily SCRUM at 09:30 inhibits efficient work during that hour since the team has pre-concieved view-points that are based on yesterday's events. Thus, wrong decisions are made (eg. there's nothing to test, or I have to wait for event X to be able to do event Y). It seems that the best time to have the daily SCRUM, is about 10 minutes after the team gets in. That's about enough time to get in, turn on the computer, get a cup of coffee, skim through your e-mails and take up your context from the day before so that you can update your team members in a coherent way. What are your experiences in the matter?

TFS Merge and naming

If I merge BranchX to BranchY, undo my local changes places BranchX’s changes into BranchY.