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

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 WinForms 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.

Related

Visual Studio 2010 keeps complaining about Invalid XML although there is none (WP7)

I experience a strange behaviour in Visual Studio 2010 when creating Windows Phone 7 apps. After some time VS starts to complain about Invalid XAML although there is no problem and the app compiles and runs just fine.
It bugges me because I cannot use the visual desingner saying "Exception was thrown on "DataTemplate": Invalid XML" and there is a DataTemplate higlighted in the code. The data template is always ok, VS does not complain about it when copy-pasted to another project.
I found out that problematic are usually the DataTemplates with custom converters or when usin g classes like PhonePerformance.
Sometimes the error is "Exception thrown was due to document error: Invalid XML" and nothing is even highlighted in the XAML file.
I tried reinstalling .NET. Visual Studio etc. and the problem occurs on two separated machines so I do not think it is specific to my configuration. It may be specific to my code.
Anyone experienced similar behaviour?
When using XAML, if you reference a library that needs to be evaluated but can't be at design time you get this kind of error. You can turn off the visual editor and just work in XAML - that will stop the error (and save you time).
You reinstalled .NET and VisualStudio??? You should have just spun up a second instance, opened the solution in both, then attached the debugger from one to the second and opened up the visual editor. It would have told you exactly what in your code was causing the problem. Also DesignerProperties.IsInDesignMode in your converters. Jeez. You wasted so much time :(
As for design time data, that's tricky. Either you have DesignTimeDataWithDesignTimeCreatableTypes that aren't or DesignData that can't create proxies for your real types (for whatever reason, had this issue many times deep in the past).
The only way to figure this out is to debug one instance from another. Its actually not that hard. I do it alot (debugging WF4 ActivityDesigners).
A friend has found a solution and you would not believe where the problem is. This happens if you have a space in the name of your assembly. I found out that I really have a space in assembly name in all the problematic projects, renamed the assemblies and the designer works again.
The solution is also mentioned here http://forums.silverlight.net/t/115011.aspx/1

Expression Blend Sketchflow reference build error

I'm working on a mobile application prototype in Expression Blend 4. Up until now it has worked fine, but after re-opening the program I can no longer build the project. I get 4 errors that are all pretty much the same:
The primary reference "System.Windows.Controls.Toolkit, Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7ceec85d7bea7798e" which has a higher version "5.0.5.0" than the version "2.0.5.0" in the current target framework."
Yeah, pretty lengthy error message (which I had to type out as you can't copy from the error output!). The other 3 errors are identical but refer to different .NET Framework Assemblies (System, System.Core and System.Windows)
Any pointers on how to fix this?
It sounds like you're trying to edit a Silverlight 5 project in Expression Blend 4. That won't work: you need the Blend Preview for Silverlight 5. Last I checked, Microsoft has not yet released final bits for this. :/

Could not load file or assembly Microsoft.Expression.Interactions and GalaSoft.MvvmLight.Extras.WPF4

I am facing unknown problem while using Prism 4. We implement business solution in MVVM pattern. For that I have used
1. Microsoft.Expression.Interactions
2. System.Windows.Interactivity
3. GalaSoft.MvvmLight.Extras.WPF4
for Interaction.Triggers, CallMethodAction and EventToCommand.
<SWI:Interaction.Triggers>
<SWI:EventTrigger SourceObject="{Binding ElementName=txtName}" EventName="GotFocus">
<MEI:CallMethodAction TargetObject="{Binding Path=DataContext,ElementName=txtName}" MethodName="txtName_GotFocus"></MEI:CallMethodAction>
</SWI:EventTrigger>
<SWI:EventTrigger SourceObject="{Binding ElementName=txtName}" EventName="KeyUp">
<GMEWCMD:EventToCommand Command="{Binding Path=DataContext.cmdtxtNameKeyUpEvent,ElementName=txtName}" PassEventArgsToCommand="True">
</GMEWCMD:EventToCommand>
</SWI:EventTrigger>
</SWI:Interaction.Triggers>
Everything is working fine but now we required to make whole system loosely couple we choose prism 4. We already achieved this but above code create following problem as below.
Could not load file or assembly 'Microsoft.Expression.Interactions, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
If I comment above code everything is working fine. I don't know what an issue. Does PRISM 4 not support above assemblies?
Please help us to get rid from this problem.
Thank you
This commonly happens to me when I reference both Microsoft.Expression.Interactions and System.Windows.Interactivity in a view that belongs to a module, but I fail to also add those references to the project that acts as the shell.
I had a similar problem with Prism in Visual Studio 2012. The XAML editor would fail with the same exception.
The solution was to install Microsoft Expression Blend SDK. The assembly should be part of SDK. Allegedly, it is necessary for binding between control events and commands in XAML and some code may require it.
I had the same problem during a Prism 6.1 composite app using .NET 4.5.2, where i was referencing in one of the modules (class library) the Microsoft.Expression.Interactions & System.Windows.Interactivity.
Eventually i had to reference the same dlls in the Desktop project (where bootstrapper and Shell belong)

Custom building SGEN assemblies and including in installer

I've been rather confused by some SGEN stuff. I've enable the generation of serialization assemblies for one of my projects. Originally I got the follow error which I believe I've solved by doing some caspol stuff on a remote assembly.
Unable to load one or more of the request types. Retrieve the
LoaderExceptions propery for more information
Now however, I don't get an assembly generated. Adding some debugging/verbose output provides the message "SS.dll does not contain any types that can be serialized using XmlSerializer". I've read that this is because of a proxy switch applied by VS. The odd thing is it doesn't seem to be a problem with any other project.
So if I disable the proxy switch (example here) it seems to work. The linked build events however seem to do all projects. I don't know enough about MSBuild to tweak to just a single project, does anyone know what I need to change?
Additionally, if this change is made, is there a way I can automatically include this in a installer (VDProj)? I can't statically link to the SS.XmlSerializers.dll because the each dev uses a custom path.
Discovered the following post which talks about adding the <SGenUseProxyTypes>Off</SGenUseProxyTypes> to the csproj file which seems to work :)

How to change VS2010 Add Reference box filter?

I'm getting used to the new IDE (it's vc# express), but the first contact is somewhat confusing. When I open the Add Reference dialog and switch to the .NET tab, a label above the assembly list states: "Filtered to:.NET Framework 4". And it's true - I can reference .NET 4.0 assemblies only plus things like XNA 3.1. However I can't see older assemblies i.e. Managed DirectX libs, which are obviously installed on my computer as there was no trouble with adding a ref to them in vc#08.
What is this? How to change the filter? The label is read-only. These sound like dull guy's questions, but I'm out of luck in finding an answer and there is no intuitive solution.
Thanks in advance.
Change your new application to target the .NET Framework 4 and not .NET Framework 4 Client
"When you create a new application, some projects target the .NET Framework 4 Client Profile by default."
http://msdn.microsoft.com/en-us/library/cc656912.aspx
"If you are targeting the .NET Framework 4 Client Profile, you cannot reference an assembly that is not in the .NET Framework 4 Client Profile. Instead you must target the .NET Framework 4. "
We've created a tool that will help you to achieve your goal. Muse VSReferences will allow you to add a Global Assembly Cache reference to the project from Add GAC Reference menu item.
Regards
s
How to change the filter?
Very simple - you must change the Target .NET Framework for your project, as whole. It's not pain :) just RMB on project name in Solution Explorer->Properties->Application tab->Target Framework(combobox). Select what you want. Change combobox == change filter in Add Reference dialog. ;)
I was having a similar problem until I noticed that the older .NET assemblies were actually in the list, there's just some really strange sorting going on. If you sort by assembly name, you should see them in the proper order.
Another possibility is to go into your project’s Properties page and change the Target Framework from 4.0 to your desired Framework. You will then need to reload you application. Now your Reference should be there. Once you have added the Reference you want, change back to 4.0 and again reload.
Hope this helps.
If, for instance, your project is Framework 4 and you want to reference say Microsoft.Deployment.WindowsInstaller (which is not in the filtered list of the .NET tab), then go to the Browse tab and enter the path to the reference item e.g. C:\Program Files\Windows Installer XML v3.5\SDK\Microsoft.Deployment.WindowsInstaller.dll

Resources