Visual Studio: Detect type presence in a container

I have the following situation: I do serialization of an object: MyBOContainer.

It throws me serialization errors "the class MyUIElement is not marked as serializable".

Normally, I shouldn't have such a class between myBOContainer elements(or their children). However, I have some public List<object> and theoretically this is possible.

Question: How can I test in the Debug Mode in VS if an instance of object myBOContainer contains(deepsearch) or not instances of MyQueryTestClass type?

Answers


If you can't predict what the data is, then IMO you shouldn't be serializing that element.

Since it appears you are using BinaryFormatter, perhaps add some [NonSerialized]:

[NonSerialized]
private List<object> foo = ...

Also, events are the usual cause of confusion on this; I would annotate any events, too:

[field:NonSerialized]
public event EventHandler SomeCrazyEvent;

or if you are doing explicit event implementations, set [NonSerialized] on whatever backing field is holding the delegate or EventHandlerList.

(well, strictly speaking I just wouldn't be using BinaryFormatter in the first place - using a serialize that isn't so tied to the internal class structure can only be a good thing; but that is a rant for another day...)


Need Your Help

Problems with authentication with Laravel 5

mysql laravel-5

I am trying to login a user with laravel 5.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.