473,573 Members | 5,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP: Serializing and Deserializing

I have written an Office Add-in for Excel using VB.NET and the .NET
1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I
want to add a User Settings/Prefereneces dialog and allow the user to
specify some settings and I need to persist these settings between
runs. I made a serializable class which uses the BinaryFormatter to
serialize/deserialize the setttings.

Serialization works great. However, when I try to deserialize the
saved settings on subsequent runs the following exception is thrown:

MyAddin.OnConne ction Exception: Cannot find the assembly MyAddin,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= null.
at
System.Runtime. Serialization.F ormatters.Binar y.BinaryAssembl yInfo.GetAssemb ly()
...

To get around this, it seems I need to register my assembly in the
GAC. So, I generated a key pair using the following command:

C:sn -k "D:\MyAddin\SNK ey.snk"

and added the following line to my AssemblyInfo.vb file:

<Assembly: AssemblyKeyFile ("D:\MyAddin\SN Key.snk")>

When I try to build with this I get the error:

Unable to emit assembly: Referenced assembly
'Interop.Micros oft.Office.Core ' does not have a strong name

I'm confused about how to get this to work. I just want to read and
write my user settings to disk.

Any help is greatly appreciated.
-Frank

Feb 4 '07 #1
7 2814
This is a previous response to the problem you are describing.
Hope this helps.

*************** *************** *************** *****
If anyone is interested, I ended up solving this problem.

If you serialize in one app, and want to deserialize in another app, an
exception will be thrown if dotnet can't load the assembly that did the
serializing.

Option 1: register the serializing app in the GAC. I didn't try this,
but I assume it would work
Option 2: use the SerializationBi nder class to effectively fool the
deserializing app into thinking that it did the serializing:
when setting your BinaryFormatter up to deserialize, set the Binder
property to the class below:

BinaryFormatter b = new BinaryFormatter ();
b.Binder = new FooDeserializat ionBinder();
myClasss = (MyClass) b.Deserialize(s tream);

sealed class FooDeserializat ionBinder : SerializationBi nder
{
public override Type BindToType(stri ng assemblyName, string
typeName)
{
return Type.GetType(ty peName + ", " +
Assembly.GetExe cutingAssembly( ).FullName);
}
}
*************** *************** *************** ********

"fjlaga" <fj****@sbcglob al.netwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
>I have written an Office Add-in for Excel using VB.NET and the .NET
1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I
want to add a User Settings/Prefereneces dialog and allow the user to
specify some settings and I need to persist these settings between
runs. I made a serializable class which uses the BinaryFormatter to
serialize/deserialize the setttings.

Serialization works great. However, when I try to deserialize the
saved settings on subsequent runs the following exception is thrown:

MyAddin.OnConne ction Exception: Cannot find the assembly MyAddin,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= null.
at
System.Runtime. Serialization.F ormatters.Binar y.BinaryAssembl yInfo.GetAssemb ly()
...

To get around this, it seems I need to register my assembly in the
GAC. So, I generated a key pair using the following command:

C:sn -k "D:\MyAddin\SNK ey.snk"

and added the following line to my AssemblyInfo.vb file:

<Assembly: AssemblyKeyFile ("D:\MyAddin\SN Key.snk")>

When I try to build with this I get the error:

Unable to emit assembly: Referenced assembly
'Interop.Micros oft.Office.Core ' does not have a strong name

I'm confused about how to get this to work. I just want to read and
write my user settings to disk.

Any help is greatly appreciated.
-Frank

Feb 5 '07 #2
fjlaga,

Making things everytime more complex to get a solution is seldom helping.
Just try to find the most easiest way don't knit.

http://www.vb-tips.com/dbpages.aspx?...c-61641f5c8d9d

Cor

"fjlaga" <fj****@sbcglob al.netschreef in bericht
news:11******** **************@ q2g2000cwa.goog legroups.com...
>I have written an Office Add-in for Excel using VB.NET and the .NET
1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I
want to add a User Settings/Prefereneces dialog and allow the user to
specify some settings and I need to persist these settings between
runs. I made a serializable class which uses the BinaryFormatter to
serialize/deserialize the setttings.

Serialization works great. However, when I try to deserialize the
saved settings on subsequent runs the following exception is thrown:

MyAddin.OnConne ction Exception: Cannot find the assembly MyAddin,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= null.
at
System.Runtime. Serialization.F ormatters.Binar y.BinaryAssembl yInfo.GetAssemb ly()
...

To get around this, it seems I need to register my assembly in the
GAC. So, I generated a key pair using the following command:

C:sn -k "D:\MyAddin\SNK ey.snk"

and added the following line to my AssemblyInfo.vb file:

<Assembly: AssemblyKeyFile ("D:\MyAddin\SN Key.snk")>

When I try to build with this I get the error:

Unable to emit assembly: Referenced assembly
'Interop.Micros oft.Office.Core ' does not have a strong name

I'm confused about how to get this to work. I just want to read and
write my user settings to disk.

Any help is greatly appreciated.
-Frank

Feb 5 '07 #3
Gino,

Do you know that this is a VB.Net newsgroup. Although you try to be helpful,
don't think by that only to the OP. This newsgroup is more searched on
Google than only by the OP's.

Therefore please use VB.Net code.

Cor

"Gino" <so*****@micros oft.comschreef in bericht
news:O8******** ******@TK2MSFTN GP02.phx.gbl...
This is a previous response to the problem you are describing.
Hope this helps.

*************** *************** *************** *****
If anyone is interested, I ended up solving this problem.

If you serialize in one app, and want to deserialize in another app, an
exception will be thrown if dotnet can't load the assembly that did the
serializing.

Option 1: register the serializing app in the GAC. I didn't try this,
but I assume it would work
Option 2: use the SerializationBi nder class to effectively fool the
deserializing app into thinking that it did the serializing:
when setting your BinaryFormatter up to deserialize, set the Binder
property to the class below:

BinaryFormatter b = new BinaryFormatter ();
b.Binder = new FooDeserializat ionBinder();
myClasss = (MyClass) b.Deserialize(s tream);

sealed class FooDeserializat ionBinder : SerializationBi nder
{
public override Type BindToType(stri ng assemblyName, string
typeName)
{
return Type.GetType(ty peName + ", " +
Assembly.GetExe cutingAssembly( ).FullName);
}
}
*************** *************** *************** ********

"fjlaga" <fj****@sbcglob al.netwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
>>I have written an Office Add-in for Excel using VB.NET and the .NET
1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I
want to add a User Settings/Prefereneces dialog and allow the user to
specify some settings and I need to persist these settings between
runs. I made a serializable class which uses the BinaryFormatter to
serialize/deserialize the setttings.

Serializatio n works great. However, when I try to deserialize the
saved settings on subsequent runs the following exception is thrown:

MyAddin.OnConn ection Exception: Cannot find the assembly MyAddin,
Version=2.0.0. 0, Culture=neutral , PublicKeyToken= null.
at
System.Runtime .Serialization. Formatters.Bina ry.BinaryAssemb lyInfo.GetAssem bly()
...

To get around this, it seems I need to register my assembly in the
GAC. So, I generated a key pair using the following command:

C:sn -k "D:\MyAddin\SNK ey.snk"

and added the following line to my AssemblyInfo.vb file:

<Assembly: AssemblyKeyFile ("D:\MyAddin\SN Key.snk")>

When I try to build with this I get the error:

Unable to emit assembly: Referenced assembly
'Interop.Micro soft.Office.Cor e' does not have a strong name

I'm confused about how to get this to work. I just want to read and
write my user settings to disk.

Any help is greatly appreciated.
-Frank


Feb 5 '07 #4
Beautiful! It worked like a charm. (the code snippet provided was
easily translated into VB.NET). Thank you.
-Frank

On Feb 4, 3:55 pm, "Gino" <some...@micros oft.comwrote:
This is a previous response to the problem you are describing.
Hope this helps.

*************** *************** *************** *****
If anyone is interested, I ended up solving this problem.

