.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

Re-signed my assembly, now I cannot deserialize objects saved before

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :.NET Framework
I have a strange situation about object deserialization. My assemblies all had strong name but signed with different key pair file - I did not realize it is better to have all assemblies signed with the same key pair file before. And now I need to use one single key pair file to resign all assemblies for some other purpose. But After I did that, my program cannot deserialize objects saved by previous version of the assemblies anymore. Use XML object as example, In the XML file, the object is saved with this kind of information, <MyObject version="1" referenceType="MyObject, Assembly1, Version=, Culture=neutral, PublicKeyToken=f89a7ef07260c910"> <.... omited ... > </MyObject> The problem is that, the Assembly1 is resigned and the public key token of the running assembly does not match the token in the xml file. The same problem happens in my binary objects. Any gurus have some idea to deserialize objects after I resigned the assemblies? My program saved hundreds of objects, I hope there is some solution which will work with all of those objects.    

View Complete Post

More Related Resource Links

"Cannot install this assembly into the global assembly cache The assembly might not be signed" when

In a workflow that I developed earlier I could debug from within Visual Studio 2008. 
It would deploy automatically with no errors when I used DEBUG -> START NEW INSTANCE.

Now when I try to debug it I am getting the error:

Cannot install this assembly into the global assembly cache:  MYDLL.DLL. The assembly might not be signed.

But it is Signed with the same key.snk as before when it debugged with no problems.

How do I fix this?

Deserialize - unable to find an Assembly .....



I've got a really strange error. I'm using a fairly standard method to implement the IClonable interface, basically I serialize my object to a memory stream and then stream it back again.

This all works fine in the .Net runtime environment and if I use a test application. However, I need to run as a COM control inside of an HTML page (long story, but I am embedding it in the home page pane of Outlook).

Anyway everything works fine except this routine. It fails when trying to deserialize with "Assembly not found". I added some debug code to load the assembly dynamically and that all works fine. It can't be a version issue as I am serializing and deserializing the same object in the same method.

I've traced where the framework is loading the assembly and it looks pretty simple:

internal static Assembly LoadAssemblyFromStringNoThrow(string assemblyName)

[RESOLVED] Cannot deserialize an array of objects (of variable type)


Hi helpful folks and gurus

I have been developing an application which uses a derived class inherited from TreeView, with the aim of putting custom objects on the nodes.  The method I have been using is to have a variable array against the node (of type object) which contains variables in custom classes to contain each of the variables associated with the node.

The two problems I had to overcome were, how to serialize a TreeView, and how to serialize an array of objects (of variable type).  Good thing is I overcame both of these with some work of some other folks (and 3 days of my own work).

TreeView: http://www.codeproject.com/KB/vb/TreeViewDataAccess.aspx?display=Print

Object Array (NOT of variable type). adapted to variable type: http://www.codeproject.com/KB/XML/xmlserializerforunknown.aspx

Serialization works a charm..  Deserialization naddah..  Can find no sufficent documentation for me to debug and work on manual deserialization (of only one variable, the variable array of objects).  All others are handled by the regular deserializer.

Effectively the xmlserializerforunknown URL provided a solution which manually handles both the type handling and the handling of the object array.

The main error I'm having lies in the ReadXml, function.  I just can't align the xml with the code.


FormatterAssemblyStyle, Deserialize in different assembly



 I have 2 applications saving a serialized object in a flat file, one app has a PublicKeyToken the over is null. I know need to read and deserialized both files type in the same application (definition of the serialized objet is the same). I try to use FormatterAssemblyStyle as simple as I understoud the should not take care of the assembly... But this does not work... My code :


  public static Object Deserialisation(string fileName)
   FileStream fs = new FileStream(fileName, FileMode.Open);
   BinaryFormatter bf = new BinaryFormatter();
   bf.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
   Object o;
   o = bf.Deserialize(fs);
   return o;


Please Help.

Thanks in advance.


Need help with objects and arrays


I have an objuct that I declared like this:

    Class DailyStats
        Dim _day As String
        Dim _hour As String
        Dim _impressions As String
        Dim _clicks As String
        Property Day() As String
                Return _day
            End Get
            Set(ByVal value As String)
                _day = value
            End Set
        End Property
        Property Hour() As String
                Return _hour

How to check for null/empty strings on dynamic objects?


What is the proper way to check for null or empty strings on dynamic objects? This is the only solution I've found so far:

if (admin.PasswordHash.GetType() == typeof(DBNull) || admin.PasswordHash == string.Empty)

If the field is null, the object returned is DBNull.Value, but if the field is empty string, it's return as a System.String object. This makes it impossible to do regular "admin.PasswordHash == DBNull.Value" check, as that will fail whenever the field has been set to empty string. Is my example the right (and only) way to go?

how to serialize objects ??


Is there any way or process to serialize the the objects?? i am trying to store the instance of few control in viewstate but it shows error msg that it is not a serialized object. should i perform some steps to serialize the objects ???

Error: Encountered multiple versions of the same assembly with GUID...try pre-importing...TlbImp


Hi!  Can someone tell me how I can troubleshoot the following error: "Encountered multiple versions of the same assembly with GUID...try pre-importing one of these assemblies".

