GIT to SVN Quick Start

Installing GIT and getting started

GIT Documentation: http://git-scm.com/documentation

GIT Getting started basics: http://git-scm.com/book/en/Getting-Started-Git-Basics

GIT for Windows: http://git-scm.com/download/win

Setting up for the first time: http://git-scm.com/book/en/Getting-Started-First-Time-Git-Setup

Visual Studio 2012 Tools for Git:

Install VS2012 Update 2: http://www.microsoft.com/en-us/download/details.aspx?id=38188

Install VS Tools for GIT: http://visualstudiogallery.msdn.microsoft.com/abafc7d6-dcaa-40f4-8a5e-d6724bdb980c

 

This is a quick reference guide for using GIT accessing a Subversion source code repository.

Tools for VS2012: Getting started with git in Visual Studio 2012

Using GIT Bash from context menu:

Clone repo from SVN

git svn clone -s https://url  <local_path>

The first time (takes a long time):

git svn show-ignore > .gitignore
git add .
git commit                  (commits .gitignore)
git svn dcommit             (commits .gitignore to svn for everyone to share)

Show list of branches

git branch -a

Make changes in a branch

git branch <new_branch>      (create branch)
git checkout <new_branch>    (switch)

Add changes/edits

git add <file>           (1 file)
git add .                (all files)
git add --patch          (prompts text changes)

Commit

git commit               (commits to current branch)

Merge to master

git checkout master      (switches to master)
git merge <branch>       (merge branch into master and auto commit if no conflicts)
git commit               (if conflicts needed resolving)

Merge to svn

git svn rebase           (update from svn)
git svn dcommit          (commit to svn for all to share)

Revert

git checkout <file>      (revert individual file)
git checkout .           (revert all files)
git reset head <file>    (revert if changes have been tracked)
git reset head .         (all files)

References and further help:
http://git.or.cz/course/svn.html
http://viget.com/extend/effectively-using-git-with-subversion
http://maymay.net/blog/2009/02/24/how-to-use-git-svn-as-the-only-subversion-client-youll-need

Enjoy!

 

Posted in Development, Miscellaneous, Source Repository | Tagged , , , | Leave a comment

Entity Framework 4 (EF4) with Visual Studio 2010 and Pluralisation

With the recent release of Microsoft’s EF4 with Visual Studio there is some debate around the use of pluralisation of table names.

Standard database theory is taught to use singular entity names, i.e. Genre and the table names should match this singular naming convention, i.e. Genre not Genres.

With EF4, whether using the Code First (CF) features or not, the table names are expected to be pluralised. This is an issue if you prefer to stick with the singularised table names or don’t have a choice on pre-existing databases. It is difficult to change an existing database, especially if that database is being used by other programs or reports within an organisation. This also causes some conflicts when an entity such as Person is used – the EF pluralises this as Persons but perhaps People would be a better option.

This post shows how to get around the EF pluralisation for whatever reason you need.

I prefer to use the manual setup of the entity classes as it allows me to set the attributes needed for frameworks such as MVC3 that facilitate ORM mapping and validation.

I’ll use the the MVC3 Music Store tutorial in my example. The database entity setup can be found here: http://www.asp.net/mvc/tutorials/mvc-music-store-part-4. Check the entity relationship diagram in the tutorials and you will see the database tables are all named singularly. This suited EF3 but was broken in EF4 and there is an updated database available, however, the linked scripted database still created the singular table names at time of writing.

The EF4 Code First (CF) model has a nice feature allowing the database schema to be generated from code. If the code schema changes, you can request in code to drop the schema and recreate it. This has some limitations in all but the simplest of schemas and is not an option in production code. Auto generating the schema is outside the scope of this article but is covered in the MVC3 Music Store tutorial.

In a production or complex environment, you will need to modify the database schema manually and reflect the changes in your code. This may mean adding a column or adding a new table to your database.

To specify the Genre table from the tutorial, your entity class would be:

An example of the database context class is below:

The EF will expect the database table name to be Genres (because the entity is called Genre, not because the entity set is called Genres). If you wish to keep the table names as Genre (or use some other name if legacy issues existed), you can override the table name individually by overriding the settings in the OnModelCreating function, as below:

NB: The quoted name specifies the database table name.

You can do this for all tables or just the tables required – you do not have to list all tables, only the table names you wish to override.

Alternatively, and more simply, you can annotate the entity class with the table attribute to specify the table name, which overrides the EF’s defaults, including the pluralisation. An example is below:

This is all there is to it. Searching the web, all I found was negative comments that this couldn’t be done or unnecessarily complex solutions, including questions posted in the tutorial mentioned.

Enjoy!

Posted in Code, Development | Tagged , , , , , | Leave a comment

Error: IIS SSL certificate re-issue and the issuer of the certificate not being trusted with the error : “The issuer of this certificate could not be found”

I recently had need to renew a client’s IIS SSL certificate on their behalf as it had expired.

Generating the renewal request was easy in IIS using IIS Manager. It was sent off to the issuer and a new certificate quickly received.

Importing the new certificate into IIS was also easy using IIS Manager, however, once imported IIS reported the certificate issuer could not be verified and digging further “The issuer of this certificate could not be found”. WTF? It was working from the same provider previously and Thawte are a well known authority.

A bit of a google, came up with Thawte changing their security in June 2010 to require an intermediate certificate. This link provides the intermediate certificate and how to install on IIS – all worked exactly as detailed.

Hopefully, this will help someone else to get over this hurdle quickly.

Enjoy!

Posted in Security | Tagged , , | Leave a comment

Code-First Development with Entity Framework 4

The EF Code-First Library is a very cool feature of the Visual Studio 2010 tools that will allow developers to get their applications running quickly – a full persistent data entity model can be created without having to configure a database, run any tools, configure any XML files, or define any base data entity classes. One of the coolest things is the way the database model can be changed automatically when changes to the entity model are made and the automatic creation of the primary keys and relationships between the tables. This should be a real time saver to developers.

To use the features you require the EF4 (ships with VS2010), SQL Server CE 4.0 and the EF Code-First Library (the CTP can be downloaded from here)

Scott Guthrie has done a really good job of explaining the steps to using the EF Code-First Library in his blog post.

Enjoy!

Posted in Architecture, Code, Development | Tagged , , , , , | Leave a comment

Protected: Bikes and Video

This content is password protected. To view it please enter your password below:

Posted in Recreational | Tagged , | Enter your password to view comments.

Visual Studio 2010 and .NET 4 officially released today

Visual Studio 2010 and .NET 4 officially released today.

http://weblogs.asp.net/scottgu/archive/2010/04/12/visual-studio-2010-and-net-4-released.aspx

Enjoy!

Posted in Development | Tagged , | Leave a comment

Protected: Visual Studio 2010 Pending Release

This content is password protected. To view it please enter your password below:

Posted in Development | Tagged , | Enter your password to view comments.

.NET web.config WCF Settings

I love the way the .NET web.config file allows the appSettings and connectionStrings sections to reference another file. It provides easy support for differing deployment environments as the settings for each environment are kept in their own files and can be switched in out by changing the configSource attributes, as per the example below:

<appSettings configSource="AppSettingsDevelopment.config" />

And the linked config file would look something like this:

<appSettings>
    <!-- Development -->
    <add key="myKey" value="http://localhost:56299"/>
</appSettings>

If this was extended to include the WCF settings in the <system.ServiceModel> this would be a fantastic enhancement as the settings are always different in each environment – the URIs are always different as are the security, binding and transport settings.

Sure, the whole web.config file can be copied out to different named files, then copied back and renamed, but this is tedious in that the whole file must be scanned for other changes for each environment whenever a any change is made.

I always find myself writing a factory to create the client proxy instance. The factory initialises the correct address which is retrieved from the appSettings, which changes depending on the environment but this is not an ideal solution.

Posted in Architecture, Development, Miscellaneous | Tagged , , , | Leave a comment

OziExplorer Tracklog File Format

I searched around the web high and low and could only find limited information on the OziExplorer tracklog file format that is stored in the .plt files. 

OziExplorer has PC and Windows Mobile versions making it a great tool for tracking/logging and planning your travels. Tracklogs save your tracks as you travel: saving on your portable mobile device saves space in your vehicle (or even in your pocket!) and allows you to copy the tracklog files to your PC for viewing on the big screen later.

On our recent trip around Australia, we saved all of our treks using OziExplorer.

