VS 2005 SQL CE / xmta Error

Here’s another in the world of strange VS.NET 2005 error messages.  I have a project that I added some SQL CE code to and I get this message:

genasm.exe(1) : error There was an error finalizing type . Type ‘System.Data.SqlServerCe.SqlCeException, System.Data.SqlServerCe, Version=3.0.3600.0, Culture=neutral, PublicKeyToken=3be235df1c8d2ad3, Retargetable=Yes’ was loaded in the ReflectionOnly context but the AssemblyBuilder was not created as AssemblyBuilderAccess.ReflectionOnly.

After a little searching I found a couple of articles that describe the same problem.

The second one describes a long workaround from Microsoft to get around the problem, and the other has lots more.  But the both include the magic trick of changing the Build Action for xmta files to Content.  Which is all it takes to get around this crazy problem.
Updated Info:

I now have run in to another version of this same problem.  I have a Windows Form that contains a protected method containing a generic List as an out parameter.

protected virtual ResponseBase GetItems(out List<ItemVO> lstItems)
lstItems = new List<ItemVO>();
return ResponseBase.SuccessResponse;

I receive the error if the method is public or protected, but not private and the parameter is a ref or out. My solution was to change it to return an array of ItemVOs instead.  This is actually the scenerio described in the first article.

SQL Mobile 2005 – Editing Table Data

In SQL Server CE 2.0 it was always painful to create the mobile database, and populate the data. However, with SQL Mobile 2005 and VS.NET 2005 Microsoft has come a long way to making the SQL Mobile database much easier to manage. While creating a new database is pretty well document, editing the table records is more obscure.

While developing the database is handled easily in the Microsoft SQL Server Management Studio, editing the database records requires VS.NET 2005. The “trick” to editing the database table is to use the Server Explorer (View->Server Exploer) in VS.NET to open the table for editing.

The first set is to add a Data Connection to add your mobile database to the project. This can be done by selecting the Data Connections option in the Server Explorer and choosing on the “Add Connection…” option in the pop-up menu. This will launch the “Add Connection dialog which you can use to specify the location and password of the database. For this example I am using the NorthWinds.sdf mobile database.

Add Connection - Northwinds

Once the Data Connection is successfully added you can now use the Server Explorer window to examine the various properties of the database. In order to open a table to edit, you must first expand the Table tree to see a list of all of the tables that are in the current database.

Server Explorer - Northwinds Database

Finally by selecting the table and choosing “Open” for the pop-up menu (right mouse) you can open the table and start editing. In this case I chose the customer database table.

Edit the Customer Table

SQL Mobile 2005 – Error: Not Enough Storage is Available

Here’s another in a long list of cryptic error messages. In this case I am developing a local database component for our SNAPRetail applications and on opening the database for the first time I get a SQLCEException with the message “Not enough storage is available to complete this operation”. Initially, I thought it was a problem with my database, but it is after a little searching I found a post (http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=895861&SiteID=17) on the Microsoft Technet forums that describes the problem as a “DLL Squeeze” and to open the connection to the database at the start of the appliation.

A little more research reveals that the DLLS that are being loaded are sqlceqp30.dll, sqlcese30.dll, sqlceer30en.dll, sqlceme30.dll which are the minium required for SQL Mobile to run.