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.

Leave a Reply

Your email address will not be published. Required fields are marked *