If you serialize in one app, and want to deserialize in another app, an
exception will be thrown if dotnet can't load the assembly that did the
serializing.

Option 1: register the serializing app in the GAC. I didn't try this,
but I assume it would work
Option 2: use the SerializationBi nder class to effectively fool the
deserializing app into thinking that it did the serializing:

when setting your BinaryFormatter up to deserialize, set the Binder
property to the class below:

BinaryFormatter b = new BinaryFormatter ();
b.Binder = new FooDeserializat ionBinder();
myClasss = (MyClass) b.Deserialize(s tream);

sealed class FooDeserializat ionBinder : SerializationBi nder
{
public override Type BindToType(stri ng assemblyName, string
typeName)
{
return Type.GetType(ty peName + ", " +
Assembly.GetExe cutingAssembly( ).FullName);
}}

*************** *************** *************** ********

"fjlaga" <fjl...@sbcglob al.netwrote in message

news:11******** **************@ q2g2000cwa.goog legroups.com...
I have written an Office Add-in for Excel using VB.NET and the .NET
1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I
want to add a User Settings/Prefereneces dialog and allow the user to
specify some settings and I need to persist these settings between
runs. I made a serializable class which uses the BinaryFormatter to
serialize/deserialize the setttings.
Serialization works great. However, when I try to deserialize the
saved settings on subsequent runs the following exception is thrown:
MyAddin.OnConne ction Exception: Cannot find the assembly MyAddin,
Version=2.0.0.0 , Culture=neutral , PublicKeyToken= null.
at
System.Runtime. Serialization.F ormatters.Binar y.BinaryAssembl yInfo.GetAssemb *ly()
...
To get around this, it seems I need to register my assembly in the
GAC. So, I generated a key pair using the following command:
C:sn -k "D:\MyAddin\SNK ey.snk"
and added the following line to my AssemblyInfo.vb file:
<Assembly: AssemblyKeyFile ("D:\MyAddin\SN Key.snk")>
When I try to build with this I get the error:
Unable to emit assembly: Referenced assembly
'Interop.Micros oft.Office.Core ' does not have a strong name
I'm confused about how to get this to work. I just want to read and
write my user settings to disk.
Any help is greatly appreciated.
-Frank- Hide quoted text -

- Show quoted text -

Feb 5 '07 #5
Yes.
And the whole programming world knows that it's C# code on a VB.net
newsgroup, without you telling them.
And you don't have to whine about being politically correct (real men don't
whine).
And the vast majority of vb.net programmers can easily read a C# snipet to
get an idea for a solution (as was indicated by the response to my post,
from the original poster)
And if I see this same question again, I'm going to send this same post.
Gino, from the Socialist Republic of Cambridge
Massachusetts.
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Gino,

Do you know that this is a VB.Net newsgroup. Although you try to be
helpful, don't think by that only to the OP. This newsgroup is more
searched on Google than only by the OP's.

Therefore please use VB.Net code.

Cor

"Gino" <so*****@micros oft.comschreef in bericht
news:O8******** ******@TK2MSFTN GP02.phx.gbl...
>This is a previous response to the problem you are describing.
Hope this helps.

************** *************** *************** ******
If anyone is interested, I ended up solving this problem.

If you serialize in one app, and want to deserialize in another app, an
exception will be thrown if dotnet can't load the assembly that did the
serializing.

Option 1: register the serializing app in the GAC. I didn't try this,
but I assume it would work
Option 2: use the SerializationBi nder class to effectively fool the
deserializin g app into thinking that it did the serializing:
when setting your BinaryFormatter up to deserialize, set the Binder
property to the class below:

BinaryFormatte r b = new BinaryFormatter ();
b.Binder = new FooDeserializat ionBinder();
myClasss = (MyClass) b.Deserialize(s tream);

sealed class FooDeserializat ionBinder : SerializationBi nder
{
public override Type BindToType(stri ng assemblyName, string
typeName)
{
return Type.GetType(ty peName + ", " +
Assembly.GetEx ecutingAssembly ().FullName);
}
}
************** *************** *************** *********

