VS 2012 Designer throws TypeLoadException - by Shane Gilbert

Status : 


Sign in
to vote
ID 782051 Comments
Status Active Workarounds
Type Bug Repros 2
Opened 3/25/2013 10:36:17 AM
Access Restriction Public


I have a base class for my edit forms that takes two generic arguments, the entity class for the form and the type of the primary key. These are declared in the xaml asTypeArguments:

<f:BaseEditView x:Class="CLO.Surface.Views.LandUseEvaluationView"
             x:TypeArguments="data:LandUseEvaluation, sys:Guid"
             Style="{StaticResource EditView}"
             d:DesignHeight="1200" d:DesignWidth="800">

Here is the declaration for the class itself:

public partial class LandUseEvaluationView : BaseEditView<LandUseEvaluation, Guid>

If I open the designer I get this exception:

GenericArguments[0], 'CLO.DatabaseModel.LandUseEvaluation', on 'WPFFramework.BaseEditView`2[T,U]' violates the constraint of type parameter 'T'.
   at System.RuntimeTypeHandle.Instantiate(RuntimeTypeHandle handle, IntPtr* pInst, Int32 numGenericArgs, ObjectHandleOnStack type)
   at System.RuntimeTypeHandle.Instantiate(Type[] inst)
   at System.RuntimeType.MakeGenericType(Type[] instantiation)

This worked fine before in VS 2010.

 I was getting a different error before installing Update 2 RC4 but it still would not open in design mode as it would complain about the TypeAgurments property in the XAML.

Sign in to post a comment.
Posted by Deon [MSFT] on 6/6/2014 at 9:53 AM
Thank you for using Visual Studio and for reporting this bug. We are happy to let you know that this issue has been fixed in Visual Studio 2013 Update 2. If you already have Visual Studio 2013, you can upgrade to Update 2 for free or you can install a trial version from: http://go.microsoft.com/?linkid=9832436
Posted by Kelly R Cannon on 1/2/2014 at 4:52 PM
Hey Shane and Davut,

Shane - The error you're seeing in VS 2013 is (most likely) due to the space between data:SampleEntity, and sys:Guid when you set your TypeArguments. I see an invalid XAML error message prior to deleting that space, but after deleting the space it renders okay. If you're still seeing an error after deleting that space, could you give me a little more information about what type of error you're seeing?

Davut - The fix is currently only available in Visual Studio 2013 and not currently under consideration for inclusion in Visual Studio 2012 due to the risk/costs and limited number of customers who have encountered the issue. Very sorry for the inconvenience.

Posted by Shane Gilbert on 12/30/2013 at 11:35 AM
So this still errors in VS 2013 as well. Any update as to when it might be fixed?
Posted by Davut Gürbüz on 12/28/2013 at 10:41 AM
I also get this error ' violates the constraint of type parameter' .
Indeed it doesn't violates. The Bug marked as fixed so could you please how can we get the fix.

Note:I'm facing this error on VS2012 Premium.
King regards!
Posted by Kelly [MSFT] on 4/24/2013 at 3:07 PM
Hey Shane,
Sorry for the delay. Thanks so much for reporting this issue. We've been able to reproduce it locally and hope to have a fix in a future release of Visual Studio.
Thanks again,
Posted by Shane Gilbert on 4/11/2013 at 12:19 PM
When should I expect an update on this issue?
Posted by Microsoft on 3/27/2013 at 12:29 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Shane Gilbert on 3/26/2013 at 8:44 AM
I have submitted a sample project that demonstrates the problem
Posted by Microsoft on 3/25/2013 at 8:49 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project to demonstrate this issue so that we can conduct further research?

We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 3/25/2013 at 10:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)