My analysis has determined the following from two versions v2.1 and v2.0

.plt – Extracts:

v2.0 from OziExplorerCE
1.    OziExplorer Track Point File Version 2.0
2.    WGS 84
3.    Altitude is in Feet
4.    Reserved 3
5.    0,2,255,OziCE Track Log File,1
6.    0
7.    -26.7597652, 150.6400882,0, 1047.9,40165.0451620 ,181209,000505.3
8.    -26.7597353, 150.6400796,0, 1114.8,40165.0457292 ,181209,000554.3
9.    -26.7597090, 150.6400779,0, 1139.1,40165.0473380 ,181209,000813.3
10.  -26.7596040, 150.6400643,0, 1151.2,40165.0475810 ,181209,000834.3

v2.1 from OziExplorer PC
1.    OziExplorer Track Point File Version 2.1
2.    WGS 84
3.    Altitude is in Feet
4.    Reserved 3
5.    0,2,255,OziCE Track Log File ,1,0,2,8421376
6.    1257
7.    -26.759765, 150.640088,0, 1047.9,40165.0451620, 18-Dec-09, 1:05:01 am
8.    -26.759735, 150.640080,0, 1114.8,40165.0457292, 18-Dec-09, 1:05:51 am
9.    -26.759709, 150.640078,0, 1139.1,40165.0473380, 18-Dec-09, 1:08:10 am
10. -26.759604, 150.640064,0, 1151.2,40165.0475810, 18-Dec-09, 1:08:30 am

Description
Line 1 – Type and version information
Line 2 – Datum used
Line 3 – Just a reminder the altitude is always stored in feet
Line 4 – Reserved for future use
Line 5 – 0,2,255:RGB colour of track; OziCE Track Log File: track description; 1:trackskip value – usually set to 1
                for v2.1 – extra fields: 1,0,2,8421376
                   1 – trackskip value
                   0 – trackType: 0=normal; 10=closed polygon; 20=alarm zone
                   2 – track fillstyle: 0=solid; 1=clear; 2=back diagonal; 3=forward diagonal; 4=cross
                   8421376 – track fill color (RGB)
Line 6 – number of trackpoints in the file. Not updated in v2.0. Redundant as the number can be determined when reading the records

Track log records
Lines 7 to end: data records of track log

Field
1.    -26.7597652 latitude
2.    150.6400796 longitude
3.    0 0=normal; 1=break in track line
4.    1047.9 altitude in feet 1047.9 ft = 319.39992m
5.    40165.0451620     date/time 40165=days since 30/12/1899 i.e. 40165 = 18/12/2009 (18 Dec 2009)
                                                                    0451620 is fraction part of day in localtime zone, i.e. 0451620 = 01:05:02am. This appears to be in UTC time (not local time)
v2.0
6.    181209 date ddmmyy
7.    000505.3 time seems to be some rounding discrepancy between v2.0 & v2.1
v2.1
6.    18-Dec-09 date dd-mmm-yy
7.    1:05:01 am time UTC? time?

NOTE: Fields 6 & 7 are ignored by OziExplorer
              Field 7 appears to have a discrepancy in the calculation of the time from field 5 (the minutes are different)

The OziExplorer date/time format is the OLE date/time value stored in it’s raw double format. The .NET DateTime class provides a build in function to construct a DateTime from this value:

1
DateTime timestamp = DateTime.FromOADate(40165.0451620);

Edit (20/2/2010): I have since found this link:
http://www.rus-roads.ru/gps/help_ozi/fileformats.html

Enjoy!

[Edit 21/2/2010]
Corrected time conversion – I was a decimal place out.
Added a method to convert the OziExplorer date/time to a .NET DateTime.
The OziExplorer time format appears to be stored in UTC format.

Posted in GPS | Tagged , , | Leave a comment

Baited Remote Underwater Video Stations

Anyone that knows me well will know that I am a scuba diver, so this little gem really pleased me.

The Courier Mail reports about Baited Remote Underwater Video Stations (BRUVS) that have been deployed on the Great Barrier Reef to bring live video to viewers. This one was a little short lived when a tiger shark decides it’d make a great meal after spitting out a sea snake. I encourage you to watch it until the end.

Isn’t it a great way of using technology. I hope they publish more of these.