"fjlaga" <fj****@sbcglob al.netwrote in message
news:11******* *************** @q2g2000cwa.goo glegroups.com.. .
>>>I have written an Office Add-in for Excel using VB.NET and the .NET
1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I
want to add a User Settings/Prefereneces dialog and allow the user to
specify some settings and I need to persist these settings between
runs. I made a serializable class which uses the BinaryFormatter to
serialize/deserialize the setttings.

Serializati on works great. However, when I try to deserialize the
saved settings on subsequent runs the following exception is thrown:

MyAddin.OnCon nection Exception: Cannot find the assembly MyAddin,
Version=2.0.0 .0, Culture=neutral , PublicKeyToken= null.
at
System.Runtim e.Serialization .Formatters.Bin ary.BinaryAssem blyInfo.GetAsse mbly()
...

To get around this, it seems I need to register my assembly in the
GAC. So, I generated a key pair using the following command:

C:sn -k "D:\MyAddin\SNK ey.snk"

and added the following line to my AssemblyInfo.vb file:

<Assembly: AssemblyKeyFile ("D:\MyAddin\SN Key.snk")>

When I try to build with this I get the error:

Unable to emit assembly: Referenced assembly
'Interop.Micr osoft.Office.Co re' does not have a strong name

I'm confused about how to get this to work. I just want to read and
write my user settings to disk.

Any help is greatly appreciated.
-Frank



Feb 7 '07 #6
Gino,

Een grote aantal mensen actief in deze nieuwsgroep kan eenvoudig Nederlands
lezen en toch doen ze dat niet.

Cor

"Gino" <so*****@micros oft.comschreef in bericht
news:u$******** ******@TK2MSFTN GP03.phx.gbl...
Yes.
And the whole programming world knows that it's C# code on a VB.net
newsgroup, without you telling them.
And you don't have to whine about being politically correct (real men
don't whine).
And the vast majority of vb.net programmers can easily read a C# snipet to
get an idea for a solution (as was indicated by the response to my post,
from the original poster)
And if I see this same question again, I'm going to send this same post.
Gino, from the Socialist Republic of Cambridge
Massachusetts.
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>Gino,

Do you know that this is a VB.Net newsgroup. Although you try to be
helpful, don't think by that only to the OP. This newsgroup is more
searched on Google than only by the OP's.

Therefore please use VB.Net code.

Cor

"Gino" <so*****@micros oft.comschreef in bericht
news:O8******* *******@TK2MSFT NGP02.phx.gbl.. .
>>This is a previous response to the problem you are describing.
Hope this helps.

************* *************** *************** *******
If anyone is interested, I ended up solving this problem.

If you serialize in one app, and want to deserialize in another app, an
exception will be thrown if dotnet can't load the assembly that did the
serializing .

Option 1: register the serializing app in the GAC. I didn't try this,
but I assume it would work
Option 2: use the SerializationBi nder class to effectively fool the
deserializi ng app into thinking that it did the serializing:
when setting your BinaryFormatter up to deserialize, set the Binder
property to the class below:

BinaryFormatt er b = new BinaryFormatter ();
b.Binder = new FooDeserializat ionBinder();
myClasss = (MyClass) b.Deserialize(s tream);

sealed class FooDeserializat ionBinder : SerializationBi nder
{
public override Type BindToType(stri ng assemblyName, string
typeName)
{
return Type.GetType(ty peName + ", " +
Assembly.GetE xecutingAssembl y().FullName);
}
}
************* *************** *************** **********

"fjlaga" <fj****@sbcglob al.netwrote in message
news:11****** *************** *@q2g2000cwa.go oglegroups.com. ..
I have written an Office Add-in for Excel using VB.NET and the .NET
1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I
want to add a User Settings/Prefereneces dialog and allow the user to
specify some settings and I need to persist these settings between
runs. I made a serializable class which uses the BinaryFormatter to
serialize/deserialize the setttings.

Serializatio n works great. However, when I try to deserialize the
saved settings on subsequent runs the following exception is thrown:

