Problem with creating a session (C#)

   2543   2   1
User Avatar
Member
7 posts
Joined: June 2018
Offline
Hi,
I have a problem when trying to create a session in my x86 application written in C#.
The result comes back as HAPI_RESULT_FAILURE when I try to create the session using the
CreateThriftNamedPipeServer function.

pipe_name = “hapi”
server_executable_path = “C:\Program Files\Side Effects Software\Houdini 16.5.496\bin\HARS.exe”
(which is the correct path to the .exe)

//HoudiniVersion.HAPI_LIBRARY = libHARC32.dll
[DllImport(HoudiniVersion.HAPI_LIBRARY, CallingConvention = CallingConvention.Cdecl)]
private static extern HAPI_Result
HAPI_StartThriftNamedPipeServer(
ref HAPI_ThriftServerOptions options,
string pipe_name,
out int process_id);


private static bool startProcess (...){
...

int process_id;
HAPI_ThriftServerOptions server_options = new HAPI_ThriftServerOptions();
server_options.autoClose = true;
server_options.timeoutMs = 2000.0f;

HAPI_Result result = HAPI_StartThriftNamedPipeServer(
ref server_options,
pipe_name,
out process_id);

...

}

My questions is then:

1. Am I missing something in the code?
2. Does the pipe need to be named in a certain way for it to work?
3. I have tried adding HARS.exe (and basically everything else in the bin folder) in the same folder as my executable without any luck. Is there something special I need to do beside the code for it to work?
4. And is it even possible to link the API to a x86 application?
User Avatar
Staff
534 posts
Joined: Sept. 2016
Offline
Hi,

All those issues are most likely caused by your application being 32bits.
Since HARS, LibHAPIL (or Houdini) are not 32bits, you cannot start the server from your application.

However, you can link to HARC32, and use it to connect to an existing 64bit session of HARS.
To do so, you'd need to start HARS on a 64 bit machine:

HARS -n hapi -a
will start a named pipe session (hapi) with autoclose.

In your application, you should be able to connect to it by calling:

HAPISession* SessionPtr = nullptr;
HAPI_Result result = HAPI_CreateThriftNamedPipeSession( SessionPtr, “hapi” );

That session pointer can then be used to Initialize HAPI.
User Avatar
Member
7 posts
Joined: June 2018
Offline
That worked, thank you!
  • Quick Links