.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Help working with serializable object that contains a non serializable member

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :ASP.Net

Hey guys, I am running into an issue at my job that I was hoping someone in this community could help me out with.

I have been tasked with fixing an issue a user control is having that someone else built.  The user control is a filter control.  It contains a filter control class that holds the raw data for the filter control.  One of the members of the filter control is an Object DataSource.  The page that contains the user control will make a call to add a control which in turn instantiates the filter control class.  One of the arguments passed into the calling method is the object datasource which can be anything from a stored procedure to a list or a datatable returned from the data layer.

Initially the filter control class was stored in view state but then serialization issues started occuring.  It was moved to session state where a random bug was reported that we were unable to recreate at our end.  Also, as my understanding would have it serialization issues that occur in view state will also occur in session state since the object is still undergoing serialization.  So I have been tasked with moving the object from session state and coming up with some other mechanism.

Here is the solution I came up with:

Mark the object DataSource property with the <nonserializable> attribute.  Then either ser

View Complete Post

More Related Resource Links

How to make linq Object Serializable... 'System.Data.EnumerableRowCollection is not marked as Seriz


Dear All,

Is it possible to make the linq object as serializable. I need to pass the serialized Data as parameter to the Remoting Method.

My LinQ Query is as follows

 Dim LinqQuery = From R In dsEdit.Tables(0) _

                    Where R.Field(Of Integer)("ID") < 400 _

                    Select R


The Definition of ZipObject is as follows.



  Public Function ZipObject(ByVal obj As Object) As Byte()

        Dim ms

Mark an Object as Serializable in Run Time



I'm using a third part component that has a problem with serialization because the developers probably forgotten to prefix the control with the [Serializable()] or something like this..

So, the control causes an exception when needs to be serializable.


Would it be possible to mark that control as serializable? Or, going deeper, would it be possible to patch the assembly (or .exe) to correct the issue? How could I do that?


Thanks in advance.

How to connect the OledbCommand object with another Member Function

protected void GridViewTest_RowDeleting(object sender, GridViewDeleteEventArgs e)
       int deleteKey = Int32.Parse(GridViewTest.DataKeys[e.RowIndex].Value.ToString());
       OleDbCommand deleteCommand = new OleDbCommand();
       deleteCommand.CommandType = CommandType.StoredProcedure();
           deleteCommand.Parameters.AddWithValue("@empid", deleteKey);
 private DataTable  Connection1(string Storedprocedure)
       using (OleDbConnection MyConnection = new OleDbConnection(ConfigurationManager.AppSettings[0].ToString()))
           OleDbDataAdapter MyAdapter = new OleDbDataAdapter(Storedprocedure, MyConnection);
           DataTable MyTable = new DataTable();
           return MyTable;

Hello Members,

           I need one help..I Don't know how to connect the command object with
another Member function...
I tried something in the above code...But i got error...Please put me in right direction...


Is SMO classes like Database serializable?

Quick question, can I use xml serialization on SMO objects, like new XmlSerializer(typeof(Database)); thanks.

how make log4net serializable

