Error Message :"The type 'TEntity' must be a reference type in order to use it as parameter 'T' in the generic type or method 'XXXXX' (CS0452) -"
I got a line of code like this:
Code
public class HibnerateRepository<TEntity, TId> : IRepository<TEntity, TId> | |
...... | |
public IList<TEntity> GetAll() |
That sounds alright, but I got an Error Message :"The type 'TEntity' must be a reference type in order to use it as parameter 'T' in the generic type or method 'XXXXX' (CS0452) -".
Well, that is a common mistake and easy to fix.
Code
public class HibnerateRepository<TEntity, TId> : IRepository<TEntity, TId> where TEntity:class | |
...... | |
public IList<TEntity> GetAll() |
SharpDevelop 4.0
Visual Studio 2010 is in the market for a little while. That sounds like no opensource alternative for .Net 4.0 until now. SharpDevelop 4.0 Beta 1 is released. I have tried that. So far, my first impression is slower. I guess that is because the UI is heavy rewritten in WPF. I think most of people will agree WPF got a better appearance and runs slower. But it got a feature I want for long time. Windows forms designer for WPF. Now, you can use the form desginer to edit xaml. That's great! By the way, in release notes, they do not recommend to use the form designer for editing .net 2.0 winfrom files. I tried that, so far, I have not faced any major issues. Well, they don't recommend that, I think you should not do that.
Lastly, so far, I am very happy to the new version. It looks better and got more features!
C# in iPhone
I found that actually you can develop iPhone app in C#. There is an application from Novell, MonoTouch. I read the documentations, it seems to be directly interface with the native iPhone OS. That sounds quite nice and it supports iPhone OS. Although it sounds powerful, it is not a freeware. Even the professional edition costs $399!
Set the icon of a window in WPF
Setting the Icon of a window in WPF is very simple! In your window xaml, you need to put the filename of your icon file in icon attribute, like the following:
Code
<Window x:Class="GUIDGenerator.Window1" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="GUIDGenerator" Height="300" Width="300" Icon="generator.ico" | |
> |
Moreover, please the properties in the icon file. The build action sets to be "Content" and Copy to output directory sets to "Always".
TableLayoutPanel can hold only one control
I was tried to drop two buttons into TableLayoutPanel(Winforms). I can't do it. I thought TableLayoutPanel should works very similar with GridPanel in WPF. It should hold multiple controls. I thought that should be the problem my SharpDevelop. So, I tried to upgarde my SharpDevelop to the latest, version 3.2. It still doesn't. Thus, I believe TableLayoutPanel can hold only one control.
To solve this issue, the solution is very similar, just dropping a panel inside the cell of TableLayoutPanel. That works! Panel control can multiple controls.