简体   繁体   English

NuGet导入后无法添加对BouncyCastle的引用

[英]Unable to add reference to BouncyCastle after NuGet import

I am trying to link to the BouncyCastle library in my ASP.NET MVC 5 application. 我正在尝试链接到ASP.NET MVC 5应用程序中的BouncyCastle库。 I right clicked on my project, and went to the NuGet Packages. 我右键单击我的项目,然后转到NuGet软件包。 I installed BouncyCastle and I now see it in my references as BouncyCastle.Crypto. 我安装了BouncyCastle,现在在我的引用中以BouncyCastle.Crypto看到了它。 I want to use this package, so just like anything else I am trying: 我想使用此软件包,所以就像我尝试的其他任何事情一样:

using Org.BouncyCastle.Crypto

When I do this, I get an error that The type or namespace 'Org' could not be found . 执行此操作时,出现错误,即The type or namespace 'Org' could not be found If I try using BouncyCastle.Crypto I get the same error, except this time for the type or namespace BouncyCastle . 如果我尝试using BouncyCastle.Crypto遇到相同的错误,但这次是类型或名称空间BouncyCastle

If I grep for BouncyCastle, I can see it in my packages: 如果我为BouncyCastle使用grep,则可以在我的软件包中看到它:

packages/BouncyCastle.1.7.0/lib/Net40-Client/crypto.xml:        <member name="T:Org.BouncyCastle.OpenSsl.PemReader">

One thing that I notice, however, is that it comes up as Net40-Client . 我注意到的一件事是,它以Net40-Client Is this an issue? 这是问题吗? Was it built using a client profile? 它是使用客户端配置文件构建的吗? If so, it seems similar to this issue . 如果是这样,则似乎与此问题类似。 However, I am not sure how to actually change this profile if this is the case, since it is a pre-built library. 但是,我不确定在这种情况下如何实际更改此配置文件,因为它是一个预先构建的库。

Are you sure you are using the using in the same project where the DLL has been added as a reference? 您确定要在添加了DLL作为参考的同一项目中using吗?

Edit 1: I just tried that and it is working for me. 编辑1:我只是尝试过,并且它对我有用。 Please verify if you are using it in relevant project. 请验证您是否在相关项目中使用它。

I was having the same issue. 我有同样的问题。 Eventually I noticed that BouncyCastle.Crypto.dll (which was in the correct project's bin folder) wanted me to right click on it and select "Include in Project". 最终,我注意到BouncyCastle.Crypto.dll(位于正确项目的bin文件夹中)希望我右键单击它,然后选择“包含在项目中”。 This was the fix I needed to succssfully reference the bouncy castle classes =^.^= 这是我成功引用弹性城堡类= ^。^ =所需要的解决方案。

right click the project click unload then reload. 右键单击项目,然后单击“卸载”,然后重新加载。

you should then see BouncyCastle in the references folder in the project. 您应该在项目的references文件夹中看到BouncyCastle。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM