C# – error compiling targeting Compact Net Framework 3.5 – No overload for method ‘GetString’ takes ‘1’ arguments

ccompact-frameworkmimewindows-mobile

I actually have two questions regarding the same problem but I think it is better to separate them since I don't think they are related.

Background:
I am writing a Windows Mobile software in VB.NET which among its tasks needs to connect to a mail-server for sending and retrieving e-mails. As a result, I also need a Mime-parser (for decoding and encoding) the e-mails in order to get the attachments. First I thought, I would write a small "hack" to handle this issue (using ordinary string-parsing) but then I saw a project, written in C#, at CodeProject which I thought I would implement into my solution. I don't know much about C# so I simply made a class-library out of the classes and used it in my VB.NET-project. This library works very nicely when I am targeting the Net Framework on normal windows-computers however when I was going to make the same library targeting the Compact Net Framework, I ran into troubles. This is natural since the Compact Net Framework has more limits but I actually didn't get that many errors – only two although repeated in various places in the code.

One of the errors is the one cited in the subject of this question i.e. "No overload for method 'GetString' takes '1' arguments". As mentioned above, I don't know much about C# so I converted the class with the error online into VB-NET but still I don't understand much.. Here is the function which gives above indicated error:

public virtual string DecodeToString(string s)
{
  byte[] b = DecodeToBytes(s);
  if(m_charset != null)
  {
    //ERROR ON THIS LINE
    return System.Text.Encoding.GetEncoding(m_charset).GetString(b);
  }
  else
  {
    m_charset = System.Text.Encoding.Default.BodyName;
    //ERROR ON THIS LINE
    return System.Text.Encoding.Default.GetString(b);
  }
}

If the complete source-code is needed for this class, then I can post it in another message in this thread or you can find it by downloading the code at the web-site mentioned above and by having a look at the class named MimeCode.cs.

Anyone who can help me out? Can I rewrite above function somehow to overcome this problem?

I thank you in advance for your help.

Kind regards and a Happy New Year to all of you.

Rgds,
moster67

Best Answer

CF .NET requires you to use the signature: Encoding.GetString Method (array[], Int32 index, Int32 count) so try using:

...GetString(b, 0, b.Length);