Microsoft KB Archive/814903

= BUG: You receive a &quot;does not implement interface member&quot; compilation error message in a JLCA-converted Visual J++ project with a class that implements java.io.Serializable =

Article ID: 814903

Article Last Modified on 5/16/2007

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft Visual J++ 1.0 Standard Edition

-





SYMPTOMS
You may receive the following error message:

' ' does not implement interface member 'System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'

You may receive this error message if all the following conditions are true:
 * You have a Visual J++ project with a class that implements the java.io.Serializable interface.
 * You convert your Visual J++ project to a Visual C# .NET project by using the Java Language Conversion Assistant (JLCA).
 * You try to compile the generated Visual C# .NET project.



CAUSE
In the Microsoft .NET Framework, the equivalent for the java.io.Serializable interface is the System.Runtime.Serialization.ISerializable interface. However, when you convert the Visual J++ project, JLCA does not add the implementation for the GetObjectData method of the ISerializable interface.



WORKAROUND
To work around this problem, implement the GetObjectData method in the generated Visual C# .NET class. To do so, follow these steps after you convert the Visual J++ project based on the steps in the &quot;Steps to Reproduce the Behavior&quot; section of this article:
 * 1) On the View menu, click Class View.
 * 2) In the Class View pane, expand the following nodes:
 * 3) * MyVJTestApplication
 * 4) * Employee
 * 5) * Bases and Interfaces
 * 6) Right-click ISerializable, point to Add, and then click Implement Interface.

Note A default implementation is added to the GetObjectData method in step 6 of the steps in the &quot;Steps to Reproduce the Behavior&quot; section of this article. You may not receive any compilation errors when you add the default implementation. However, you may add required information to the SerializationInfo object.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
In the .NET Framework, you can mark any class that may be serialized with the SerializableAttribute class. However, if a class controls the serialization process, the class implements the ISerializable interface. The Formatter calls the GetObjectData method during serialization and populates the supplied serialization information with all the required data to represent the object.

Steps to Reproduce the Behavior
 Start Visual J++ 6.0. On the File menu, click New Project. On the New tab, expand Visual J++ Projects, and then click Applications. In the right pane, click Console Application. In the Name box, type MyVJTestApplication, and then click Open.</li>  Replace the existing code with the following code for Class1.java: import java.util.*; import java.io.*;

// Class that implements the Serializable interface class Employee implements Serializable {   private int empId; private String name; private int basicSalary; // Default constructor // It is not a good idea to use this constructor. // Always use the constructor with three parameters. public Employee {   }    // A constructor with three parameters public Employee(int empId, String name, int basicSalary) {       this.empId = empId; this.name = name; this.basicSalary = basicSalary; }   // A Setter method to set BasicPay public void SetBasic(int newBasic) {       this.basicSalary = newBasic; }   // A Print method to display the details of the Employee public void PrintDetails {       System.out.println(&quot;Employee ID       : &quot;+ empId); System.out.println(&quot;Employee Name    : &quot;+ name); System.out.println(&quot;Employee Basic Pay: &quot;+ basicSalary); } }

//A class with the Main method public class Class1 {   public static void main(String[] args) {       Employee employee = new Employee(80366, &quot;Peter&quot;, 3700); employee.PrintDetails; } } </li> On the File menu, click Save All.</li> Quit Visual J++.</li> Start Microsoft Visual Studio .NET 2003.</li> On the File menu, point to Open, and then click Convert.</li> Click Java Language Conversion Assistant in the Available Converters list, and then click OK.</li> Follow the instructions in JLCA Wizard to convert the Visual J++ project that you created earlier in these steps.</li> On the Build menu, click Build Solution. You receive the compilation error message that is listed in the &quot;Symptoms&quot; section of this article.</li></ol>

<div class="references_section">