VB 解决方案中的 C# 类库不导入

标签 c# .net vb.net class-library

我正在尝试为一些 Yahoo Placefinder 工作创建一个 C# 类库。我没有在网上找到 VB 代码示例,所以我想我会使用他们提供的 C# 代码并简单地向我的解决方案添加另一个类库项目并节省一些时间。

但是,无论我做什么,我似乎都无法让我的 VB Windows 服务项目识别导入命名空间。

Imports Code

我已经多次将 VB windows 服务项目中的引用添加到 C# 库中(见下文)...

References

...但似乎没有什么能让它正确识别它。

下面是类(class)代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OAuth;

namespace YahooRequest
{
  public class YahooR
  {
    /// <summary>
    /// Request Address from Yahoo BOSS Placefinder
    /// </summary>
    /// <param name="args"></param>
    /// <returns></returns>
    public static string RequestAddress(string[] args)
    {
      string consumerKey = "...";
      string consumerSecret = "...";
      var uri = new Uri("https://yboss.yahooapis.com/geo/placefinder?location=" + args[0]);
      string url, param;
      var oAuth = new OAuthBase(); 
      var nonce = oAuth.GenerateNonce();
      var timeStamp = oAuth.GenerateTimeStamp();
      var signature = oAuth.GenerateSignature(uri, consumerKey,
      consumerSecret, string.Empty, string.Empty, "GET", timeStamp, nonce,
      OAuthBase.SignatureTypes.HMACSHA1, out url, out param);

      using (WebRequest response = WebRequest.Create(string.Format("{0}?{1}&oauth_signature={2}",
      url, param, signature)).GetResponse())
      {
        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
        {
          return reader.ReadToEnd();
        }
      }
    }
  }
}

关于为什么这个库不能被 Visual Studio 识别的任何建议?

更新 1

一条评论指示我查看对象查看器,它确实显示了类库,但没有显示任何功能。我不确定这是为什么,但我觉得这与我的问题有关。

Object Viewer

更新 2

代码最初来自Yahoo .

最佳答案

如果 Studio 提示引用的库不包含公共(public)类或方法,那很可能是真的。

  • 检查库项目是否确实构建。使用“构建”>“清洁解决方案”,然后重建。
  • 检查您是否从主项目中引用了正确的 dll 文件。您可能已将引用指向一些陈旧的副本。
  • 检查包含实际库代码的代码模块是否确实可以编译(构建操作类型必须是“编译”)。

    enter image description here

关于VB 解决方案中的 C# 类库不导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32593203/

相关文章:

c# - 使用 InMemoryDatabase 和 Identity 列进行测试,如何处理?

c# - 如何在 c# .net 中阻止一个方法直到另一个方法执行

.net - 如何扫描磁盘上真正巨大的文件?

c# - C#版本的项目命名

vb.net - VB.NET 和 Windows 窗体中的文本框验证

vb.net - 在 VB.NET 中向集合添加结构

c# - 抛出什么样的异常?

c# - 缩放 WPF 窗口

c# - 带有 2 个表的 WPF TreeView(分层数据模板)

c# - 如何使用 JSON 从 WCF REST 服务返回 Base64 编码的字节数组?