Visual Studio .NET - Edit / Update all .cs files together in VS 2012

Asked By SP on 25-Jun-14 03:36 PM

Hi Friends,

I have a requirement to change all .cs files including classes and code-behind pages. I have to put keyword [Serializable] just above the class declaration like 

[Serializable]
Public Class Class_Name

I have hundreds of such pages in my solution, so I am trying to find a way through which all pages/classes can be updated together.

Please let me know if you have any useful trick for this.

Thanks.
Robbe Morris replied to SP on 25-Jun-14 04:02 PM
Uh why are you doing this?  What would be the point of making a business logic class serializable?  Especially code behind pages in an ASP.NET app?
SP replied to Robbe Morris on 25-Jun-14 04:07 PM
Don't know Robbe. Its just an experiment and instructions from manager. We still have to discuss about this in next project meeting.
Robbe Morris replied to SP on 25-Jun-14 04:22 PM
Does your manager know what serialization is for and what uses it?  I highly doubt it if they are asking you to make all code behind pages serializable.
SP replied to Robbe Morris on 26-Jun-14 03:02 PM
Not sure. But they just wants to test if it works for whole application without any trouble as they want to use state server.
Robbe Morris replied to SP on 26-Jun-14 03:12 PM
You don't want to use ASP.NET State Server.  It is flaky at best.  Trust me...  ScaleOutSoftware.com has a relatively inexpensive product that works quite well for managing session state in a web farm.

Neither of these options require a class to be decorated with Serializable "unless" an instance of that class is going to be stored in session or in some way serialized into and out of a given format.  A code behind class or some other business logic class would never meet this criteria.  Methods and Events are not serialized anyway.

There are performance drawbacks and compiler speed drawbacks to unnecessarily decorating classes with the Serializable attribute.  You only want to use this on classes that warrant it.
SP replied to Robbe Morris on 03-Jul-14 11:57 AM
Hi Robbe,

Just saw your reply. 

Here is the details (before seeing your reply) which we need to serialize the classes:

We are creating a state server for porting issue. Currently we are porting all changes after office hours and in that duration if any user is using the portal, he is automatically logged out.
So the team is planning to create another state server and transfer the data including session to another server which the porting process is running, so the end user should not get any issue or doesn't know about anything running backstage.

Can you please share your views on this? 
Robbe Morris replied to SP on 03-Jul-14 12:27 PM
ScaleOut Software handles this exact scenario and you don't have to write any code for it.  It is specifically designed for load balances scenarios where you are deploying updates to a web site in a web farm environment.

Their product still handles the scenario described in the article.

http://www.nullskull.com/articles/scaleout_server.asp

That said, none of what you describe has anything to do with setting all your code behind and business logic classes to be Serializable.