Critical Development

Language design, framework development, UI design, robotics and more.

Visual Studio Build Bug in CF Controls Project using Generics

Posted by Dan Vanderboom on April 21, 2008

So there I was, minding my own business, creating some custom controls in a reusable framework project.  I needed to apply some design-time attributes, and because I’m working with Compact Framework, I attempted to add my DesignTimeAttributes.xtma file to accomplish this, which I’ve done many times before.

Bang!  I got an error message: “genasm.exe has encountered a problem and needs to close.  We are sorry for the inconvenience.”  In the task list was this error: “Process is terminated due to StackOverflowException.”  Stack overflow?!

I checked (and checked again) to make sure that my .xtma file was properly formatted, which it was, and I simplified it to include only a single DesktopCompatible attribute; being a boolean, I figured it was hard to mess that up (compared to something trickier like a Designer attribute).  But alas, I was stumped, and for the past week or two gave up and went without the attributes in that project, putting the majority of my controls in a separate project.

Today I decided I was on the mission of isolating the problem and getting to the bottom of this.  While I don’t know the root cause (I’ve submitted a bug report to Microsoft), I can reproduce the problem and describe the pitfall so some poor soul can find it while Googling for help.

It happens in Compact Framework projects.  To reproduce it, create a CF 3.5 project (I chose class library), and add a file with the following code:

public class atree<T> where T : atree<T>
{
} 

public class btree : atree<btree>
{
}

 

Note that if these classes are changed from public to internal, the problem disappears.

Then add a DesignTimeAttributes.xtma file, change nothing in it, and try to build.  Mine looks like this:

<?xml version="1.0" encoding="utf-16"?>
<Classes xmlns="http://schemas.microsoft.com/VisualStudio/2004/03/SmartDevices/XMTA.xsd">
</Classes>

 

That’s it, and I get the nasty errors described above.  I’m really curious to know what genasm.exe is doing, how it’s using some recursive algorithm to examine somewhat self-referencing generic definitions (I admit that the generics constraint in the code above is a bit on the odd side).

About these ads

7 Responses to “Visual Studio Build Bug in CF Controls Project using Generics”

  1. Tarek Haoula said

    Hi Dan,

    I reported a similar Genasm with generics bug to Microsoft and it is really sad to see that the problem still has not been resolved.

    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=117736

    I hope we can get some action this time round.

    Kind Regards,
    Tarek

  2. Dan Vanderboom said

    That does seem very similar. Looks like they have a number of problems with generics playing nicely with forms. According to http://weblogs.asp.net/jezell/archive/2008/04/09/net-3-5-sp1-visual-studio-2008-sp1-details.aspx, we should be seeing a beta of SP1 soon. Let’s hope these generics problems are solved there!

  3. ilker said

    In the properties of DesignTimeAttributes.xmta (right click on it and select Properties) set BuildAction to Content and try to build again. I hope this will get the build successfully

  4. someone said

    @Ilker “Setting the xmta file to content prevents the creation of the asmeta file. How did you get around that.”

  5. Overflight said

    Somehow i missed the point. Probably lost in translation :) Anyway … nice blog to visit.

    cheers, Overflight.

  6. Dan Vanderboom said

    Missed the point of what? The article? I was trying to use my Tree data structure (which uses this generic constraint pattern) in the same project as my custom controls. This was just a bug I found.

  7. [...] Visual Studio Build Bug in CF Controls Project using Generics [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: