简体   繁体   English

System.IO.FileNotFoundException:无法加载文件或程序集'System.Web.DataVisualization MEF MVC

[英]System.IO.FileNotFoundException: Could not load file or assembly 'System.Web.DataVisualization MEF MVC

I am creating a website which should be able to take in multiple modules and compose those modules to a main project. 我正在创建一个网站,该网站应该能够采用多个模块并将这些模块组成一个主要项目。 After programming the bootstrapper and custom View engine to make it able to find Views in the module.dll. 对引导程序和自定义View引擎进行编程后,使其能够在module.dll中找到View。

After compiling a test module for testing, I am getting a weird error where it says it cannot load System.Web.DataVisualization for some reason. 编译了用于测试的测试模块后,出现一个奇怪的错误,它说由于某种原因它无法加载System.Web.DataVisualization。 I have also noticed that the Controller from the Module dll gets loaded properly, I can see it in the debug but this error keeps killing a thread and throws the error. 我还注意到,Module dll中的Controller已正确加载,我可以在调试中看到它,但是此错误不断杀死线程并引发错误。

在此处输入图片说明

This is the code I have for Bootstrapper.cs that handles the loading/composing of the dlls. 这是我为Bootstrapper.cs处理的dll的加载/组成的代码。

using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.IO;

public class Bootstrapper
{
    private static CompositionContainer CompositionContainer;
    private static bool IsLoaded = false;

    public static void Compose(List<string> pluginFolders)
    {   
        if (IsLoaded) return;

        var catalog = new AggregateCatalog();

        catalog.Catalogs.Add(new DirectoryCatalog(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin")));

        foreach (var plugin in pluginFolders)
        {
            var directoryCatalog = new DirectoryCatalog(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Modules", plugin));
            catalog.Catalogs.Add(directoryCatalog);

        }
        CompositionContainer = new CompositionContainer(catalog);

        CompositionContainer.ComposeParts();
        IsLoaded = true;
    }

    public static T GetInstance<T>(string contractName = null)
    {
        var type = default(T);
        if (CompositionContainer == null) return type;

        if (!string.IsNullOrWhiteSpace(contractName))
            type = CompositionContainer.GetExportedValue<T>(contractName);
        else
            type = CompositionContainer.GetExportedValue<T>();

        return type;
    }
}

And this is the error that gets thrown out when testing. 这就是测试时抛出的错误。 在此处输入图片说明

The solution for this was to unfortunately manually download the dll and add it to the reference, but the main edit was to Web.Config where I had to define the assembly to import System.Web.DataVisualization as such. 不幸的是,解决方案是手动下载dll并将其添加到引用中,但是主要编辑是Web.Config,在这里我必须定义程序集以导入System.Web.DataVisualization <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

暂无
暂无

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

相关问题 无法加载文件或程序集“System.Web.DataVisualization”或其依赖项之一 - Could not load file or assembly 'System.Web.DataVisualization' or one of its dependencies 无法加载文件或程序集System.IO.FileNotFoundException - Could not load file or assembly System.IO.FileNotFoundException System.IO.FileNotFoundException:无法加载文件或程序集 - System.IO.FileNotFoundException: Could not load file or assembly System.IO.FileNotFoundException: '无法加载文件或程序集 - System.IO.FileNotFoundException: 'Could not load file or assembly 奇怪的错误:System.IO.FileNotFoundException:无法加载文件或程序集 - Weird Error: System.IO.FileNotFoundException: Could not load file or assembly System.IO.FileNotFoundException: 无法加载文件或程序集 C# - System.IO.FileNotFoundException: Could not load file or assembly C# 无法加载程序集&gt;&gt; System.IO.FileNotFoundException:无法加载文件或程序集&#39;System.Core, - Unable to Load assembly>>System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, System.IO.FileNotFoundException:无法在Mono for Android中加载程序集System.Web - System.IO.FileNotFoundException: Could not load assembly System.Web in Mono for Android System.IO.FileNotFoundException:无法加载文件或程序集System.Xml.Linq - System.IO.FileNotFoundException: Could not load file or assembly System.Xml.Linq System.IO.FileNotFoundException:无法加载文件或程序集。 系统找不到文件SharpSvn.dll - System.IO.FileNotFoundException: Could not load file or assembly. The system cannot find the file SharpSvn.dll
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM