Microsoft KB Archive/836670

= BUG: &quot; does not implement interface member&quot; error message when you build a Visual C# .NET project that you converted from a Java-language class by using JLCA =

Article ID: 836670

Article Last Modified on 5/17/2007

-

APPLIES TO


 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * 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:

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

Note In this error message,  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 &quot;Symptoms&quot; 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 &quot;Applies to&quot; 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:

http://msdn2.microsoft.com/en-us/vstudio/aa718346.aspx

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

<div class="references_section">