Category Archives: development

Bootstrapping your new project using crane

Get the code

Visit us on github https://github.com/ewilde/crane

Or install the app

crane-5

But what does it do?

crane is a command line tool the I developed with Kevin Holditch. It kick starts development of a new project by templating the boring bits.

crane init ServiceStack.Plugin

Running this command creates the following items

  • Solution file
  • Project
  • Unit test project
    • Example test based on xbehave
  • VERSION.txt
  • Nuspec file for project
  • Build script
    • Downloads nuget.exe if missing
    • Performs nuget restore on solution
    • Builds solution in debug or release mode
    • Runs unit tests
    • Updates assembly info with correct version numbers
    • Packages project into nuget package
    • Publishes to nuget repository

In action

First initialize a new project using the syntax crane init {project name}
crane-1

It creates a directory using the the project name given in the init command
crane-2

You can immediately build the project. Just run .\build.ps1 from the project directory
crane-3

Here’s what it looks like in Visual Studio if you open the solution file:
crane-4

Advertisements

How does Xamarin.IOS aka monotouch work?

Xamarin is a software development framework that allows developers to build applications for iOS and Android platforms using c# and the .Net framework. The SDK has separate requirements for developing iOS and Android application. The part of the SDK targeting iOS development is referred to as Xamarin.iOS or monotouch (the original name of the project)

Requirements for developing iOS applications using Xamarin.iOS
Apple Macintosh Computer Running OSX Lion or greater (10.7 >)
Apple Developer Program membership $99 per year, allows downloading of iOS SDK and publication of applications to the Apple app store
iOS SDK and Xcode Required during compilation, and optionally can be used to design graphical user interfaces using it’s inbuilt graphical designer
iOS Device Simulator Part of the SDK allows running of applications during the development process
Xamarin studio or Visual Studio Not strictly necessary, however does automate the build process
Knowledge of c# c# is the main language supported by Xamarin.iOS

Table 1 (Xamarin, Inc)

Mono is an open source implementation of the .NET Framework which can run across multiple operating systems, Windows, Linux and OSX. Mono is based on ECMA standards and is ABI (application binary interface) compatible with ECMA’s Common language infrastructure (CLI).

Xamarin.iOS compiles c# source code against a special subset of the mono framework. This cut down version of the mono framework includes additional libraries which allow access to iOS platform specific features. The Xamarin.iOS compiler, smsc, takes source code and compiles it into an intermediate language, ECMA CIL (common intermediate language), however it does not produce ECMA ABI compatible binaries unlike the normal mono compiler, gmcs or dmsc. This means any 3rd party .Net libraries you want to include in your application will need to be recompiled against the Xamarin.iOS subset of the mono framework using smsc.

Once a Xamarin.iOS application has been compiled into CIL it needs to be compiled again into native machine code that can run on an iOS device. This process is carried out by the SDK tool ‘mtouch’, the result of which is an application bundle that can be deployed to either the iOS simulator or an actual iOS device, such as an iPhone or iPad.

Diagram showing how monotouch aka xamarin.ios works?

Due to restrictions placed by Apple, the iOS kernel will not allow programs to generate code at runtime. This restriction has severe implications for software systems that run inside a virtual machine using just-in-time compilation. Just-in-time compilation takes the intermediate code, for example mono CIL and compiles it at runtime into machine code. This machine code is compatible for the device it is running on at the time of execution.

To work around this restriction the mtouch tool compiles the CIL ahead of time. A process that the mono team describe as AOT, ahead of time compilation. See: http://docs.xamarin.com/guides/ios/advanced_topics/limitations

Tagged , ,

Running nuget on mono

Well the documentation states that the nuget command-line tool does indeed work with mono

Does NuGet support Mono?

The command-line application (nuget.exe) builds and runs under Mono and allows you to create packages in Mono.

So I merrily install nuget to my home directory ~/. Run the command mono ~/nuget and get the error message:

Problem

WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v2.0.50727

Screen Shot 2012-05-06 at 11.04.32

Solution

Turns out the simple solution is to specify the absolute .net version:

mono –runtime=v4.0.30319 NuGet.exe

 and voila!

Screen Shot 2012-05-06 at 11.11.57

Tagged ,

The imported project “C:\Program Files\MSBuild\Microsoft.Office.InfoPath.targets” was not found

If you get this error message, which I did this morning opening up someone else’s SharePoint solution, make sure you have InfoPath installed.

Microsoft Visual Studio

 

Once I installed the InfoPath client application  with .Net Programmability Support, see below, the targets file was installed to the MSBuild directory.

Microsoft Office Enterprise 2007

Tagged , ,

Visual Studio 2008 SP1 Crashes when exiting the application, in module ModName:msenv.dll

After recently increasing my monitor setup to 3 flat screens! I decided to embark on the ultimate 2-window Visual Studio layout, docking most of my non-text editor windows on monitor 2. After lots of precision placements of windows, I thought I had better close Visual Studio so that it saves my new layout. Well fat chance!

Visual Studio threw up the depressing “Microsoft Visual Studio has encountered a Problem and needs to close.”

Microsoft Visual Studio has encountered a problem and needs to close

 

For a laugh I decided to fire off the error report via the “Send Error Report” button. The subsequent confirmation button had a link on it which I almost missed.

Visual Studio 2008 Send Error Report

 

Clicking on this link took you to a rather generic looking Windows Error Reporting page:

Windows Error Reporting Page

However out of curiosity I followed the link to the KB article, expecting it to be next to useless in solving my issue. However imagine my surprise when the article was 100% relative!

KB 960075 Fixes issues with Visual Studio 2008 SP1 IDE crashes when changing the window layout. Hooray for Windows Error reporting, it actually works {on incredibly rare occasions}.

 

UPDATE: I ended up reading the comments on http://code.msdn.microsoft.com/KB960075 before installing the hotfix and “Window->Reset Window Layout” fixed the crashes for me. In the end I didn’t bother to install the hot fix.

 

2nd UPDATE: Okay so I *DID* have to install it in the end, and it worked fine.

Tagged , ,

SharePoint can not debug assemblies

If you are ever having problems getting Visual Studio to break into your code and you develop by deploying your dll’s into the GAC, it’s probably down to mismatching PDB’s.

  1. Do a Clean Solution
  2. Rebuild the solution
  3. Re-Gac all your dll’s
  4. Reattach to IIS processes

Other hints

Locked files in the GAC

Some times a process will take a lock on an assembly and if, like me, you use WSPBuilder to re-gac your assemblies, you might not notice that it fails to re-gac them. Crack open process explorer, find the rogue process and “Get Some”. Usually Visual Studio is the culprit here.

Tagged ,

Restoring an old friend – Visual Studio 2008 Create GUID tool

Remember to recreate a link to guidgen.exe (Guid generator tool) after installing Visual Studio 2008. For some reason it’s no longer out of the box?

 

  1. Choose the Tools -> External Tools...
  2. Title: Create &GUID
  3. Click the Browse (…) button and find the guidgen.exe in the C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\ folder.

See a better crafted posting with pretty pictures and idiot proof step-by-step guide@ http://karinebosch.wordpress.com/2009/05/28/create-guid-in-visual-studio-2008/

Tagged ,

My SVN Global Ignore Pattern for C# and Resharper

*\bin* *\obj* *.suo *.user *.bak **.ReSharper** **\_ReSharper.** StyleCop.Cache

Tagged , , ,