简体   繁体   English

添加对.dll asp.net的引用

[英]Add reference to .dll asp.net

I have a simple question about adding references to a .NET project. 我有一个有关向.NET项目添加引用的简单问题。 I'm adding reCAPTCHA to a website and i have downloaded the dll. 我正在将reCAPTCHA添加到网站,并且已经下载了dll。

After setting the reference to the dll i build and run the project and gets this error: 设置对dll的引用后,我构建并运行该项目并得到以下错误:

[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
   System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark) +0
   System.Reflection.Assembly.GetTypes() +96
   StarSuite.Core.Settings.GetSingletonInstancesOfBaseType(Type baseType, String staticMethodName, Type returnType) +149

[ApplicationException: Unable to load types from 'Recaptcha, Version=1.0.5.0, Culture=neutral, PublicKeyToken=9afc4d65b28c38c2'. LoaderExceptions: [FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
]

What am i missing, why do i get this error? 我缺少什么,为什么会出现此错误?

Sorry if the question is silly...Is it your web project MVC? 抱歉,这个问题很愚蠢……是您的Web项目MVC吗? It seems that If you're using web form based project you shouldn't use that component since it relies on mvc assemblies (maybe there is a web form version?). 看来,如果您使用的是基于Web表单的项目,则不应使用该组件,因为它依赖于MVC程序集(也许有Web表单版本?)。

For people finding this whilst searching for a fix for Umbraco, the fix can be found here: 对于在寻找Umbraco的修复程序时发现此问题的人,可以在这里找到修复程序:

http://our.umbraco.org/forum/developers/xslt/19383-referencing-catcha-dll-breaks-xslt http://our.umbraco.org/forum/developers/xslt/19383-referencing-catcha-dll-breaks-xslt

The same fix can be applied to websites that are not running Umbraco. 相同的修补程序可以应用于未运行Umbraco的网站。

Summary to save you having to read the whole forum post, add this to your web config: 摘要以免您不得不阅读整个论坛文章,请将其添加到您的Web配置中:

<runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="1.0.0.0"
          newVersion="2.0.0.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>

File Not Found : 找不到文件

This is you reason - its in the output: 这是您的原因-其在输出中:

FileNotFoundException

Double check where your reference is pointing to 仔细检查您的引用指向的位置

您是否在项目的引用下添加了DLL,以便将其包含在构建中?

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

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