VIDEO: Reefcam

Enjoy!

Posted in Miscellaneous | Tagged , | Leave a comment

Ten things to do with your new friend PALRO

Here’s my official order for next Xmas…

Ten things to do with your new friend PALRO.

I wonder if I can get it to write software, wash the car, sweep the floors?

Enjoy!

Posted in Miscellaneous | Tagged | Leave a comment

Specifying/changing the database when using Web Parts in an ASP.NET application

When using Web Parts in an ASP.NET application, if personalization is enabled (which is the best reason for using Web Parts), the personalization is stored in a SQL database.

This article details the steps to set this up or to change the default location. The default is the sql express instance on a development machine – my preference is for the SQL 2008 database on my network, but you will also need to specify the database to use when deploying your application.

The database used by the WebPart, or more precisely the WebPartManager, is the same one used by the membership and role providers. To create the database on either SQL2005 or SQL2008, run aspnet_regsql from the C:WindowsMicrosoft.NETFrameworkv2.0.50727 folder. This will run a wizard allowing you to specify where you would like the database created – you will need an instance of SQL Server 2005 or 2008 installed before doing this.

Once this is completed, you need to tell your ASP.NET application to use this database. This is configured in the web.config file by copying the following into the <system.web> tags:

     <webParts>
      <personalization defaultProvider="SqlPersonalizationProvider">
        <providers>
          <add name="SqlPersonalizationProvider"
            type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider"
            connectionStringName="AspNetDbConnectionString"
            applicationName="/" />
        </providers>
        <authorization>
          <deny users="*" verbs="enterSharedScope" />
          <allow users="*" verbs="modifyState" />
        </authorization>
      </personalization>
    </webParts>

All that’s left then is to create the database connection specified in the connectStringName specified above:

  <connectionStrings>
    <add name="AspNetDbConnectionString"
        connectionString="Data Source=MSSQLSERVER2008;Initial Catalog=aspnetdb;Integrated Security=True"
        providerName="System.Data.SqlClient" />
  </connectionStrings>

You may need to adjust the security settings to allow access to anonymous users, but that is beyond the scope of this article.

Since the WebPartManager uses the provider pattern, with a bit more work, you could also create a custom provider and use any other database store.

Enjoy!

Posted in Development | Tagged , | Leave a comment

God mode on Windows 7

Try creating a folder on Windows 7 and calling it

GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}

Then open the folder and check out it’s contents.

You can call the folder anything you like, it’s the suffix that is important – the .{ED7BA470-8E54-465E-825C-99712043E01C} part – so

Cool.{ED7BA470-8E54-465E-825C-99712043E01C}

Will also work.

Enjoy!

Posted in Miscellaneous | Tagged , | Leave a comment

Protected: Windows Registry interaction with 64 and 32 bit applications

This content is password protected. To view it please enter your password below:

Posted in Development | Tagged , , , , | Enter your password to view comments.

Retrieving COM class factory failed due to the following error: 80040154

When installing a new version of Windows 7 (64 bit), I came across this error when attempting to run one of my web services:

Retrieving COM class factory failed due to the following error: 80040154

No real explaination on what component was causing the problem, but stepping into the code, there is a dependency on a third party COM DLL to communicate with a remote server. The COM component is 32 bit - getting it to run in the 64 bit environment is the issue.

Changing the build in VS to x86 did not correct the problem, the component still failed to load.

Since the component is hosted in IIS, IIS needs to be told to run in 32 bit mode instead of 64. There are a few links on the web that state that IIS 7 must be set to run in 32 bit mode to support this and this is at the expense of all your other applications, however, this is not the case.

The better way to support this is to setup a dedicated application pool to run in 32 bit mode and set the web application to use this application pool, allowing you can continue to use IIS 7 in 64 bit mode for your other applications. This application pool will now run in WOW64 (Windows on Windows 64) mode which runs in 32 bit mode and as such will only load 32 bit applications, so if you also have another 64 bit dependency you will need to run that in a different application pool and invoke it through another web application.

Enjoy!

Posted in Development | Tagged , , , , , , | Leave a comment

Integrated security with IIS and .NET

Setting up a new Windows 7 machine had me challenged remembering all of the things that need to be done to get my .NET applications all working again, especially ones that use any kind of integrated windows security with IIS, and connect to a database and web services.

The main one that gets me thinking everytime is the impersonation account if a Windows’ account is setup to connect to a database. This would typical be needed when connecting to a web service that connects to a database. One way to achieve this is to use SQL security to maintain the account and store the user/password in the web.config but this has some security concerns in that the password is stored in clear text. This also requires the password to maintained in multiple places, which is not desirable.

The better option is to use integrated security, provide the account the appropriate level of permissions to stored procedures , tables or a schema under SQL 2005 or later, and set the IIS security to use ASP.NET impersonation. This way the password is secure and managed outside of the application in the domain.

The first thing that invariable happens on the first invocation is an error like the following occurs:

‘The current identity (XXXXXX) does not have write access to ‘C:WindowsMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files’

Hmmm, what I have seen here is developers racing off to set the permissions on the above folder to allow  write access to the folder. This works with limited success but is NOT the correct way to do it.

The easiest and correct way is to add the user account to the local IIS_IUSRS group, and be sure the user account is not in the standard ‘Users’ group otherwise someone could login to the machine/network using the service account which might not be want you want…

Simple…

Enjoy!

Posted in Development | Tagged , , | Leave a comment

IIS Hosted WCF Service Fails

When attempting to get a new machine running, I have come across an issue getting IIS hosted WCF services to instantiate.

A typical WCF service file would contain something like the following:

<%@ServiceHost language=c# Debug=”true” Service=”Bellette.MyService” %>

The error is typically something like the following:

Unhandled Exception: System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (405) Method not allowed.

This can occur if ASP.NET isn’t installed or the .svc file is not mapped to the aspnet_isapi.dll

To correct this first must make sure that aspnet_isapi is enabled as a Web service extension for IIS. You do this by running aspnet_regiis –i –enable from the .NET Framework installation directory. Once you have done so, verify that ASP.NET is running. To do so, place a test .aspx file in the inetpubwwwroot directory, and make sure it can be opened in the browser.

If IIS was installed after WCF, running the following will register the required script mappings in IIS:

“%WINDIR%Microsoft.NetFrameworkv3.0Windows Communication FoundationServiceModelReg.exe” -r

More detail can be found on MSDN.

Enjoy!

Posted in Development | Tagged , , | Leave a comment

Getting IIS Debugging and WCF working under Vista and Windows 7 with VS2008

After installing VS2008 on Vista and attempting to fire up a WCF application built with a .NET framework I built a couple of years ago now, I found the WCF channel was failing with no hint as to the problem. This issue also applies for running on Windows 7.

The framework architecture hosts the WCF service in IIS. When opening the solution with VS2008, I was presented with the need to run VS as an administrator. That problem is sorted easily enough, but is a bit intrusive.

Restarting VS as administrator, the next thing I tried was to step into the WEB presentation layer.

Firing up the debugger, I was presented with the error “Unable to start debugging on the web server. Strong name validation failed. Click Help for more information”.

Clicking the help did not present a solution but a quick google found a number of references to a setup a string name for iisresolver.dll, as mentioned in these links:

This did not resolved the problem, nor is it the correct way to resolve the problem.

The issue is actually with IIS7 authentication, as I found in Rick Strahl’s Web Log at http://www.west-wind.com/WebLog/posts/139869.aspx

By default, IIS7 does not install by default with Windows Authentication.

Also, IIS Metabase and IIS6 metabase configuration compatibility needs to be enabled for IIS6 based applications.

This is performed by installing the Windows Features as below:

The application also needs to be added to an application pool that uses classic managed pipeline mode, as by default IIS default application pool uses Integrated pipeline.

Setup a new application pool from IIS Manager and add the application to the new application pool.

Finally, Windows Authentication then needs  to be enabled for the IIS application:

You should now be able to debug the web application when hosted in IIS – and there is no need to attach to the wp3 worker process in the service host, which is a big improvement on XP.

At  this stage, the WCF invocation will still likely fail. This is because WCF HTTP activation is not enabled by default (nor is Non-HTTP Activation).

To enable this, go to the Control Panel -> Programs -> Turn Windows Features on or off

Find Windows .NET Framework 3.0 and enable WCF HTTP activation as show below. You can also enable non-HTTP activation while you are there.

