Regenerating DBML Designer when your database changes

Here’s how to regenerate your DBML code in Visual Studio 2010 when one of your database objects changes:
1. Remove the table
2. Close the DBML designer and save
3. Re-open the DBML designer
4. Re-add the object by dragging from Server Explorer
5. Close the DBML designer and save

In finding this solution, I did find some wailing and gnashing of teeth on-line, with people expecting the DBML code to have some kind of refresh feature for automatically doing this when the database changed.

I must admit I don’t share their chagrin. I am:
* Pathetically grateful for anything that saves me not having to write a hundred lines of property let/get statements
* Impressed by the way projects that reference these objects automatically re-test for compilation as soon as you save the DBML code

Visual Studio Stops Recognising Mouse Input

The shine is starting to wear off Visual Studio 2010 Professional for me. Recently the IDE has started to hang, in a rather strange way. The code editor still appears to respond to mouse events, but nothing actually happens. E.g. you can highlight some code, right mouse click and choose copy from the context menu, but then when you come to paste, nothing happens. Or you’ve been coding away, and you see the file name has an asterisk against it, so you hit ‘Control+S’ to save, but nothing happens. And the only way you can save your changes is by closing the file – at this point VS prompts you if you want to save.

This seems to be something that others have noticed, certainly in the Beta:
http://connect.microsoft.com/VisualStudio/feedback/details/504538/debugger-hangs-vs-for-a-long-time-when-coming-out-of-debug-mode

One of the tips is to uncheck the ‘Enable the Visual Studio hosting process’ checkbox in Project Properties > Debug pane – and this seems to have fixed it for me.

This is not very impressive. I’ve used all of the previous .NET editions of Visual Studio, and never seen this kind of stuff before.

DevExpress DXGrid for WPF and Visual Studio Express

Turns out that the DevExpress installer does not integrate DXGrid with Express editions of Visual Studio. Solution is:

1.Manually add references for following assemblies:
DevExpress.Data.v9.2.dll
DevExpress.Wpf.Core.v9.2.dll
DevExpress.Wpf.Editors.v9.2.dll
DevExpress.Wpf.Grid.v9.2.dll

2. Manually add namespace to XAML:
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"

You can then add your element as usual.

DevExpress Support also say that you can manually add the following assemblies to the Toolbox to achieve designer support, but that didn’t work for me:
C:Program FilesDevExpress 2009.2ComponentsSourcesDevExpress.DLLDevExpress.Wpf.Editors.v9.2.dll
C:Program FilesDevExpress 2009.2ComponentsSourcesDevExpress.DLLDevExpress.Wpf.Grid.v9.2.dll

Tip: Shared Assembly Attribute File

When you on a solution with several assmblies in .NET, you’ll find yourself maintaining multiple copies of AssemlyInfo.cs, each of which contain a lot of common attributes such as:
AssemblyCompany
AssemblyProduct
AssemblyCopyright
AssemblyTrademark
AssemblyCulture

You may also wish to make AssemblyVersion uniform accross your build.

A useful technique in this situation is the following:
1. Copy the common attributes out into a new file, called something like ‘GlobalAssemblyInfo.cs’
2. Delete these common attributes from the original AssemblyInfo.cs files
3. Save your GlobalAssemblyInfo.cs file somewhere useful, e.g. in the same folder as your solution file
4. In each project, add GlobalAssmblyInfo.cs through the IDE as a linked file, rather than a straight addition.

Breakpoint conditions

Just started using these in a large project I am maintaining – very useful for working with event sinks that get called every time *anything* happens.

School boy error for the day was thinking in VB rather than C# for my loop condition: ‘i=6’ has changed rather than ‘i==6’ has changed
Assignment never changes, as I found, waiting in vain for my debug window to appear!