简体   繁体   English

找不到类型或命名空间名称 TSocket apache thrift C# Visual Studio 2019

[英]Type or namespace name TSocket could not be found apache thrift C# Visual Studio 2019

Screenshot of installed thrift package and Thrift.dll reference:已安装的 thrift package 和 Thrift.dll 参考截图:

已安装的 thrift 包和 Thrift.dll 参考的屏幕截图

I am trying to create a simple thrift client in Visual Studio 2019 using C#.我正在尝试使用 C# 在 Visual Studio 2019 中创建一个简单的节俭客户端。 I have generated the c# thrift bindings and everything else.我已经生成了 c# 节俭绑定和其他所有内容。 However, I get "Type or namespace name "TSocket" could not be found".但是,我得到“找不到类型或命名空间名称“TSocket””。 I have no other errors.我没有其他错误。 Here is a snippet from my setup code:这是我的设置代码中的一个片段:

// imports, namespaces
using System;
using System.Net;
using Thrift;
using Thrift.Transport;
using Thrift.Protocol;
  
TTransport socket1 = new TSocket("hostname", port);
TTransport transport = new TFramedTransport(socket1);
                
(more stuff .....)

I have no other issues with other references to thrift modules within the client.对于客户端中对节俭模块的其他引用,我没有其他问题。 It just can't find "TSocket" somehow.它只是无法以某种方式找到“TSocket”。 I am super new to c# and thrift.我是 c# 和节俭的超级新手。

I am using thrift 0.14.1 and have installed it using the NuGet packages add-on Visual Studio 2019.我正在使用thrift 0.14.1并使用 NuGet 软件包附加 Visual Studio 2019 安装它。

What could be the problem?可能是什么问题呢? Thanks.谢谢。 screenshot of error错误截图

After looking at, it seems "TSocket" is not even listed under Transport as you can see in the screenshot below.查看后,似乎“TSocket”甚至没有在 Transport 下列出,如下面的屏幕截图所示。 screenshot of available modules under Thrift Transport Thrift Transport 下可用模块的屏幕截图

Thrift 0.14 changed some names and the nested namespace structure. Thrift 0.14 更改了一些名称和嵌套的命名空间结构。 What was Thrift.Transport.TSocket is now Thrift.Transport.Client.TSocketTransport. Thrift.Transport.TSocket 现在是 Thrift.Transport.Client.TSocketTransport。 See if swapping that fixes it.看看交换是否可以解决它。

If not check your project ref to the Thrift lib.如果没有检查您的项目对 Thrift 库的引用。 Something like this may help (quoting "The Programmer's Guide to Apache Thrift"):这样的事情可能会有所帮助(引用“Apache Thrift 的程序员指南”):

"To add the C# Apache Thrift library reference, right-click the References item in the project in the Solution Explorer and choose “Add Reference”. Next use the “Browse...” button to locate the Thrift.dll in thrift/lib/csharp/src/bin/Debug (or wherever). Make sure that there is a check next to the Thrift.dll entry in the Reference Manager dialog and then click OK. After a brief pause Intelisense errors should clear." “要添加 C# Apache Thrift 库引用,请在解决方案资源管理器中右键单击项目中的 References 项并选择“添加引用”。接下来使用“浏览...”按钮找到 Thrift.Z06416233FE45EC4C5933 中的 Thrift.Z06416233FE45EC4C59331 /csharp/src/bin/Debug(或任何地方)。确保在 Reference Manager 对话框中的 Thrift.dll 条目旁边有一个检查,然后单击 OK。短暂暂停后,Intelisense 错误应该会清除。

... or using the package manager: ...或使用 package 管理器:

"To add a Thrift.dll reference you can simply run the PackageManager install command: “要添加 Thrift.dll 参考,您只需运行 PackageManager 安装命令:

PM> Install-Package -Prerelease ApacheThrift -ProjectName <your proj name here>

'ApacheThrift 1.0.0-dev' already installed.
Adding 'ApacheThrift 1.0.0-dev' to tradeServer.
Successfully added 'ApacheThrift 1.0.0-dev' to tradeServer.
"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio 2013 C#找不到类型或名称空间名称IVSStatusBar - Visual Studio 2013 C# The type or namespace name IVSStatusBar could not be found Visual Studio Code Do.net Core C# 错误:“找不到类型或命名空间名称‘System’”,但构建成功 - Error in Visual Studio Code Dotnet Core C#: "The type or namespace name 'System' could not be found", but build succeeds C#找不到类型或名称空间名称 - C# The type or namespace name could not be found 找不到类型或名称空间名称-C# - The type or namespace name could not be found - C# Visual Studio 代码:找不到类型或命名空间名称“IntPtr” - Visual Studio Code: The type or namespace name 'IntPtr' could not be found 错误:在Visual Studio 2013中找不到类型或命名空间名称“ApplicationUser” - Error: The type or namespace name 'ApplicationUser' could not be found in Visual Studio 2013 在 Visual Studio Code for Mac 上找不到类型或命名空间名称“System” - The type or namespace name 'System' could not be found on Visual Studio Code for Mac 在 MSBuild 中找不到类型或命名空间名称,但在 Visual Studio 中有效 - The type or namespace name could not be found in MSBuild but works in Visual Studio 在 Visual Studio 2017 中找不到“类型或命名空间” - 'the type or namespace could not be found' in Visual Studio 2017 C#错误:找不到类型或名称空间名称“,已检查框架” - C# error: The type or namespace name '' could not be found, checked framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM