Article ID: 818438
Article Last Modified on 5/16/2007
APPLIES TO
- Microsoft Visual J# .NET 2003 Standard Edition
SYMPTOMS
You have added a reference to the Component Object Model (COM) component to your Microsoft Visual J# .NET application. When you modify the globally unique identifier (GUID) after you add a reference to the COM component, you receive the following compilation errors:
CAUSE
Each COM component is identified by a GUID. When you refer to the COM component in a Visual J# .NET application, the application uses the GUID to interact with the COM component. When you modify the GUID of the COM component, this change is not reflected in the Visual J# .NET application and you receive the error that is mentioned in the "Symptoms" section of this article.
WORKAROUND
To work around this problem, remove the reference in your Visual J# .NET application, and then add the COM component as a reference. To do this, follow these steps:
- In Microsoft Visual Studio .NET, open your Visual J# .NET project.
- In Solution Explorer, right-click COM component, and then click Remove.
- Right-click Visual J# .NET application, and then click Add Reference.
- Follow the instructions in the Add Reference Wizard to add the COM component as a reference.
STATUS
This behavior is by design.
MORE INFORMATION
Steps to Reproduce the Behavior
Create a COM Component
- Start Microsoft Visual C++ 6.0.
- On the File menu, click New.
- On the Projects tab, click ATL COM AppWizard, type TestCOMLibrary in the Project name box, type C:\TestCOMLibrary in the Location box, and then click OK.
- Click Finish.
- Click OK.
- On the left pane, right-click TestCOMLibrary classes, and then click New Class.
- Type TestInterface in the Name box, and then click OK.
- Click to expand the TestCOMLibrary classes node.
- Right-click ITestInterface, and then click Add Method.
- Type MyTestMethod in the Method Name box, type [in] int a, [in] int b, [out, retval] int *c in the Parameters box, and then click OK.
- On the Build menu, click Rebuild All.
Create a Visual J# .NET Application
- Start Visual Studio .NET.
- On the File menu, point to New, and then click Project.
- Click Visual J# Projects under Project Types, and then click Console Application under Templates.
- Type MyTestConsoleApplication in the Name box, and then click OK.
- In Solution Explorer, right-click MyTestConsoleApplication, and then click Add Reference.
- Follow the instructions in the Add Reference Wizard to add the COM component that was created in the "Create a COM Component" section of this article.
Replace the existing code with the following code for Class1.jsl:
import TESTCOMLIBRARYLib.*; public class Class1 implements ITestInterface { public Class1() { } public int TestMethod(int i, int j) { return i+j; } public static void main(String[] args) { Class1 obj = new Class1(); System.out.println(" "+obj.TestMethod(5, 6)); } }
- On the Build menu, click Build Solution.
Generate a GUID and Test Application
- Open a Visual Studio .NET command prompt.
- Type guidgen at the command prompt, and then press ENTER.
- To generate a new GUID, click New GUID in the Create GUID dialog box. To copy the generated GUID to the Clipboard, click Copy.
- Make a note of this generated GUID.
- Replace the GUID value of the COM component with the GUID value that was generated in step 3 by editing the TestCOMLibrary.idl of the COM component that was created in the "Create a COM Component" section of this article.
- In Visual C++, click Rebuild All on the Build menu.
- In Visual Studio .NET, click Build Solution on the Build menu. You receive the error that is described in the "Symptoms" section of this article.
REFERENCES
For more information about Visual J# .NET, visit the following MSDN Web site:
Keywords: kberrmsg kbcompiler kbjava kbcomservices kbcominterop kbprb KB818438