I have created an add-in for VS.NET and when it starts I want the add-in to
read the options from file.
I have created a class (with the [Serializable] attribute set) that contains
the options and implemented GetObjectData(SerializationInfo info,
StreamingContext context) as well as a copy constructor: protected
Options(SerializationInfo info, StreamingContext context).
The serialization process definately works. However, on startup I try to
create an instance of my Options class and deserialize the file, but I get a
SerializationException as follows:
Engine.LoadOptions: System.Runtime.Serialization.SerializationExceptio n:
Cannot find the assembly CodeStore, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=null.
at
System.Runtime.Serialization.Formatters.Binary.Bin aryAssemblyInfo.GetAssembl
y()
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.GetType(BinaryAs
semblyInfo assemblyInfo, String name)
at System.Runtime.Serialization.Formatters.Binary.Obj ectMap..ctor(String
objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[]
typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32
objectId, BinaryAssemblyInfo assemblyInfo, SizedArray
assemIdToAssemblyTable)
at
System.Runtime.Serialization.Formatters.Binary.Obj ectMap.Create(String name,
String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[]
typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32
objectId, BinaryAssemblyInfo assemblyInfo, SizedArray
assemIdToAssemblyTable)
at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWith
MapTyped(BinaryObjectWithMapTyped record)
at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWith
MapTyped(BinaryHeaderEnum binaryHeaderEnum)
at System.Runtime.Serialization.Formatters.Binary.__B inaryParser.Run()
at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.Deserialize(Head
erHandler handler, __BinaryParser serParser, Boolean fCheck,
IMethodCallMessage methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S
tream serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallMessage methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S
tream serializationStream)
at Salamander.Addins.CodeStore.Engine.Engine.LoadOpti ons() in
c:\development\codestore\engine\engine.cs:line 78
Why can't it find the assembly? It is not calling out to a separate library,
it's a single dll for the add-in and that's where the code is being called
from. The file it is trying to read is inthe same location as the dll, too.
The LoadOptions function looks like this:
internal void LoadOptions()
{
try
{
string path = GetAddInPath() + this.optionsFileName;
Stream stream = new FileStream(path + ".options", FileMode.Open,
FileAccess.Read, FileShare.Read);
try
{
IFormatter formatter = new BinaryFormatter();
this.options = (Options)formatter.Deserialize(stream); // <-- This is
line 78 where the exception is raised.
}
catch (System.Exception exc)
{
System.Diagnostics.Trace.WriteLine(exc.ToString(),
"Engine.LoadOptions");
}
finally
{
stream.Close();
}
}
catch (System.Exception exc)
{
if (exc is FileNotFoundException)
{
// No options file, so write the current default options to file.
SaveOptions();
}
else
{
System.Diagnostics.Trace.WriteLine(exc.Message, "Engine.LoadOptions");
}
}
} 4 5776
Thanks for the idea, but unfortunately I still have the same problem. Any
other ideas?
Derek.
"James X. Li" <do*********@abc.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Try to add the following line into to your add-in assembly:
[assembly:AllowPartiallyTrustedCallers] James X. Li
"news.microsoft.com" <de*********@lineone.net> wrote in message news:eA**************@tk2msftngp13.phx.gbl... I have created an add-in for VS.NET and when it starts I want the add-in to read the options from file. I have created a class (with the [Serializable] attribute set) that contains the options and implemented GetObjectData(SerializationInfo info, StreamingContext context) as well as a copy constructor: protected Options(SerializationInfo info, StreamingContext context).
The serialization process definately works. However, on startup I try to create an instance of my Options class and deserialize the file, but I
get a SerializationException as follows:
Engine.LoadOptions: System.Runtime.Serialization.SerializationExceptio n: Cannot find the assembly CodeStore, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null. at
System.Runtime.Serialization.Formatters.Binary.Bin aryAssemblyInfo.GetAssembl y() at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.GetType(BinaryAs semblyInfo assemblyInfo, String name) at System.Runtime.Serialization.Formatters.Binary.Obj ectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader,
Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) at System.Runtime.Serialization.Formatters.Binary.Obj ectMap.Create(String name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader,
Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWith MapTyped(BinaryObjectWithMapTyped record) at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWith MapTyped(BinaryHeaderEnum binaryHeaderEnum) at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.Run() at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.Deserialize(Head erHandler handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage) at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S tream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage) at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S tream serializationStream) at Salamander.Addins.CodeStore.Engine.Engine.LoadOpti ons() in c:\development\codestore\engine\engine.cs:line 78
Why can't it find the assembly? It is not calling out to a separate library, it's a single dll for the add-in and that's where the code is being
called from. The file it is trying to read is inthe same location as the dll, too. The LoadOptions function looks like this:
internal void LoadOptions() { try { string path = GetAddInPath() + this.optionsFileName; Stream stream = new FileStream(path + ".options", FileMode.Open, FileAccess.Read, FileShare.Read); try { IFormatter formatter = new BinaryFormatter(); this.options = (Options)formatter.Deserialize(stream); // <-- This
is line 78 where the exception is raised. } catch (System.Exception exc) { System.Diagnostics.Trace.WriteLine(exc.ToString(), "Engine.LoadOptions"); } finally { stream.Close(); } } catch (System.Exception exc) { if (exc is FileNotFoundException) { // No options file, so write the current default options to file. SaveOptions(); } else { System.Diagnostics.Trace.WriteLine(exc.Message,
"Engine.LoadOptions"); } } }
"news.microsoft.com" <de*********@lineone.net> wrote in
news:eA**************@tk2msftngp13.phx.gbl: I have created an add-in for VS.NET and when it starts I want the add-in to read the options from file. I have created a class (with the [Serializable] attribute set) that contains the options and implemented GetObjectData(SerializationInfo info, StreamingContext context) as well as a copy constructor: protected Options(SerializationInfo info, StreamingContext context).
The serialization process definately works. However, on startup I try to create an instance of my Options class and deserialize the file, but I get a SerializationException as follows:
Engine.LoadOptions: System.Runtime.Serialization.SerializationExceptio n: Cannot find the assembly CodeStore, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null. at System.Runtime.Serialization.Formatters.Binary.Bin aryAssemblyInfo.GetAss
e mbl y() at
I had the same problem. It went away when I also implemented
ISerializable on the objects inside the object that was related to the
errormessage.
It's very weird why this error pops up, and you can't debug it,
because it goes wrong somewhere in the deserialization code of .NET.
FB
--
Solutions Design : http://www.sd.nl
My open source .NET Software : http://www.sd.nl/software
My .NET Blog : http://weblogs.asp.net/FBouma
-------------------------------------------------------------------------
This may be too simplistic, but did you derive your class from
ISerializable? You need to both mark it as Serializable and also as derived
from ISerializable
"Derek Lakin" <de*********@lineone.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Thanks for the idea, but unfortunately I still have the same problem. Any other ideas?
Derek.
"James X. Li" <do*********@abc.net> wrote in message news:%2****************@tk2msftngp13.phx.gbl... Try to add the following line into to your add-in assembly:
[assembly:AllowPartiallyTrustedCallers] James X. Li
"news.microsoft.com" <de*********@lineone.net> wrote in message news:eA**************@tk2msftngp13.phx.gbl... I have created an add-in for VS.NET and when it starts I want the
add-in to read the options from file. I have created a class (with the [Serializable] attribute set) that contains the options and implemented GetObjectData(SerializationInfo info, StreamingContext context) as well as a copy constructor: protected Options(SerializationInfo info, StreamingContext context).
The serialization process definately works. However, on startup I try
to create an instance of my Options class and deserialize the file, but I get a SerializationException as follows:
Engine.LoadOptions:
System.Runtime.Serialization.SerializationExceptio n: Cannot find the assembly CodeStore, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null. at
System.Runtime.Serialization.Formatters.Binary.Bin aryAssemblyInfo.GetAssembl y() at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.GetType(BinaryAs semblyInfo assemblyInfo, String name) at System.Runtime.Serialization.Formatters.Binary.Obj ectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) at System.Runtime.Serialization.Formatters.Binary.Obj ectMap.Create(String name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWith MapTyped(BinaryObjectWithMapTyped record) at
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWith MapTyped(BinaryHeaderEnum binaryHeaderEnum) at System.Runtime.Serialization.Formatters.Binary.__B inaryParser.Run() at
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.Deserialize(Head erHandler handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage) at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S tream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage) at
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S tream serializationStream) at Salamander.Addins.CodeStore.Engine.Engine.LoadOpti ons() in c:\development\codestore\engine\engine.cs:line 78
Why can't it find the assembly? It is not calling out to a separate library, it's a single dll for the add-in and that's where the code is being called from. The file it is trying to read is inthe same location as the dll, too. The LoadOptions function looks like this:
internal void LoadOptions() { try { string path = GetAddInPath() + this.optionsFileName; Stream stream = new FileStream(path + ".options", FileMode.Open, FileAccess.Read, FileShare.Read); try { IFormatter formatter = new BinaryFormatter(); this.options = (Options)formatter.Deserialize(stream); // <--
This is line 78 where the exception is raised. } catch (System.Exception exc) { System.Diagnostics.Trace.WriteLine(exc.ToString(), "Engine.LoadOptions"); } finally { stream.Close(); } } catch (System.Exception exc) { if (exc is FileNotFoundException) { // No options file, so write the current default options to file. SaveOptions(); } else { System.Diagnostics.Trace.WriteLine(exc.Message,
"Engine.LoadOptions"); } } }
Yes it does derive from ISerializable. Full class listing is:
using Microsoft.Win32;
using System;
using System.Runtime.Serialization;
namespace Salamander.Addins.CodeStore.Engine
{
/// <summary>
/// Summary description for Options.
/// </summary>
[Serializable]
internal class Options: ISerializable
{
#region Class Data
internal string ServerUrl =
"http://www.salamandersoftware.biz/codestore/";
internal string LocalPath = String.Empty;
#region Proxy Settings
internal bool UseProxy = false;
internal bool BypassProxyOnLocal = false;
internal bool ProxyAuthorisation = false;
internal string ProxyAddress = String.Empty;
internal int ProxyPort = 0;
internal string ProxyUser = String.Empty;
internal string ProxyPassword = String.Empty;
#endregion
#endregion
#region Constructors
/// <summary>
/// Default Constructor.
/// </summary>
internal Options() {}
/// <summary>
/// Construct an Options object from serialization.
/// </summary>
/// <param name="info"></param>
/// <param name="context"></param>
protected Options(SerializationInfo info, StreamingContext context)
{
int version = info.GetInt32("_OptVersion");
this.ServerUrl = info.GetString("ServerUrl");
this.LocalPath = info.GetString("LocalPath");
this.UseProxy = info.GetBoolean("UseProxy");
this.BypassProxyOnLocal = info.GetBoolean("BypassProxyOnLocal");
this.ProxyAuthorisation = info.GetBoolean("ProxyAuthorisation");
this.ProxyAddress = info.GetString("ProxyAddress");
this.ProxyPort = info.GetInt32("ProxyPort");
if (version >= 2)
{
//TODO: Add encryption support to version 2.
}
else
{
// Clear text used in version 1.
this.ProxyUser = info.GetString("ProxyUser");
this.ProxyPassword = info.GetString("ProxyPassword");
}
}
#endregion
/// <summary>
/// Populates a SerializationInfo with the data needed to serialize the
target object.
/// </summary>
/// <param name="info">The SerializationInfo to populate with
data.</param>
/// <param name="context">The destination for this serialization.</param>
public virtual void GetObjectData(SerializationInfo info, StreamingContext
context)
{
info.AddValue("_OptVersion", 1);
info.AddValue("ServerUrl", this.ServerUrl);
info.AddValue("LocalPath", this.LocalPath);
info.AddValue("UseProxy", this.UseProxy);
info.AddValue("BypassProxyOnLocal", this.BypassProxyOnLocal);
info.AddValue("ProxyAuthorisation", this.ProxyAuthorisation);
info.AddValue("ProxyAddress", this.ProxyAddress);
info.AddValue("ProxyPort", this.ProxyPort);
//TODO: Add encryption to version 2.
info.AddValue("ProxyUser", this.ProxyUser);
info.AddValue("ProxyPassword", this.ProxyPassword);
}
}
}
"Dave" <kd******@wi.rr.com> wrote in message
news:eV**************@TK2MSFTNGP12.phx.gbl... This may be too simplistic, but did you derive your class from ISerializable? You need to both mark it as Serializable and also as
derived from ISerializable
"Derek Lakin" <de*********@lineone.net> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... Thanks for the idea, but unfortunately I still have the same problem.
Any other ideas?
Derek.
"James X. Li" <do*********@abc.net> wrote in message news:%2****************@tk2msftngp13.phx.gbl... Try to add the following line into to your add-in assembly:
[assembly:AllowPartiallyTrustedCallers] James X. Li
"news.microsoft.com" <de*********@lineone.net> wrote in message news:eA**************@tk2msftngp13.phx.gbl... > I have created an add-in for VS.NET and when it starts I want the add-in to > read the options from file. > I have created a class (with the [Serializable] attribute set) that contains > the options and implemented GetObjectData(SerializationInfo info, > StreamingContext context) as well as a copy constructor: protected > Options(SerializationInfo info, StreamingContext context). > > The serialization process definately works. However, on startup I
try to > create an instance of my Options class and deserialize the file, but
I get a > SerializationException as follows: > > Engine.LoadOptions:
System.Runtime.Serialization.SerializationExceptio n: > Cannot find the assembly CodeStore, Version=2.0.0.0,
Culture=neutral, > PublicKeyToken=null. > at >
System.Runtime.Serialization.Formatters.Binary.Bin aryAssemblyInfo.GetAssembl > y() > at >
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.GetType(BinaryAs > semblyInfo assemblyInfo, String name) > at System.Runtime.Serialization.Formatters.Binary.Obj ectMap..ctor(String > objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] > typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 > objectId, BinaryAssemblyInfo assemblyInfo, SizedArray > assemIdToAssemblyTable) > at >
System.Runtime.Serialization.Formatters.Binary.Obj ectMap.Create(String name, > String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] > typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 > objectId, BinaryAssemblyInfo assemblyInfo, SizedArray > assemIdToAssemblyTable) > at >
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWith > MapTyped(BinaryObjectWithMapTyped record) > at >
System.Runtime.Serialization.Formatters.Binary.__B inaryParser.ReadObjectWith > MapTyped(BinaryHeaderEnum binaryHeaderEnum) > at System.Runtime.Serialization.Formatters.Binary.__B inaryParser.Run() > at >
System.Runtime.Serialization.Formatters.Binary.Obj ectReader.Deserialize(Head > erHandler handler, __BinaryParser serParser, Boolean fCheck, > IMethodCallMessage methodCallMessage) > at >
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S > tream serializationStream, HeaderHandler handler, Boolean fCheck, > IMethodCallMessage methodCallMessage) > at >
System.Runtime.Serialization.Formatters.Binary.Bin aryFormatter.Deserialize(S > tream serializationStream) > at Salamander.Addins.CodeStore.Engine.Engine.LoadOpti ons() in > c:\development\codestore\engine\engine.cs:line 78 > > Why can't it find the assembly? It is not calling out to a separate library, > it's a single dll for the add-in and that's where the code is being called > from. The file it is trying to read is inthe same location as the
dll, too. > > The LoadOptions function looks like this: > > internal void LoadOptions() > { > try > { > string path = GetAddInPath() + this.optionsFileName; > Stream stream = new FileStream(path + ".options", FileMode.Open, > FileAccess.Read, FileShare.Read); > try > { > IFormatter formatter = new BinaryFormatter(); > this.options = (Options)formatter.Deserialize(stream); // <--
This is > line 78 where the exception is raised. > } > catch (System.Exception exc) > { > System.Diagnostics.Trace.WriteLine(exc.ToString(), > "Engine.LoadOptions"); > } > finally > { > stream.Close(); > } > } > catch (System.Exception exc) > { > if (exc is FileNotFoundException) > { > // No options file, so write the current default options to
file. > SaveOptions(); > } > else > { > System.Diagnostics.Trace.WriteLine(exc.Message, "Engine.LoadOptions"); > } > } > } > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Frank Jones |
last post by:
When manually running resgen.exe from the command prompt (Visual Studio .NET
2003 command prompt) I get the following error:
error: Invalid ResX input.
error: Specific exception:...
|
by: Philip Reed |
last post by:
I'm trying to write a preferences-handling infrastructure that
serializes prefs to XML. Basically I want to read in a common
"default" prefs set, then read in the user's prefs and override the...
|
by: Skip |
last post by:
Hi,
I get the following exception thrown when I try to run my code:
"An unhandled exception of type
'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional...
|
by: Really stuck |
last post by:
Hello,
I'm getting the following error now with my aplication, but only when I run it ocally on my machine:
System.Runtime.Serialization.SerializationException: Cannot find member name...
|
by: Adam P |
last post by:
Hi,
When I run my website under IIS, it works fine. When I attempt to run it
as a "file system" website under vs2005 RC1 I get the following error:
Error Message: Type is not resolved for...
|
by: mekim |
last post by:
I am getting an unhandled exception on a webservice as listed below
and my quesiton is
How do I trap it to find where it's coming from since it seems to be outside
of the my code.
Thx in...
|
by: Brent Starkes |
last post by:
Hi,
I'm having a deserialization problem with a dll plug-in I'm writing, it
serializes just fine but I'm getting an exception on the deserialization
process.
A first chance exception of type...
|
by: Simon Hart |
last post by:
Hi,
I have the following code which is miss-behaving at one site:
public class HMRHost
{
private int _pid;
|
by: billa |
last post by:
Hello,
I am creating a web service with .NET 2.0 and Visual Studio 2005.
I want to enable the following class as a web service:
public class Service : System.Web.Services.WebService
{
|
by: Andy |
last post by:
Hi All,
I am calling a Java web service which is throwing some exception which the
catch block is trapping successuly. I can see the "javax.ejb.EJBException:"
in ex.message. but after this...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |