Accessing the .NET AppConfig File (connectionStrings and appSettings)

Accessing the .NET AppConfig File (connectionStrings and appSettings)

If your .NET logic uses App.Config files, reads information from connectionStrings sections, appSettings or needs any other data from configuration, you can use javOnet to load this file.

To do this, use the following method in your application. This method should be called just after activating javOnet and before any other operation. Simply add the BindConfig method to your application and call it by passing the path to your config file with config file name as an argument.

Example

public static void main(String[] args) throws JavonetException, IOException {  

  Javonet.activate("your@mail.com", "your-license-key", JavonetFramework.v40);  

  String path = new File( "." ).getCanonicalPath()+"\\"; 
  BindConfig(path+"app.config"); 
} 

private static void BindConfig(String configFile) throws JavonetException { 
  Javonet.getType("AppDomain") 
      .getRef("CurrentDomain") 
      .invoke("SetData","APP_CONFIG_FILE", configFile);  
}