Soap Formatter

  • Thread starter Thread starter Trey Balut
  • Start date Start date
T

Trey Balut

How do I fix the following error ?

"The type or namespace name 'Soap' does not exist in the namespace
'System.Runtime.Serialization.Formatters' (are you missing an assembly
reference?)"


Here is my source code:

public static bool Serialize(System.Object myObject, string
writeToXmlPath)
{
bool state = true;
System.Runtime.Serialization.IFormatter formatter = null;
System.IO.Stream stream = null;


try
{

/*********************************The next line is the
error*******************/

formatter = new
System.Runtime.Serialization.Formatters.Soap.SoapFormatter();
stream = new System.IO.FileStream(writeToXmlPath,
FileMode.Create, FileAccess.Write, FileShare.None);
formatter.Serialize(stream, myObject);
}
catch (System.Exception ex)
{
state = false;
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
finally
{
stream.Close();
formatter = null;
stream = null;
}
return state;
}


Thanks,

Trey
 
How do I fix the following error ?

"The type or namespace name 'Soap' does not exist in the namespace
'System.Runtime.Serialization.Formatters' (are you missing an assembly
reference?)"


Are you missing an assembly reference? That's the first place to
look. Make sure you check all directories when you "Add" an assembly
from inside Visual Studio. I got tripped up on that several times. I
was only checking out the "old" directory, but in fact my toolkit DLLs
resided in a newer directory, unknown to me. It was that easy, once I
realized the problem.

RL
 
How do I fix the following error ?

"The type or namespace name 'Soap' does not exist in the namespace
'System.Runtime.Serialization.Formatters' (are you missing an assembly
reference?)"


Here is my source code:

public static bool Serialize(System.Object myObject, string writeToXmlPath)
{
bool state = true;
System.Runtime.Serialization.IFormatter formatter = null;
System.IO.Stream stream = null;


try
{

/*********************************The next line is the
error*******************/

formatter = new
System.Runtime.Serialization.Formatters.Soap.SoapFormatter();
stream = new System.IO.FileStream(writeToXmlPath, FileMode.Create,
FileAccess.Write, FileShare.None);
formatter.Serialize(stream, myObject);
}
catch (System.Exception ex)
{
state = false;
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
finally
{
stream.Close();
formatter = null;
stream = null;
}
return state;
}


Thanks,

Trey

Add a reference to System.Runtime.Serialization.Formatters.Soap.dll.
 
Back
Top