Hopefully, everything is now working as it was before you migrated to Vista and VS2008.

Debugging

To debug the IIS process you need to start VS2008 in Administrator (Run as Administrator).

The process to attached to is called w3wp.exe on Vista.

Enjoy!

(Originally written September 2007)
Posted in Development | Tagged , , , , | Leave a comment

WinForms applications – No Touch Deployment (NTD) and gotchas

Often when .NET WinForms applications are created, developers do not consider the various deployment options available and panic when it comes time for deployment and default to using ClickOnce. This is not a good strategy as the architecture of the application is not well considered with this in mind and limits the deployment options.

If WinForms intranet applications are going to scale, the various deployment options must be considered and a well architecured application designed otherwise the code soon becomes an unmaintainable mash of spaghetti that does not scale well, is difficult to maintain, and the morale of your development team deteriorates rapidly. There is also an added benefit in being able to mix languages if assemblies are correctly architectured. In a future post, I’ll go into more detail on a good architecture for scalable WinForms applications that also connect to service applications either through WCF or standard web services.

In this article, I’ll be concentrating on No Touch Deployment (NTD) as an alternative to using ClickOnce.

I originally wrote this article back in March 2008 when considering the redesign of a large VB.NET application that had gotten out of hand. The developers wanted to write in C# but due to the poor design the application was compiled into a single exe for deployment which hindered starting to use C# on new code and because the exe had become so large, the load time was slow.

No Touch Deployment is a useful feature if you want to reduce the deployment maintenance of your Windows Forms applications, especially on intranet applications.

NTD works by using a very thin client application that loads a remote assembly using reflection.

The remote assembly is downloaded into the local assembly cache, and the each time the application is loaded the assembly cache is checked to see if the assembly has already been downloaded or if the version has changed.

Any assemblies that the downloaded assembly references are also downloaded in the same way, but there is no need to use reflection to download the depended assemblies – you just referenced them in the same way that you normally do.

Benefits:

Simple deployment – no need for packaging – no messy ClickOnce dialogs. (You may need to package the launcher only unless you have a deployment mechanism to get it onto the user’s desktops some other way)

A simple static thin client application is used to launch the application.

Assemblies are downloaded on an as needed bases, so if a user does not use part of an application, the depended assemblies are not downloaded, this makes it ideal for intranet environments, reducing network traffic.

How to:

Setup a small launcher project that will load the main assembly. The launcher should be specified as a Windows Application to prevent the console window from showing.

The launcher need only have one function:

The remote assembly can either be specified as a Windows Application (exe) or a Class Library (dll).

If it is specified as a Windows Application, it has the benefit of also being able to be started without using the launcher.

The remote assembly looks something like this:

You don’t need the Main() function is using a dll, but it doesn’t hurt to leave it there incase you change your mind later.

The remote assembly references its dependent assemblies in the same way as you would normally.

Debugging in Visual Studio

The remote assembly needs to have the bin folder set as a virtual directory within the local IIS to allow startup, or for local development simply use the file reference.  VS2008 will happily step into the remotely loaded assembly. This will require the developer to setup this virtual folder.

Alternatively, make the remote project a Windows Application (exe), include a static main function as per the code above, and the set the remote project as the startup application. This will run the application without using the launcher.

Another alternative is to create a second launcher application that references the main dll directly and keep that for development purposes only, i.e. do not distribute this.

 Security

The application is launched in the internet zone, so the application does not have local permissions.

Under Vista the Microsoft .NET Security Warning is displayed as shown below:

Gotchas:

If the application is hosted on Vista (typically in a development environment), the referenced DLL may fail to download but throw a BadImageFormatException in the call to Assembly.Loadfrom(), saying a manifest was expected.

Changing the code to download from a file reference proves the assembly is OK.

If this error occurs, make sure the web service is setup to allow static content. This is activated through Windows features as shown in the image below:

Enjoy!

Posted in Development | Tagged , , , | Leave a comment

First post

I’ve been meaning to setup a technical blog for sometime now to write my technical thoughts and share my learnings with fellow developers.

Some of the first posts will be based on info I have put away some time ago but have now finally put it up.

I hope you get some value from my posts. If you do, please dig it or add a comment.

Posted in Miscellaneous | Tagged | Leave a comment