what is wrong with my code? this was working in a previous release (was using <TViewData> before) , but in preview 4 it errors out......
public class MyViewPage<TModel> : ViewPage<TModel>
{ }
Error 2 The type 'TModel' must be a reference type in order to use it as parameter 'TModel' in the generic type or method 'System.Web.Mvc.ViewPage<TModel>' E:\Hosted-Projects\CSharpCMS\CSharpCMS.Core\MVC\CMSViewPage.cs 10 18 CSharpCMS.Core
MVCNoob
Member
19 Points
74 Posts
problem when inheriting from ViewPage<>
Aug 26, 2008 06:28 PM|LINK
what is wrong with my code? this was working in a previous release (was using <TViewData> before) , but in preview 4 it errors out......
public class MyViewPage<TModel> : ViewPage<TModel>
{ }
Error 2 The type 'TModel' must be a reference type in order to use it as parameter 'TModel' in the generic type or method 'System.Web.Mvc.ViewPage<TModel>' E:\Hosted-Projects\CSharpCMS\CSharpCMS.Core\MVC\CMSViewPage.cs 10 18 CSharpCMS.Corelevib
Star
7702 Points
1099 Posts
Microsoft
Re: problem when inheriting from ViewPage<>
Aug 26, 2008 06:50 PM|LINK
The error message is telling you that you have to limit TModel to be a reference type. To fix, see the highlighted code below:
public class MyViewPage<TModel> : ViewPage<TModel> where TModel : class { }
MVCNoob
Member
19 Points
74 Posts
Re: problem when inheriting from ViewPage<>
Aug 28, 2008 03:51 AM|LINK
I've never seen that syntax before, I'll have to read up more into this.......
thanks!
levib
Star
7702 Points
1099 Posts
Microsoft
Re: problem when inheriting from ViewPage<>
Aug 28, 2008 03:58 AM|LINK
If you're interested, there's a fairly good explanation at http://msdn.microsoft.com/en-us/library/d5x73970.aspx.