0
我正在使用IoC在SharePoint上構建Web服務。這是我的主要代碼:無法通過web服務加載文件或程序集'Autofac,Version = 2.6.1.841
[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()
它說,關於未找到的文件,而是一個Autofac。在bin/debug文件夾中存在版本爲2.6.1.841的dll。我使用這個版本的autofac是因爲在sharepoint 2010上工作,我只能選擇.net framework v3.5,它是運行在這個.net框架版本上的最新版本之一。
在相似的問題中提供的答案沒有幫助我。