如何在WPF中基于Prism MVVM执行项目 [英] how to execute the Project based on Prism MVVM in WPF

查看:54
本文介绍了如何在WPF中基于Prism MVVM执行项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的场景,因为有四个项目命名为

1)Freedom.Composite.Core

2)Freedom.Composite.Styles(目录,命令,转换器) ,LoggerComponents,LoggersViewModelHelper)

3)Freedom.Core.XmlSerializers(UI的不同样式)

4)SyncDash(有视图。)



当我执行这些项目时,它会提示我无法直接启动具有类库输出类型的项目。

为了调试这些项目,添加一个可执行项目到这个引用库项目的解决方案。将可执行项目作为启动项目。



所以为此,我做了一个hello world项目引用链接http://msdn.microsoft.com/en-us/library/ff921141(v=pandp.40).aspx



所以从样本中得到它应用程序它是'加载项目的Bootstrapper'。

Bootstrapper的源代码如下所示。

u使用System.Collections.Generic唱歌系统;

;

使用System.Linq;

使用System.Text;

使用System.Threading.Tasks;

使用System.Windows;

使用Microsoft.Practices.Prism.Modularity;

使用Microsoft。 Practices.Prism.UnityExtensions;

使用Microsoft.Practices.Unity;







命名空间HelloWorld.Desktop

{

class Bootstrapper:UnityBootstrapper

{



protected override DependencyObject CreateShell()

{



返回新的Shell();

}



protected override void InitializeShell()

{

base.InitializeShell();



Application.Current.MainWindow =(Window)this.Shell;

Application.Current.MainWindow.Show();

< br $>
}





protected override void ConfigureModuleCatalog()

{

base.ConfigureModuleCatalog();

ModuleCatalog moduleCatalog =(ModuleCatalog)this.ModuleCatalog;

// moduleCatalog .AddModule(typeof(HelloWorldModule2.HelloWorldModule2));

//moduleCatalog.AddModule(typeof(SyncDash.Views.SyncDashMainView));

moduleCatalog.AddModule(typeof(SyncDash) .Views.UCSyncSettings));

//moduleCatalog.AddModule(typeof(SyncDash.Views.UCServiceBusSettings));



}









}



}







所以当我运行解决方案它给我一个激活异常....我真的需要高优先级运行这个解决方案......请帮助我.....它的优先级高。请提前谢谢。

I have the scenario as there are four projects named as
1) Freedom.Composite.Core
2) Freedom.Composite.Styles(Catalogs,Commands,Converters,LoggerComponents,LoggersViewModelHelper)
3) Freedom.Core.XmlSerializers(Different Styles of the UI)
4) SyncDash(There are views into it.The )

When I execute these project it prompts me "A project with output type of class library could not be started directly.
In orderto debug these project,add an executable project to this solution which references the library project.Set the executable project as the startup project."

So for this I have made a hello world project referring the link http://msdn.microsoft.com/en-us/library/ff921141(v=pandp.40).aspx

So got it from the sample Application that it is the 'Bootstrapper that loads the projects'.
The source code for the Bootstrapper is as Given below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.UnityExtensions;
using Microsoft.Practices.Unity;



namespace HelloWorld.Desktop
{
class Bootstrapper : UnityBootstrapper
{

protected override DependencyObject CreateShell()
{

return new Shell();
}

protected override void InitializeShell()
{
base.InitializeShell();

Application.Current.MainWindow = (Window)this.Shell;
Application.Current.MainWindow.Show();

}


protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
ModuleCatalog moduleCatalog = (ModuleCatalog)this.ModuleCatalog;
// moduleCatalog.AddModule(typeof(HelloWorldModule2.HelloWorldModule2));
//moduleCatalog.AddModule(typeof(SyncDash.Views.SyncDashMainView));
moduleCatalog.AddModule(typeof(SyncDash.Views.UCSyncSettings));
//moduleCatalog.AddModule(typeof(SyncDash.Views.UCServiceBusSettings));

}




}

}



So when I run the Solution It gives me an Activation Exception....I really need to run this solution on a high priority...Please help me .....Its on a high priority .Thanks in advance .

推荐答案

它与您的代码无关。这只是使用Visual Studio的问题。它的解决方案资源管理器具有上下文菜单。您需要选择要运行的内容。选择应用程序项目节点,而不是库项目。激活上下文菜单。从该菜单运行选定的应用程序,或者在运行解决方案时启动启动项目(F5)。



-SA
It has nothing to do with your code. This is nothing but the matter of using Visual Studio. It's Solution Explorer has the context menu. You need to choose what to run. Select the application project node, not the library project. Activate the context menu. Either run selected application from that menu, or makes it "startup project" to be started when you "run" the solution (F5).

—SA


我做了一个可执行项目作为启动项目,但它给出了激活异常。我该怎么办?
I did that made an executable project as startup project but yet it gives an activation exception. what should I do?


这篇关于如何在WPF中基于Prism MVVM执行项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