开发者

VS2010 with .Net 2.0 WinForms app - Error on binding to generic List

I've recently converted to Visual Studio 2010 and ran the conversion on a project that worked perfectly in VS2008. Things are not so sunny in Visual Studio 2010.

This is a .Net 2.0 WinFor开发者_JAVA百科ms project that makes a lot of use of binding ListViews and Grids to Generic Lists so taking out the Generic Lists isn't feasible.

I get the following error message (anonymised for posting purposes):

Could not find a type for a name.  The type name was   
'System.Collections.Generic.List`1[[MyAttribute, Domain, Version=1.0.0.5,    
Culture=neutral, PublicKeyToken=71c8708be064889a]], mscorlib, Version=2.0.0.0, 
Culture=neutral, PublicKeyToken=b77a5c561934e089'. Line 134, position 5.
C:\Projects\MyProject\Control.resx

The problem goes away if I roll the project up to .net 4.0 but this project has to target .net 2.0 so that's not a suitable long-term solution.

Googling around finds plenty of posts from people /having/ the problem but none that I can see from people who have solved the problem so any help would be greatly appreciated.

Ta.


Delete the section in the .resx file and then also delete the line in the designer.cs (resources.GetObject("..."))that's loading that resource.

Then try opening the control in the designer and both should get regenerated, you might get a null reference exception depending on the control that's exposing a property that gets set in the designer. For me I was able to ignore and continue.

After the designer appears you can compare the resx file and see that whatever object it was is now serialized a little differently. Also if it's your custom control and you are exposing a generic list property consider putting the [Browsable(false)] attribute on it first so you cannot set the value from the designer and the designer will not automatically set it to a new value.

What was happening in my case was an empty generic list was serialized to the resx file and then after upgrading visual studio the list no longer serialized the same way.


Not much to info to go on here..

Looks like a serialization problem. Are you serializing a collection property on control? Does it need to be serialized? If it's not needed try adding a DesignerSerializationVisibility attribute. It tries to serialize all properties by default.


We are finding this too... Our VS2008 projects that contain a property that exposes a generic list will get the same exception when building. We are using MSBuild 3.5 on a VS2010 build machine (it has 2010 installed, but we can't upgrade the projects to 2010 format yet).

Our error comes from a form: TBDEV830.resx (143): Could not find a type for a name. The type name was 'System.Collections.ObjectModel.ObservableCollection`1[[T1.Tb.SideBar.ISideBar, T1.Tb.SideBar, Version=1.0.3702.18460, Culture=neutral, PublicKeyToken=null]], WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Line 143, position 5.

Have found a few posts from other forums and no-one seems to have found a solution yet:

One article states to add [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] but this has no affect.

Another article (http://www.go4answers.com/Example/tfs2008-tfs2010-migration-upgrade-3526.aspx) states to load it in the IDE and asks if that helps isolate the problem, but that would mean upgrading the project to 2010 format, which ew can't do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