【问题标题】:VS 2013 Error-"No exports were found that match the constraint:"VS 2013 错误-“未找到与约束匹配的导出:”
【发布时间】:2017-03-06 00:42:39
【问题描述】:

我在 Windows 10 上使用 Visual Studio 2013,今天我收到错误“找不到与约束匹配的导出:”

我做了以下但仍然有同样的问题:

  1. 链接中给出的解决方案 Error message "No exports were found that match the constraint contract name"

通过删除/重命名“ComponentModelCache”文件夹,但仍然存在问题。

  1. 运行 VS 修复,但仍然有同样的问题。

  2. 最后,我卸载了 Visual Studio 2013 并重新安装,但仍然有 同样的问题。

请建议现在做什么?

【问题讨论】:

    标签: visual-studio


    【解决方案1】:

    最后,我自己找到了答案,而不是在路径中删除/重命名“ComponentModelCache”文件夹 C:\Users\'用户名'\AppData\local\Microsoft\VisualStudio\12.0

    我在路径中重命名了文件夹“Microsoft” C:\Users\'用户名'\AppData\local\

    这对我有用。

    【讨论】:

      【解决方案2】:

      您可以看到here更多需要删除%APPDATA%中的缓存的解决方案。

      在我的例子中,问题在于我正在使用 MEF 框架初始化和使用类,但没有将该类声明为 MEF 类。

      如何导入 MEF 类:

      [Import(typeof(ICalculator))]  
      public ICalculator calculator;
      

      如何定义和导出 MEF 类:

      public interface ICalculator  
      {  
           String Calculate(String input);  
      }  
      
      [Export(typeof(ICalculator))]  
      class MySimpleCalculator : ICalculator  
      {
      }
      

      代码示例取自here

      【讨论】:

        【解决方案3】:

        很抱歉为旧的“已回答”线程做出贡献。但是对我来说,使用 Win 10,VS 2013。在解决此问题之前,我必须从我安装的每个版本的 VS 中删除“ComponentModelCache”文件夹。

        【讨论】:

          猜你喜欢
          • 2014-07-13
          • 1970-01-01
          • 2022-10-06
          • 1970-01-01
          • 2013-10-13
          • 2014-02-17
          • 2013-07-09
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多