安装了Nuget软件包,但无法导入

发布于 2025-01-29 21:22:54 字数 1936 浏览 1 评论 0原文

我正在尝试将Nuget软件包“ azure.resourcemanager”添加到现有项目中。

这是.csproj文件: -

<Project Sdk="Microsoft.NET.Sdk">

  <ItemGroup>
    <PackageReference Include="Azure.Identity" Version="1.6.0" />
    <PackageReference Include="Azure.ResourceManager" Version="1.0.0" />
    <PackageReference Include="Azure.ResourceManager.Resources" Version="1.0.0" />
    ....
  </ItemGroup>

</Project>

我在解决方案上运行了Nuget Restore命令,我检查了该软件包是否通过Visual Studio Package Manager Console安装,

PM> Find-Package ResourceManager

Id                                  Versions                                 Descriptio
                                                                             n         
--                                  --------                                 ----------
Azure.ResourceManager               {1.0.0}                                  Azure m...
Azure.ResourceManager.Communication {1.0.0}                                  Azure m...
Azure.ResourceManager.Deployment... {1.0.111}                                This pr...
Azure.ResourceManager.Deployment... {1.0.111}                                This pa...

但是,当我尝试将此包导入类中时,类型无法解决。 我想知道包和项目是否针对不同版本,因此我检查了。

包装支持的目标框架 项目支持的目标框架

我所知,项目和软件包支持.NET Core 3.1作为目标框架。

软件包已安装到项目中,但我注意到的另一件事不能将其导入到类中

,这是在“ Microsoft.azure”命名空间中搜索类型的“ ResourceManager”,而不是“ Azure”,

寻找任何用于解决问题的指针。

I am trying to add a nuget package "Azure.ResourceManager" to an existing project.

Here is the .csproj file:-

<Project Sdk="Microsoft.NET.Sdk">

  <ItemGroup>
    <PackageReference Include="Azure.Identity" Version="1.6.0" />
    <PackageReference Include="Azure.ResourceManager" Version="1.0.0" />
    <PackageReference Include="Azure.ResourceManager.Resources" Version="1.0.0" />
    ....
  </ItemGroup>

</Project>

I ran the nuget restore command on the solution, and I have checked that the package is installed through the Visual Studio Package Manager Console, using command

PM> Find-Package ResourceManager

Id                                  Versions                                 Descriptio
                                                                             n         
--                                  --------                                 ----------
Azure.ResourceManager               {1.0.0}                                  Azure m...
Azure.ResourceManager.Communication {1.0.0}                                  Azure m...
Azure.ResourceManager.Deployment... {1.0.111}                                This pr...
Azure.ResourceManager.Deployment... {1.0.111}                                This pa...

However, when I try to import this package into a class, the type cannot be resolved.
enter image description here
I wondered if the package and project targeted different versions, so I checked.

Target frameworks supported by package
enter image description here
Target framework supported by project
enter image description here
In summary,

As far as I can tell, both project and package support .Net Core 3.1 as a target framework.

Package is installed into project, but cannot be imported into class

Another thing I noticed is that the type "ResourceManager" is being searched for in the "Microsoft.Azure" namespace instead of "Azure"

Looking for any pointers to resolve the issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

动听の歌 2025-02-05 21:22:54

我了解到,由于我试图添加导入的命名空间中的命名冲突是由于命名冲突而发生的。似乎还有另一个命名空间“ Azure”。在我正在添加代码的一个中。添加GloCal前缀有助于解决问题。

using global::Azure.ResourceManager;

I learnt that the issue was happening because of naming conflicts within the namespace that I was trying to add the import in. There seems to have been another namespace "Azure." within the one I was adding code to. Adding a glocal prefix helped resolve the issue.

using global::Azure.ResourceManager;
也只是曾经 2025-02-05 21:22:54

这似乎是一个错误。我刚刚在内部使用.NET Core 3.1项目创建了一个解决方案。我使用了Nuget Manager UI,它运行良好。您是否尝试过这样的方式安装它?

This seems like a bug. I just created a solution with a .NET core 3.1 project inside. I used the Nuget Manager ui and it worked fine. Have you tried installing it that way?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文