Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error explanation requested
Message
From
04/04/2005 19:33:16
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01001356
Message ID:
01001387
Views:
15
Paul,

If you make the method static, it should work just fine from your Common project:
public static String UTF8ByteArrayToString(Byte[] characters)
~~Bonnie

>I am trying to get an object into an xml string. From what I have gathered on the web is that I need to use "serialization".
>
>I found some code on the internet:
>
>string xml = null;
>MemoryStream memoryStream = new MemoryStream();
>XmlSerializer serializer = new XmlSerializer(typeof(Class1));
>XmlTextWriter textWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
>
>serializer.Serialize(textWriter,cls1);
>memoryStream = (MemoryStream)textWriter.BaseStream;
>xml = Common.UTF8ByteArrayToString(memoryStream.ToArray());
>
>
>I put my UTF8ByteArrayToString function in another project that is reference by the current project.
>
>
>/// <summary>
>/// To convert a Byte Array of Unicode values (UTF-8 encoded) to a complete String.
>/// </summary>
>/// <param name="characters">Unicode Byte Array to be converted to String</param>
>/// <returns>String converted from Unicode Byte Array</returns>
>public String UTF8ByteArrayToString(Byte[] characters)
>{
>	UTF8Encoding encoding = new UTF8Encoding();
>	String constructedString = encoding.GetString(characters);
>	return (constructedString);
>}
>
>
>I get the following error
>
>An object reference is required for the nonstatic field, method, or property 'aeCommon.Common.UTF8ByteArrayToString(byte[])'
>
>
>If I move the UTF8ByteArrayToString function into my current project I don't get the error.
>
>Can someone explain what's happening here.
>
>Thank you,
>Paul
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform