无法使用 web 服务加载文件或程序集 'Autofac,版本 = 2.6.1.841
Could not load file or assembly 'Autofac, Version=2.6.1.841 with webservice
我正在使用 IoC 在 Sharepoint 上构建 Web 服务。这是我的主要代码:
[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);
}
}
}
问题是我在尝试调用使用 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()
它说找不到文件,但是 bin/debug 文件夹中存在版本为 2.6.1.841 的 Autofac.dll。我正在使用此版本的 autofac,因为在 Sharepoint 2010 上工作,我只能选择 .net framework v3.5,它是在此版本的 .net framework 上运行的最新版本之一。
类似问题中提供的答案对我没有帮助。
不知何故我设法解决了...如果有人遇到类似的问题:
我添加到项目引用中的 Autofac 程序集,visual studio 无法找到,尽管我的项目中存在该文件(如果有人能解释原因,我将不胜感激它发生了吗)。解决方案是通过以下命令通过开发人员命令提示将此程序集添加到 GAC:
gacutil /i <path to the assembly> /f
我正在使用 IoC 在 Sharepoint 上构建 Web 服务。这是我的主要代码:
[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);
}
}
}
问题是我在尝试调用使用 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()
它说找不到文件,但是 bin/debug 文件夹中存在版本为 2.6.1.841 的 Autofac.dll。我正在使用此版本的 autofac,因为在 Sharepoint 2010 上工作,我只能选择 .net framework v3.5,它是在此版本的 .net framework 上运行的最新版本之一。
类似问题中提供的答案对我没有帮助。
不知何故我设法解决了...如果有人遇到类似的问题:
我添加到项目引用中的 Autofac 程序集,visual studio 无法找到,尽管我的项目中存在该文件(如果有人能解释原因,我将不胜感激它发生了吗)。解决方案是通过以下命令通过开发人员命令提示将此程序集添加到 GAC:
gacutil /i <path to the assembly> /f