Tuesday, May 01, 2012

If you install Visual Studio 11 and VSMonoTouch stops building with mscorlib problems...

If you install Visual Studio 11 and VSMonoTouch stops building with mscorlib problems...

or if you are seeing problems referencing simple Core types like System.Action...

Then:

1. Set the flag in Properties > Build > Advanced ... which says "Do not include mscorlib"

2. Make sure you have followed the vsmonotouch setup instructions:

A note on mscorlib.dll

The MonoTouch templates does not include an explicity reference to mscorlib.dll. The default behavior of Visual Studio 2010 is that all projects contain an implied reference to mscorlib.dll. The problem is that the implied version of mscorlib.dll is different from the MonoTouch mscorlib.dll, which will give you warnings in the editor. The project will compile just fine without the reference.

The other problem is how Visual Studio 2010 will not let you add a new reference to mscorlib.dll as it allready have that reference implied. The way to work around this is to add it manually by editing the .csproj file.

  <ItemGroup>
    <Reference Include="mscorlib" />
    <Reference Include="monotouch" />
    <Reference Include="System" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Core" />    
  </ItemGroup> 

Visual Studio will now pick up the MonoTouch version of mscorlib.dll, and the project will still build just fine in MonoDevelop. The next update of the extension will enable you to automatically add this reference if missing.

No comments:

Post a Comment