【问题标题】:WPF The type or namespace name 'CompositionInitializer' does not exist in the namespace 'System.ComponentModel.Composition'WPF 命名空间“System.ComponentModel.Composition”中不存在类型或命名空间名称“CompositionInitializer”
【发布时间】:2016-03-08 11:35:27
【问题描述】:

我正在尝试将我的 silverlight 应用程序转换为 wpf 应用程序。我有这段代码,它是用 silverlight 编写的,它引用了 system.componentModel.Composition.CompositionInitializer 但是当我尝试在 WPF 中引用它时。它不可用。我该怎么办:

这是我的错误:

public ParserFactory()
    {
        System.ComponentModel.Composition.CompositionInitializer.SatisfyImports(this);

        foreach (var item in _ParserList)
        {
            var type = item.Metadata.ParserType;
            var value = item.Value;

            Parsers.Add(type, value);
        }
    }

这是我的一段代码:

错误 2 命名空间“System.ComponentModel.Composition”中不存在类型或命名空间名称“CompositionInitializer”(您是否缺少程序集引用?) c:\Users\sahluwai\Desktop\cusControls2\leitch\HarrisSilverlightToolkit\ Toolkit\Source\XmlSerializableObject\SerializerFactory.cs 44 47 XmlSerializableObject

我该怎么办。是否有其他我可以参考的程序集。 WPF中的解决方法是什么。 谢谢。

【问题讨论】:

  • 您是否在项目中引用了该程序集?
  • “System.ComponentModel.Composition.CompositionInitializer”在列表中不可用,当我尝试通过右键单击引用并单击“添加引用...”来添加程序集时
  • 任何其他想法。该怎么办?
  • 添加对System.ComponentModel.Composition的引用。 CompositionInitializer 是该程序集命名空间中的成员
  • 已经试过了。这是行不通的。它不是 System.ComponentModel.Composition 的一部分

标签: c# .net wpf silverlight namespaces


【解决方案1】:

您需要引用库 System.ComponentModel.Composition.Initialization.dll 才能访问该类。

https://msdn.microsoft.com/en-us/library/system.componentmodel.composition.compositioninitializer(v=vs.95).aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-19
    • 1970-01-01
    • 2012-05-28
    • 1970-01-01
    • 1970-01-01
    • 2018-05-09
    • 2022-01-11
    • 2021-10-15
    相关资源
    最近更新 更多