Microsoft KB Archive/326208

= PRB: Native Function Import Is Incompatible with Unicode and Auto Modifiers =

Article ID: 326208

Article Last Modified on 8/7/2003

-

APPLIES TO


 * Microsoft Visual J# .NET 2003 Standard Edition
 * Microsoft Visual J# .NET 2003 Standard Edition

-



This article was previously published under Q326208



SYMPTOMS
In a Visual J# .NET application, a J/Direct DLL import statement for function 'X' results in a different function version from the same DLL import statement for function 'X' in a Visual J++ application. This occurs when the following criteria are met:
 * You import the function with a Unicode or auto modifier.
 * The DLL that contains function 'X' also contains a function named 'XW', where the 'W' suffix indicates the Unicode version.
 * The application is running on a Unicode platform.



CAUSE
The Visual J# .NET application always imports the method with the 'W' suffix, if it exists. The Visual J++ application imports the method without the suffix in this scenario.



STATUS
This behavior is by design.



MORE INFORMATION
This compatibility issue occurs when 'X' and 'XW' are the only entry points for the function in the DLL.

In cases where 'X', 'XW', and 'XA' (where the 'A' suffix indicates the ANSI version) are defined, or only 'XW' and 'XA' are defined, both Visual J# .NET and Visual J++ bind to the same function, the 'XW' version.

Steps to Reproduce the Behavior
 Create or find a DLL that exports a Unicode and a generic version of a function, as described in this article. Make sure that the behavior in each function version is different so that you can identify which version is called.  Create a Java language application that uses @dll.import with the Unicode or auto modifier to import the function from the DLL: public class MyApp {   /** @dll.import(&quot;Sample.dll&quot;, unicode) */ public static native void myFunc; public static void main(String[] args) {       myFunc; } }                    Compile the application by using the Microsoft Visual J++ compiler, and then run the application. Notice that the application imports the generic version of the function. Compile the application by using the Visual J# .NET compiler, and then run the application. Notice that the application imports the Unicode version of the function.

Additional query words: vjsharp jsharp j# dll import

Keywords: kbprb KB326208

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.