简体   繁体   English

无法使用Web服务加载文件或程序集'Autofac,Version = 2.6.1.841

[英]Could not load file or assembly 'Autofac, Version=2.6.1.841 with webservice

I'm building an web service on sharepoint with IoC. 我正在用IoC在sharepoint上构建Web服务。 Here is my main code: 这是我的主要代码:

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1), WebService(Namespace = "http://tempuri.org/")]
class WebService : System.Web.Services.WebService
{
    private static IContainer Container { get; set; }
    private DataTable Articles=new DataTable();
    private string display;
    [WebMethod(EnableSession = true, Description = "Web method for using search service")]
    public string DisplayArticles()
    {
        var builder = new ContainerBuilder();
        builder.RegisterType<WebServiceRepo>().As<IArticlesRepository>();
        Container = builder.Build();
        Search();
        return display;
    }

    public void Search()
    {
        using (var scope = Container.BeginLifetimeScope())
        {
            var repo = scope.Resolve<IArticlesRepository>();
            Articles.Load(repo.GetArticles(),LoadOption.OverwriteChanges);
            display = repo.ReturnArticles(Articles);
        }
    }
}

The problem is an error I'm getting when trying to invoke method that uses Autofac: 问题是尝试调用使用Autofac的方法时遇到的错误:

    System.IO.FileNotFoundException: Could not load file or assembly 'Autofac, Version=2.6.1.841, Culture=neutral, PublicKeyToken=17863af14b0044da' or one of its dependencies. The system cannot find the file specified.
   at SOAP_WebService.WebService.DisplayArticles()

It says about file not being found, but an Autofac.dll with version 2.6.1.841 exists in bin/debug folder. 它说找不到文件,但是bin / debug文件夹中存在版本2.6.1.841的Autofac.dll。 I'm using this version of autofac because working on sharepoint 2010, I can only choose .net framework v3.5 and it's one of the newest version that operates on this version of .net framework. 我正在使用此版本的autofac,因为在SharePoint 2010上工作时,我只能选择.net Framework v3.5,它是可在此.net Framework版本上运行的最新版本之一。

Answers provided in simmiliar questions did not help me. 简单问题中提供的答案对我没有帮助。

Somehow i managed to work it out... If anyone will have a simmiliar problem: 我设法设法解决了...如果有人遇到类似问题:

The Autofac assembly I added to the references in my project, was somehow impossible to find by visual studio, despite the fact that file existed in my project (I'll be gratefull if someone will explain me why did it happen). 尽管我的项目中存在文件,但我在项目中的引用中添加的Autofac程序集还是无法通过Visual Studio找到的(如果有人向我解释为什么会发生,我将不胜感激)。 The solution to it was adding this assembly to the GAC via Developer Command Prompt by this command: 解决方案是通过以下命令通过开发人员命令提示符将此程序集添加到GAC:

 gacutil /i <path to the assembly> /f

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

相关问题 无法加载文件或程序集Autofac - Could not load file or assembly Autofac 使用Autofac获取错误“无法加载文件或程序集&#39;system.web.mvc版本= 5.1.0.0” - Using Autofac get error “could not load file or assembly 'system.web.mvc version=5.1.0.0” Azure函数-无法加载文件或程序集&#39;AzureFunctions.Autofac.Shared&#39; - Azure Functions - Could not load file or assembly ''AzureFunctions.Autofac.Shared' 无法加载文件或程序集&#39;Microsoft.Bot.Builder.Autofac, - Could not load file or assembly 'Microsoft.Bot.Builder.Autofac, 无法加载文件或程序集 &#39;EntityFramework,版本 = 6.0.0.0, - Could not load file or assembly 'EntityFramework, Version=6.0.0.0, 无法加载文件或程序集 &#39;Ninject 版本 4.0.0.0 - Could not load file or assembly 'Ninject version 4.0.0.0 无法加载文件或程序集&#39;RevitApi&#39;版本= 19.0.0.0, - Could not load file or assembly 'RevitApi' version = 19.0.0.0, 无法加载文件或程序集 &#39;RestSharp,版本 = 105.2.3.0 - Could not load file or assembly 'RestSharp, Version=105.2.3.0 无法加载文件或程序集&#39;WebGrease,Version = 1.5.1.25624 - Could not load file or assembly 'WebGrease, Version=1.5.1.25624 无法加载文件或程序集 &#39;EntityFramework,版本 = 6.0.0.0 - Could not load file or assembly 'EntityFramework, Version=6.0.0.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM