4

I've installed thrift for both my library and server; using NuGet.

I have a very simple thrift file that I've compiled it using the following command:

thrift.exe -r --gen csharp node.thrift

the node.thrift has three lines:

service Server {
    string ping()
}

I get the errors from the Server.cs generated by the thrift compiler.

'TProtocol' does not contain a definition for 'IncrementRecursionDepth'

sample line throwing the error:

public void Read (TProtocol iprot)
    {
      iprot.IncrementRecursionDepth(); //this line has the error

I've googled for it, but didn't find any results.

update: If I delete the lines throwing the error, the library compiles and the server works as expected, I don't know if I'll face errors in the future or not, whats up with the recursion?!

important point: I compile the thrift file using the executable I've downloaded from http://www.apache.org/dyn/closer.cgi?path=/thrift/0.9.3/thrift-0.9.3.exe. the version is 0.9.3 but the thrift library installed by NuGet is 0.9.1.3

aliep
  • 1,702
  • 2
  • 21
  • 33

2 Answers2

7

the version is 0.9.3 but the thrift library installed by NuGet is 0.9.1.3

Thats exactly the problem. The IncrementRecursionDepth() function has been added later to prevent a problem, which is outlined in more detail in THRIFT-3235. Since you need both compiler and library for it, you get a problem.

Solution: Always use matching compiler and libraries. In particular, use 0.9.3.

JensG
  • 13,148
  • 4
  • 45
  • 55
  • I couldn't find NuGet packages for 0.9.3, is there a way I can make it my own (using a simple wizard)? – aliep Mar 17 '16 at 20:38
  • 1
    All [official packages are listed here](https://thrift.apache.org/lib/), plus some 3rdparty ones. [This is the 0.9.3 for C#](https://www.nuget.org/packages/ApacheThrift/0.9.3). If the Thrift compiler is missing from that package (I'm not sure, but IIRC there was some issue with the EXE missing), you can [get it here](https://thrift.apache.org/download). – JensG Mar 17 '16 at 20:39
  • 1
    I searched for the wrong package, please include this in your answer: To install the latest official package from NuGet, search for ApacheThrift. – aliep Mar 17 '16 at 20:45
2

The Problem was that the compiler version was not equal to the thrift version installed by NuGet.

To install the latest official package from NuGet, search for ApacheThrift.

aliep
  • 1,702
  • 2
  • 21
  • 33