vrijdag 10 juni 2011
Dutch development community
An overview of all the active topics can be found here
maandag 15 november 2010
Windows CE change screen orientation
You can use
Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation = Microsoft.WindowsCE.Forms.ScreenOrientation.Angle180;
to turn the screen 180 degrees.
Using
Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation = Microsoft.WindowsCE.Forms.ScreenOrientation.Angle0;
you can restore the default orientation
vrijdag 27 augustus 2010
Detect .Net framework version with your browser
Internet explorer sends out information about what .Net version is installed on your machine.
Scott Hanselman created a nice website that extracts this information, displays it and presents available updates for your machine (if needed): www.smallestdotnet.com
dinsdag 24 augustus 2010
Upgrading a Sql Server Compact database file
Recently I upgraded my project from Sql Server Compact 3.0x to Sql Server Compact 3.5 (I was already using VS 2008, but with SQL Server Compact 3.0x that comes with VS 2005). You can do this easily by changing the System.Data.SqlServerCe reference in your project to the new 3.5 dll.
But when you try to run the project using an existing Compact database, you get the following exception:
"The database file has been created by an earlier version of SQL Server Compact. Please upgrade using SqlCeEngine.Upgrade() method."
You can indeed upgrade the file using the code as indicated in the exception message (SqlCeEngine.Upgrade()). But because I’m always deploying the application with a ‘ready-to-start’ sdf file, I only need to do the upgrade once. Therefore I decided to use Sql Server Management Studio 2008 to upgrade the file for me.
You can use following steps to upgrade:
1) Open Sql Server Management Studio 2008 and choose ‘Sql Server Compact Edition’
2) Choose ‘Browse for more’ in the ‘database file’ combo box; an explorer window will open and you can browse to your sdf file.
3) Management Studio will detect that the file was created in a previous Sql Server Compact version and displays a warning message (which basically says the same as the .net exception):
4) When you press OK here, Management Studio converts the file for you. You can now run your program again, using the upgraded sdf file.
maandag 23 augustus 2010
Entity Framework: ‘does not support datatype datetime2’
While testing on my local development machine, I use a SQL Server 2008 instance. I generated the EF model using that same local database and everything works fine. After the testing period, I wanted to run the same tests on a production server.
The moment I tried to update an entity containing a datetime field, I received the following exception message:
“The version of SQL Server in use does not support datatype 'datetime2'.”
After checking the ddl of the tables on both test and production database, I found no differences.
What was the problem (and solution)?
It turns out that the model generator puts some database targeting information in the generated model (the edmx file). Since my production database was still a SQL Server 2005 instance, using the model on that database gives runtime errors, because statements are generated that the SQL Server database doesn’t understand. The problem is here (in the edmx file):
The ‘ProviderManifestToken’ attribute indicates that a SQL Server 2008 database was targeted. When you change this to ‘2005’ everything works fine again (even when you are connecting to the SQL Server 2008 database).
maandag 2 augustus 2010
Binding a Brush property to a Color
When you try to bind a Color directly to a Brush property, you get the following error in your Visual Studio output window:
System.Windows.Data Error: 'MS.Internal.Data.DynamicValueConverter' converter failed to convert value '#FFFF00FF' (type 'System.Windows.Media.Color'); BindingExpression: Path='LineColor' DataItem=LineVector' (HashCode=38524289); target element is 'System.Windows.Shapes.Line' (Name=''); target property is 'Stroke' (type 'System.Windows.Media.Brush').. System.InvalidOperationException: Can't convert type System.Windows.Media.Color to type System.Windows.Media.Brush.
at MS.Internal.Data.DefaultValueConverter.Create(Type sourceType, Type targetType, Boolean targetToSource)
at MS.Internal.Data.DynamicValueConverter.EnsureConverter(Type sourceType, Type targetType)
at MS.Internal.Data.DynamicValueConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
at System.Windows.Data.BindingExpression.ConvertToTarget(Object value).
The solution is to first wrap the Color in a Brush:
<Line.Stroke>
<SolidColorBrush Color="{Binding LineColor}"/>
</Line.Stroke>
maandag 12 juli 2010
Network analyzer
To do some tracing of WCF messages I was planning to use Ethereal, a network sniffing tool. I used this tool successfully a couple of years ago. While searching for the download, I discovered it’s now known under the name ‘Wireshark’: http://www.wireshark.org/
More details on the name change can be found here: http://www.wireshark.org/faq.html#q1.2