How to use PIDL compiler in C#

You can use Remote Method Invocation in C#. And for this, PIDL compiler can create proxy and stub code of C#. If you execute as below, proxy and stub code of C# will be created. (Existing –clr is same as -cs)

PIDL.exe -cs <input-file-name>

When developing an application program, there would be a module that is commonly used between server and client. The proxy and stub code of C# should be placed in that common module. And for this module, you should custom build C# project after receiving PIDL file same as How to run PIDL Compiler. In order to do this, please refer to below.

cs_custom_build.png
How to set a custom build for PIDL file from C# project

Proxy and stub created by building C2S.pidl are as below.

C2S_common.cs
C2S_proxy.cs
C2S_stub.cs

You should include them as source files at C# project(.csproj). But, please be reminded that these files are the build outcomes only, not user-written sources. So they shouldn't be included in your source control (i.e. SVN). Otherwise, it could prompt a writing error at a read-only file.

It is recommended to open .csproj in an editor and modify like this below.

<Target Name="BeforeBuild">
<ItemGroup>
<Compile Include="C2S_common.cs" />
<Compile Include="C2S_proxy.cs" />
<Compile Include="C2S_stub.cs" />
</ItemGroup>
</Target>
<Target Name="AfterBuild">
</Target>

The class names of Proxy and stub created by C# are same with those of C++. And the usage is also identical. (Refer to Attaching RMI proxy and stub)

For more details, please refer to the common module source from Sample codes of using ProudNet in C#.