Java library with .net and Delphi hydra

Hello,

I’m using a library that manipulates project files (mpp, mpx, xml, etc) in c#. http://mpxj.sourceforge.net/

This library is written and maintained in Java, however this is no barrier to using its functionality in .Net. When I use it directly with .net, it is working all fine. When I run a delphi application and invokes a .net interface with Hydra, I’m getting a lot of errors as soon as I use any method from this library.

Errors:

'O inicializador de tipo de 'net.sf.mpxj.ProjectProperties' acionou uma exceção.
System.TypeInitializationException: O inicializador de tipo de 'IntegerCache' acionou uma exceção. 
---> System.TypeInitializationException: O inicializador de tipo de 'sun.misc.VM' acionou uma exceção. 
---> System.TypeInitializationException: O inicializador de tipo de 'java.lang.Props' acionou uma exceção. 
---> System.ArgumentException: Caracteres inválidos no caminho.
   em System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
   em System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(String[] str)
   em System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
   em System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
   em System.IO.Directory.InternalGetCurrentDirectory(Boolean checkHost)
   em java.lang.VMSystemProperties.initCommonProperties(Properties )
   em java.lang.VMSystemProperties.initProperties(Properties )
   em java.lang.Props..cctor()
   --- Fim do rastreamento de pilha de exceções internas ---
   em java.lang.System.lineSeparator()
   em sun.misc.VM..cctor()
   --- Fim do rastreamento de pilha de exceções internas ---
   em sun.misc.VM.getSavedProperty(String key)
   em java.lang.Integer.IntegerCache..cctor()
   --- Fim do rastreamento de pilha de exceções internas ---
   em java.lang.Integer.valueOf(Int32 i)
   em net.sf.mpxj.ProjectProperties..cctor()'

Could anyone help me?
Thanks!

One thing you can try is to reset the control word in Delphi before you do the first call that fails:

  {$IFDEF WIN64}
  SetExceptionMask(exAllArithmeticExceptions);
  {$ELSE}
  Set8087CW(HYDRA_8087_CONTROL_WORD); // defined in uHYCLRHelpers.pas
  {$ENDIF}

Delphi keeps changing the Control Word and .NET doesn’t like this.

Didn’t work :confused:

Any other idea?

Then it has to be something IKVM does inside initCommonProperties that somehow fails in Delphi.

Hello

Please try to run your Delphi app outside of the RAD Studio. We’ve been recently reported that Delphi debugger corrupts some properties of the .NET domain used to load Hydra plugins. According to the stacktrace this could be the reason here too.

If this won’t help then I’ll have to ask you to do a debug session with .NET framework sources loaded to check which exactly string actually causes the System.IO.Path.CheckInvalidPathChars(String, Boolean) method to fail.

Regards

Thanks for the reply!

Outside of the RAD Studio it worked fine. I guess that this is the problem. Is there anything I can do to solve it and be able to debbug the app in Delphi?

Hello

Unfortunately I don’t know any reasonable way to do that. For the PrivateBinPath property (an AppDomain property that gets corrupted too) we were able to add a runtime check to avoid the exception. Unfortunately this approach won’t work here.

Still I’ll log the issue and we will try to find a soluion for this issue. Until then the only workaround is to run the app outside the RAD Studio or with debugging disabled.

Sorry for the inconvenience.