Hello, im working with log4net ( http://logging.apache.org/log4net/release/features.html ). I need to make log4net serializable. Have anyone a idea how this works? greetingshttp://get.lima-city.de

serializable class or linq to xml?

Hello, which one is better or which one do you prefer when you program client side webservice? serializable class or linq to xml=   Thanks

Workflow persistence with a non-serializable variable

I'm using Entity Framework and WF4. I want to be able to persist a workflow but one of my variables in the workflow is an EF ObjectContext. Is there a way to make the workflow persist-able and when it re-hydrates, has a fancy new ObjectContext instance?Blades Don't Need Reloading...

How to persist workflow with non-serializable arguments

I have a workflow that has some arguments for underlying components (DAL implementation, email sender etc). It also has a  WCF data contract and other serializable arguments. I need to persist and unload this workflow and then resume later on. It is throwing an exception because it is trying to serialize and persist all the workflow arguments. Is there a way to get the serializer to persist only those arguments that can be serialized?

How to share non-serializable objects between pages?

Hello I want to share some non-serializable objects (control collection) between multiple pages in my application. I'm not able to store it in the session since the objects are non-serializable. Is there any other way to achieve this? Thank youRegards NLV Visit SharePoint User group - India

WPF TreeView child nodes - collection is not a member of the first level nodes object



I was wondering if i could use a TreeView to display data from 2 separate collections where both collections are members of the same object. For example i have a view model that has 2 observable collections:



Each model has a property Brand which specifies the brand for each model. What i want to do is bind the first level to the Brands collection and the second level to the Models collection and specify a filter.

Thanks in advance.

how to create class and acess member using object

hi i am a new user to C# .net can any body help me to write a new class in c# AND HOW TO ACESS methods and members using its object thnks in advance

SSAS Calculated Member not working as expected in a SSRS report


Dear forum guys, I have a simple cube to analyze my customer's sales. I have a Time Dimension, a Product Dimension (with a few hierarchys) and a couple measures (sales and purchase amounts).


I also have defined a few Calculated Members, in particular the average sales and purchase amount over the last 12 months from the selected month.


I need to show the results in a SSRS Report: the user must select a month and the report needs to show the sales and purchase amount of the selected month and the average of the previous 12 months (both for sales and purchases).


Everything works perfectly if I test the cube using the Cube Browser or Excel 2007 as a client.


When I define the SSRS Report I cannot get to work with the calculated members (the average): I get strange numbers which are much higher than the real numbers.


I've tried both Matrix and Table reports.


Can anyone suggest me what I'm doing wrong: I think this should be a very common mistake.


Best regards



Reference to a non-shared member requires an object reference in code generated by ASP.NET



I am working on converting a project from C# to VB and am facing this weird issue. 1 page cannot compile and I get the reference error, but the weird thing is that the compiler shows the error as coming from ASP.NET generated code. Visual Studio shows me that error is coming from my ASPX page. I cannot seem to figure out why or where this error is occuring. Also if I take the inherits attribute out I don't get the compilation error. The code in aspx page is below:

<%@ Page Language="VB" AutoEventWireup="true" CodeBehind="diff.view.aspx.vb"  Inherits="MR.ControlApp.diffview" MasterPageFile="~/Site1.Master"%>

<asp:Content ID="Header1" ContentPlaceHolderID="head" runat="server">

    Page: <select onchange="sel(this);">
        Dim j As Integer = 0
        While j < pageCount
           <option <%= IIf(currentPage = ( j + 1 ), "selected", "")  %> value="<%= j+1 %>"><%= j + 1 %></option>
        <%j = j + 1
        End While
    <% 'Print(); %>
    <div style="font-family: verdana; font-size: 10pt; font-weight: bold">
        MDM Data Inconsiste

Reference to a non-shared member requires an object reference


This is detaining me from transferring my website to another webserver.  So much for a seamless transfer. I had no problem ever with the following line on several pages on my site:

  <%Dim cust As New BusinessLogic.SiteUser(CInt(BusinessLogic.SiteUser.CurrUserID))%>

This line is used on 4 other pages just like above. The vs 2008 is whining with this error message.

I opend my 2005 vb.net site into VS 2008 and it asked me if I wanted to upgrade for .net 3.5 and I said yes. I cannot debug and I get the mentioned error. Visual Studio 2005 gives NO such error. What is the issue?  How can I resolve this?

What is a non-shared member? I don't think I should have to change anything in my business logic area. Can this line, which does 2 things, be done in the code behind? Or partly in the code behind so as to not give this error?

<%@ Page Language="VB"  AutoEventWireup="false" CodeFile="paypal_featured.aspx.vb" Inherits="paypal_paypal_featured" title="Untitled Page" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <form action="<%=paypalurl%&g

Reference to a non-shared member requires an object reference


I do not receive this error when I open my website application in vs 2005. When I open in vs 2008, I get this error. What gives?

These lines are underlined in blue:

<%Dim cust As New BusinessLogic.SiteUser(CInt(BusinessLogic.SiteUser.CurrUserID))%>

Businesslogic area is imported into each of 3 pages with this line. 

Cannot use Serializable Transaction Level with Linked Servers


I am testing an upgrade from SQL Server 2005 to SQL Server 2008 R2.  I have a stored procedure which attempts to use the serializable transaction isolation level on a distributed transaction (linked server). 

The query fails on SQL Server 2008 R2 with 


OLE DB provider "SQLNCLI10" for linked server "SERVER1" returned message "No transaction is active.".

Msg 7391, Level 16, State 2

The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "SERVER1" was unable to begin a distributed transaction.


If I change the isolation level to read committed, the transaction succeeds.  This same procedure worked on SQL Server 2005 but now fails on SQL Server 2008 R2 using the same isolation level. 

Is there a way to get this isolation level to work with linked servers on SQL Server 2008 R2?

(401) Unauthorized Error working with Client Object Model


Hi All,

I'm tryiing to retrieve a list of document libraries from a sharepoint site, here is my code, this is a windows app
  public string[] GetDocumentLibraries(string siteUrl)
            Collection<string> libraries = new Collection<string>();
                //Creating the client context object, establishing the connection from the client to the remote SharePoint site
                ClientContext ctx = new ClientContext(siteUrl);

                //Authetication on SP site
                string user = ConfigurationManager.AppSettings["user"];
                string password = ConfigurationManager.AppSettings["password"];

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend