J ++ to J #: how to convert resources?

I have a Visual J ++ project that I want to port to J #. The code does not use Microsoft-specific APIs (for example, WFC) or non-standard language extensions, therefore, it is technically fully compatible with Java 1.1.

The only problem is the resources (which in the Java world are usually accessible using the Class.getResourceAsStream()API).

In J ++, it was enough to specify templates for the resource file name in the project configuration, and all resources associated with the templates would be embedded in the resulting * .exe (as the original Win32 resources) and would be accessible as programmatically, using Class.getResourceAsStream()and manually using any resource editor :

enter image description here

Problem

Visual J # (VS 2005), (Class.getResourceAsStream() null), , " " " " " :

enter image description here

( *.exe, , , dotPeek). :

<assembly default namespace>.<Java package>.<file name with extension>

, README.txt, com.example, default.com.example.README.txt:

dotPeek

Visual Studio 2003 , 2005: Class.getResourceAsStream() null, ArgumentOutOfRangeException mscorlib.dll :

mscorlib.dll!System.String.Substring(int startIndex = 0, int length = -1) + 0xbb bytes  
vjslib.dll!com.ms.vjsharp.lang.VJSClassLoader.__findResource(System.Reflection.Assembly currentAssembly = {System.Reflection.Assembly}, string resName = "com/example/README.txt") + 0xc5 bytes 
vjslib.dll!com.ms.vjsharp.lang.VJSClassLoader.__getResourcefromAssembly(System.Reflection.Assembly callingAssembly = {System.Reflection.Assembly}, string resName = "com.example.Main/+/com/example/README.txt") + 0x1b7 bytes  
vjslib.dll!com.ms.vjsharp.lang.VJSClassLoader.getResourceAsStream(string resName = "com.example.Main/+/com/example/README.txt") + 0x57 bytes    
vjslib.dll!java.lang.Class.getResourceAsStream(string resourceName = "com.example.Main/+/com/example/README.txt") + 0x10d bytes 
test-resource-loading.exe!com.example.Main.main(String[] args = {Length=0}) Line 21 + 0x26 bytes

- , , ​​ 2.0.NET Framework. 2.0.

com.ms.vjsharp.lang.VJSClassLoader, -, , .

  • , , , - .
  • *.jar javac JAR J # Binary Converter Tool (jbimp.exe) - . J # Binary Converter Tool - ( - VS 2003 VS 2005):

    • Class.getResourceAsStream(...) - Java System.InvalidProgramException , - MSIL.
    • , try-finally ( - Java), jbimp.exe ( 5- , ):

      JbImp error: Internal Conversion Error : 'exc-unclosed-blocks'
      JbImp error: Failed to create type for class 'com/example/Main'. Creating stub type
      JbImp error: Internal Conversion Error : 'JbImp fatal error: Conversion failed'
      
  • J ++ VS 2003/2005 : , *.rc/*.res.

  • *.resx, Class.getResourceAsStream() ( Java System.String ( ) System.Drawing.Bitmap ( )), , *.gif, .

vjslib.dll Class.getResourceAsStream() , ? ?

+4
1

Microsoft Java API, J #, ( , Class.getResourceAsStream() , , J ++, J #), .

, ( ), Java 1.1 API Java 1.2, Swing.

, . Visual J ++ 6.0, . Java .resx vjsresgen.exe, Visual Studio 2005, Microsoft.

. Visual Studio vjsresgen.exe - .resx:

vjsresgen.exe-generated .resx file

0

Source: https://habr.com/ru/post/1668033/


All Articles