我从这里下载了 Apache Thrift 0.9.1:http://wiki.apache.org/thrift/ThriftUsageCSharp 。在 Visual Studio 2010 中,我打开了 thrift/lib/csharp/src 中的 .sln 文件。
但是,我无法构建解决方案。我收到此错误:
Error 3 The command "rmdir /s /q "C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\gen-csharp"
del /f /q "C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\ThriftImpl.dll"
SET OUTPUT_DIR=C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\
SET THRIFT_FILE=C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\\..\..\..\..\test\ThriftTest.thrift
for %%I in ("%OUTPUT_DIR%") do set SHORT_DIR=%%~fsI
for %%I in ("%THRIFT_FILE%") do set THRIFT_SHORT=%%~fs
"C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\\..\..\..\..\compiler\cpp\thrift.exe" --gen csharp -o %SHORT_DIR% %THRIFT_SHORT%
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /t:library /out:"C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\ThriftImpl.dll" /recurse:"C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\gen-csharp"\* /reference:"C:\Users\RS88517\Documents\Visual Studio 2010\Projects\thrift-0.9.1\lib\csharp\test\ThriftTest\..\..\src\bin\Debug\Thrift.dll"" exited with code 1.
我查了很多地方,但不知道该怎么做。
最佳答案
这是 ThriftTest
的预构建步骤项目。如果您遇到问题,并且可能难以调试,请按以下步骤操作:
从 C# 项目中完全删除预构建步骤(“项目属性”对话框、“构建事件”选项卡)
编译
\lib\csharp\src\Thrift.csproj
生成 Thrift 运行时程序集。或者,考虑包括Thrift.csproj
项目到解决方案中,这使其更易于处理。打开命令行,导航到相应的文件夹并调用
thrift.exe --gen csharp ThriftTest.thrift
从 IDL 生成代码。这将生成一个新文件夹gen-csharp
里面有一堆文件。ThriftTest.thrift
IDL 文件位于\test
文件夹。确保第 3 步生成的文件包含在
ThriftTest
中项目构建一切
请注意,对于步骤 3,您的路径中需要 Thrift 编译器 ( thrift.exe
)。该文件可在 Apache Thrift 上以预编译形式下载。网站,您不需要自己构建它。
关于Visual Studio 2010 中的 C# 编译错误(Thrift 0.9.1 编译),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21587567/