The website developed in VS 2010 (.Net 3.5). This error is only received on my workstation.  Another person developing the site does not experience this issue at all.  Also, not sure if this matters, but on my workstation the 'Assembly Information...' dialog contains no values even though the 'AssemblyInfo.vb' file does specify values for the title, desc, etc.  The GUID being referenced in the error is the main project of the three projects within the solution.

I tried looking through the GAC, but do not see any references to the projects or DLLs in the VS solution and am not sure what else/where to look.

If I delete the copy of the solution on my local machine and pull down a copy from source control (AnkhSVN) the solution will build with no error.  Once I make any changes, such as adding a new aspx file, then the error is received.

I can provide any additional information needed.

The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must



This is frustrating, and I don't know how to solve it.

I have a strange problem. I am adding a LinqDatasource object, and set the context:

        protected void LinqDataSource_ContextCreating(object sender, LinqDataSourceContextEventArgs e)
            e.ObjectInstance = new KaruselaDataContext(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

Then I get this error:
The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


On web.config I already have this:
<add assembly="System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

NOTE: The datacontext is in a different project (DLL proect) where I added a refernce to System.Data.Linq.

is there another way adding a refernce to a web project? or only though teh web.config?


MySql.Data assembly problem



I added refernece MySql.Data to my project. My web.config looks like that:

<?xml version="1.0"?>
                <add assembly="MySql.Data, Version=, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>

But when in ServerExplorer I try "Add Connection..." I can't find "MySql Database" in the "Choose Data Source" dialog box?

What the problem can be?

Registering controls of current assembly object reference NOT set error


Hi There,

I have created a simple ASP.net Web Application (2.0) and have added a web user control.

Now in my page I have added this control but I have registered like this,

<%@ Register Assembly="WebApplication1" Namespace="WebApplication1" TagPrefix="Custom" %>

Which means I want to access all the controls in my current Web Application project

Then I have added my user control like this,

<Custom:MyUserControl ID="MyUserControl1" runat="server" PublicProperty="Hello" />

Every thing is fine but when I execute the project, NO control on my user control gets "instantiated" and thus I receive error "Object Reference Not Set"

Note that My Control has,

1) Public property PublicProperty as String

2) 1 Label control

In Load Event Handler I am setting Text property of Label Control to PublicProperty. Here object reference NOT set error occurs (which means Label control is NOT initialized).

I don't want to register my control using Src, TagPrefix etc. Any ideas?


Could not load file or assembly - Web Deployment Project



I have the following projects in a solution :

- A Web Application

- A Class Library

- A Web Deployment project

The Web Application compiles and run fine when I don't go through the Web Deployment Project. However when I try to use that, I get the following error:

Error 1 An error occurred creating the configuration section handler for hibernate-configuration: Could not load file or assembly 'NHibernate' or one of its dependencies. The system cannot find the file specified. (F:\Folke\Folke.csproj_deploy\Release\web.config line 4) 1 1 Folke.csproj_deploy

"An error occurred creating the configuration section handler for hibernate-configuration: Could not load file or assembly 'NHibernate' or one of its dependencies. The system cannot find the file specified. (F:\Folke\Folke.csproj_deploy\Release\web.config line 4)"

This is the beginning of my Web.config:


Class which contains an array of objects of type "Class2"



1  Partial Class _Default
2  Inherits System.Web.UI.Page

3 Public Function Ohjoy(ByVal X As Integer) As Integer
4 Dim theClass As New Class1 '= New Class1()
5    theClass.ReSize(0)
6    theClass.myBaby(0).GetName(0) = "Hello" 'Property Chars is read only'
7    Return 1
8 End Function
I have a first class named "Class1". I have a second class named "Class2" Class2, is a member of class 1,
and is implemented as an array of objects of type Class 2.

If I try and call the Accessor GetName() my hard coded value "Hello" in my accessor is not returned? Only
an alpha character like "T"

Also if I try and assigne a value using the setter GetName() it does not work, and the compiler gives me
an error message "property Chars is ReadOnly? Does anyone know what is wrong in my code? Line 6 above


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class

Public Class Class1
    Dim bs As Integer
    Public myBaby() As Class2
    Public myB As Class2
    Public Function ReSize(By

Cutting Edge: Expando Objects in C# 4


The .NET Framework 4 introduces some new features that enable you to go beyond static types. We explore dynamically expando objects and demonstrate how they can be used like dynamically updatable dictionary objects.

Dino Esposito

MSDN Magazine July 2010

CLR Inside Out: Migrating an APTCA Assembly to the .NET Framework 4


The CLR security model in the Microsoft .NET Framework 4 has undergone some substantial changes, including the adoption of "Level2" transparency, similar to the Silverlight security model. Mike Rousos provides an in-depth explanation of how that will likely impact authors of AllowPartiallyTrustedCallers (APTCA) libraries.

Mike Rousos

MSDN Magazine March 2010

Cutting Edge: Pros and Cons of Data Transfer Objects


After a brief refresher on procedural and object based patterns for organizing the business logic layer, the author focuses on data transfer objects and the impact they have on the development of the software project.

Dino Esposito

MSDN Magazine August 2009

Test-Driven Design: Using Mocks And Tests To Design Role-Based Objects


Use Test-Driven Development with mock objects to design object oriented code in terms of roles and responsibilities, not categorization of objects into class hierarchies.

Isaiah Perumalla

MSDN Magazine June 2009

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