我想用下面的代碼顯示PluginManagerView的實例。不包含「顯示」的定義,也沒有擴展方法「顯示」錯誤
此XAML文件位於相同的命名空間,同一項目中。但我在mainwindow.Show();
說
Error 1 'PluginManager.PluginManagerView' does not contain a definition for 'Show' and no extension method 'Show' accepting a first argument of type 'PluginManager.PluginManagerView' could be found (are you missing a using directive or an assembly reference?) Blah procedyre .cs 30 24 PluginManager
誰能告訴我是什麼問題行的錯誤?爲什麼它不會拋出MainWindow之前的使用錯誤?
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.ComponentModel.Composition.Hosting;
namespace PluginManager
{
public class PublicProcedures : Application
{
public static void ShowPlugins()
{
var mainwindow = new PluginManagerView();
//An aggregate catalog that combines multiple catalogs
var catalog = new AggregateCatalog();
//Adds all the parts found in the same assembly as the Program class
//catalog.Catalogs.Add(new AssemblyCatalog(this.GetType().Assembly));
catalog.Catalogs.Add(new DirectoryCatalog("./Plugins/"));
var container = new CompositionContainer(catalog);
var modules = container.GetExportedValues<IPlugin>();
mainwindow.DataContext = modules;
mainwindow.Show();
}
}
}