BUG: "<Class Name> does not implement interface member" error message when you build a Visual C# .NET project that you converted from a Java-language class by using JLCA (836670)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition

SYMPTOMS

You can use Java Language Conversion Assistant (JLCA) to convert a Java-language class that implements the Serializable interface to a project that contains a Microsoft Visual C# .NET class. However, when you try to build the project, you may receive the following error message:
Class Name does not implement interface member 'System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'
Note In this error message, Class Name is a placeholder for the name of the Java class that you have used JLCA to convert.

CAUSE

In Java, a class that implements the Serializable interface does not have to implement any methods of the interface. However, in Visual C# .NET, the corresponding converted class must implement the ISerializable.GetObjectData method.

When JLCA converts the Java-language class, JLCA does not implement the ISerializable.GetObjectData method. Therefore, you may receive the error message that appears in the "Symptoms" section of this article.

WORKAROUND

To work around this behavior, implement the ISerializable.GetObjectData method in the converted Visual C# .NET class. To do this, add the following code in the converted Visual C# .NET class:
void System.Runtime.Serialization.ISerializable.GetObjectData(
	System.Runtime.Serialization.SerializationInfo info,
	System.Runtime.Serialization.StreamingContext context)
{
	// Code as required
}

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section of this article.

MORE INFORMATION

To reproduce this behavior, you must have JLCA installed on your computer. To download JLCA, visit the following Microsoft Developer Network (MSDN) Web site:

Steps to reproduce the behavior

  1. Create a new folder in the root folder of drive C on your computer. Name the new folder MyJavaClass.
  2. Create a Java-language class that implements the Serializable interface:
    1. In a text editor such as Notepad, paste the following code:
      import java.io.*;
      public class MyClass implements Serializable {
      	public static void Main()
      	{
      	}
      }
    2. On the File menu, click Save. The Save As dialog box appears.
    3. In the File name box, type C:\MyJavaClass\MyClass.java, and then click Save.
  3. Start Microsoft Visual Studio .NET 2003.
  4. Use JLCA to convert the Java-language class to a Visual C# .NET class:
    1. On the File menu, point to Open, and then click Convert. The Convert dialog box appears.
    2. Under Available Converters, click Java Language Conversion Assistant, and then click OK. The Java Language Conversion Assistant Wizard - Page1 page appears.
    3. Click Next.
    4. Under What do you want to convert?, click to select the A directory containing the project's files option, and then click Next.
    5. In the Which directory contains the files you wish to convert? box, type C:\MyJavaClass, and then click Next.
    6. In the What name would you like for your .Net project? box, type JavaConvert, and then click Next.
    7. Click Next.
    8. In the Warning dialog box that appears, click Yes.
    9. Click Next to start the conversion process.
  5. On the Build menu, click Build Solution.

Modification Type:MinorLast Reviewed:3/6/2006
Keywords:kbvs2005swept kbvs2005doesnotapply kbpending kbJava kbconvert kbbug KB836670 kbAudDeveloper