Soap Formatter

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
 
R

RayLopez99

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
 
F

Family Tree Mike

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top