MyAddin.OnCo nnection Exception: Cannot find the assembly MyAddin,
Version=2.0. 0.0, Culture=neutral , PublicKeyToken= null.
at
System.Runti me.Serializatio n.Formatters.Bi nary.BinaryAsse mblyInfo.GetAss embly()
...

To get around this, it seems I need to register my assembly in the
GAC. So, I generated a key pair using the following command:

C:sn -k "D:\MyAddin\SNK ey.snk"

and added the following line to my AssemblyInfo.vb file:

<Assembly: AssemblyKeyFile ("D:\MyAddin\SN Key.snk")>

When I try to build with this I get the error:

Unable to emit assembly: Referenced assembly
'Interop.Mic rosoft.Office.C ore' does not have a strong name

I'm confused about how to get this to work. I just want to read and
write my user settings to disk.

Any help is greatly appreciated.
-Frank



Feb 7 '07 #7

"Cor Ligthert [MVP]" wrote
Gino,

Een grote aantal mensen actief in deze nieuwsgroep kan eenvoudig
Nederlands lezen en toch doen ze dat niet.

Cor
That's true.

A large number of people actively in this newsgroup can read simple
Dutch and nevertheless does not do that.

Gino
Feb 7 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3128
by: Jeff T. | last post by:
Hello, I have an existing set of C# classes that encapsulate our application data. They are in a heirachy with each subclass defining more specific types of data. I would like to serialize these data objects as XML but perserve the relationships in the XML document. For example, if my classes were: public class GenericItem { }
3
1888
by: Bruno Jouhier | last post by:
Is there a way to serialize a graph of objects and get the output as an XML document, without first serializing to text and then parsing the text (I know how to do this but I find it really silly and inefficient). I googled around and from what I found, the answer is NO. Am I missing something obvious? Is there something new coming in .NET...
5
4782
by: Alfonso Morra | last post by:
Hi, I am writing a messaging library which will allow me to send a generic message structure with custom "payloads". In many cases, a message must store a non-linear data structure (i.e. "payload") using pointers. Examples of these are binary trees, hash tables etc. Thus, the message itself contains only a pointer to the actual data....
2
3090
by: Earl Teigrob | last post by:
I am saving and restoring value types such as Int32, DateTime and Boolean in strings. I was wondering if there is a mechanism build into .NET for serializing and deserializing these to string format. I can, of course, serialize a class to a file, either binary or XML, but this is not what I am looking for. Currently I am using ToString() or...
3
10150
by: MioTheGreat | last post by:
I know how to take a single hashtable, and then use a binaryformatter and a filestream to dump it to a file, but I need to serialize and deserialize a hashtable inside a class. I've been trying this: public Hashtable Directions; public byte DirectionsSerialized { get
0
1101
by: Michael Maercker | last post by:
Hi! I'm about to go nuts over my serializing problem. This is my situation: I have a Data-Class that can have children of the same class which are stored in a hashtable, i.e: X has A as a child A has B as a child When an object is changed it raises an Updated-Event which the
15
2001
by: Cesar Ronchese | last post by:
Hi, I built the sample code showing the problem with dates when viewed at different machines, different Time Zones and transported via Remoting. The zip can be downloaded here: www.carsoftnet.com.br/temp/sample_error_date.zip
0
2765
by: j.askey | last post by:
Hi, I have a class that is inherited from Panel. Because Panel is not serializable, I have implemented the ISerializable interface on this class and I can sucessfully save and load classes from disk by serializing and deserializing with a binary formatter. Now, I have another class that happens to contain an array of the above classes......
2
1835
by: Kurious Oranj | last post by:
I've currently got a database structure which is something like:- class a - member type - effective date and:- class b - client name
2
2870
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hi, I know this will sound like a lot of hand waving, and I'll be glad to supply some sample code if necessary, but I thought something obvious might jump out at someone without doing so. Anyway, I have a structure that has several members including an array of strings. I assign the elements of the string array from the .Text property of...
0
7709
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8039
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8218
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8091
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6435
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5605
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3738
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.