Я столкнулся с проблемой (Важно отметить, что отладчик вообще не выполняет CivicaHousingRepairsModule .... Если я вставляю точку останова в первой строке ... ничего не происходит.), Так как последние 2 дня безлюбая подсказка. Я создал пример приложения, используя Silverlight 4, PRISM 4.0 и MEF.Какие два модуля соответствуют следующим образом.
//Module 1
namespace Civica.Housing.Security
{
[ModuleExport(typeof(CivicaHousingSecurityModule),InitializationMode = InitializationMode.OnDemand)]
public class CivicaHousingSecurityModule:IModule
{
private readonly IRegionManager _regionManager;
[ImportingConstructor] //MEF magic to for resolving all the DI
public CivicaHousingSecurityModule(IRegionManager regionManager, IAuthenticationService authenticationService)
{
regionManager.CheckForNull("regionManager");
_regionManager = regionManager;
}
#region IModule Implementation
public void Initialize()
{
}
#endregion
}
}
//Module 2
namespace Civica.Housing.Repairs
{
[ModuleExport(typeof(CivicaHousingRepairsModule), InitializationMode = InitializationMode.OnDemand)]
public class CivicaHousingRepairsModule : IModule
{
private readonly IRegionManager _regionManager;
#region Constructor
[ImportingConstructor]
public CivicaHousingRepairsModule(IRegionManager regionManager, IAuthenticationService authenticationService)
{
regionManager.CheckForNull("regionManager");
_regionManager = regionManager;
}
#endregion
#region IModule Implementation
public void Initialize()
{
_regionManager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(TestView));
}
#endregion
}
}
Ниже приведен код для модуля regestring ( ModuleCatalog.xaml ).
<Modularity:ModuleCatalog xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:Modularity="clr-
namespace:Microsoft.Practices.Prism.Modularity;assembly=Microsoft.Practices.Prism">
<Modularity:ModuleInfo Ref="Civica.Housing.Security.xap" InitializationMode="OnDemand"
ModuleName="CivicaHousingSecurityModule" />
<Modularity:ModuleInfo Ref="Civica.Housing.Repairs.xap" InitializationMode="OnDemand"
ModuleName="CivicaHousingRepairsModule" />
</Modularity:ModuleCatalog>
Теперь следуеткод для Bootstrapper
public class CivicaHousingBootstrapper : MefBootstrapper
{
private const string ModuleCatalogUri =
"/Civica.Housing.App;component/ModulesCatalog.xaml";
.
.
.
protected override Microsoft.Practices.Prism.Modularity.IModuleCatalog CreateModuleCatalog()
{
var moduleCatalog=Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml
(new Uri(ModuleCatalogUri,
UriKind.Relative));
return moduleCatalog;
}
.
.
.
}
ПРОБЛЕМА:
При переходе от одного модуля (Безопасность) к другому (Ремонт), то это дастмне следующее Ошибка
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR
2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E;
Tablet PC 2.0)
Timestamp: Wed, 22 Feb 2012 13:18:00 UTC
Message: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: Microsoft.Practices.Prism.Modularity.ModuleInitializeException: An exception
occurred while initializing module 'CivicaHousingRepairsModule'.
- The exception message was: The composition remains unchanged. The changes were rejected
because of the following error(s): The composition produced multiple composition errors, with 3
root causes. The root causes are provided below. Review the CompositionException.Errors property
for more detailed information.
1) More than one export was found that matches the constraint '((exportDefinition.ContractName ==
"Civica.Housing.Services.IRepairsDataService") AndAlso (exportDefinition.Metadata.ContainsKey
("ExportTypeIdentity") AndAlso "Civica.Housing.Services.IRepairsDataService".Equals
(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))'.
Resulting in: Cannot set import 'Civica.Housing.Security.ViewModels.DashboardViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")'
on part 'Civica.Housing.Security.ViewModels.DashboardViewModel'.
Element: Civica.Housing.Security.ViewModels.DashboardViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")
--> Civica.Housing.Security.ViewModels.DashboardViewModel --> AssemblyCatalog
(Assembly="Civica.Housing.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
2) More than one export was found that matches the constraint '((exportDefinition.ContractName ==
"Civica.Housing.Services.IRepairsDataService") AndAlso (exportDefinition.Metadata.ContainsKey
("ExportTypeIdentity") AndAlso "Civica.Housing.Services.IRepairsDataService".Equals
(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))'.
Resulting in: Cannot set import 'Civica.Housing.Security.ViewModels.ShortcutViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")'
on part 'Civica.Housing.Security.ViewModels.ShortcutViewModel'.
Element: Civica.Housing.Security.ViewModels.ShortcutViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")
--> Civica.Housing.Security.ViewModels.ShortcutViewModel --> AssemblyCatalog
(Assembly="Civica.Housing.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
3) More than one export was found that matches the constraint '((exportDefinition.ContractName ==
"Civica.Housing.Services.IRepairsDataService") AndAlso (exportDefinition.Metadata.ContainsKey
("ExportTypeIdentity") AndAlso "Civica.Housing.Services.IRepairsDataService".Equals
(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))'.
Resulting in: Cannot set import 'Civica.Housing.Security.ViewModels.HeaderViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")'
on part 'Civica.Housing.Security.ViewModels.HeaderViewModel'.
Element: Civica.Housing.Security.ViewModels.HeaderViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")
--> Civica.Housing.Security.ViewModels.HeaderViewModel --> AssemblyCatalog
(Assembly="Civica.Housing.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
Check the InnerException property of the exception for more information. If the exception
occurred
while creating an object in a DI container, you can exception.GetRootException() to help
locate the
root cause of the problem. ---> System.ComponentModel.Composition.ChangeRejectedException:
The composition remains unchanged. The changes were rejected because of the following error(s):
The composition produced multiple composition errors, with 3 root causes. The root causes are
provided below. Review the CompositionException.Errors property for more detailed information.
1) More than one export was found that matches the constraint '((exportDefinition.ContractName ==
"Civica.Housing.Services.IRepairsDataService") AndAlso (exportDefinition.Metadata.ContainsKey
("ExportTypeIdentity") AndAlso "Civica.Housing.Services.IRepairsDataService".Equals
(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))'.
Resulting in: Cannot set import 'Civica.Housing.Security.ViewModels.DashboardViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")'
on part 'Civica.Housing.Security.ViewModels.DashboardViewModel'.
Element: Civica.Housing.Security.ViewModels.DashboardViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")
--> Civica.Housing.Security.ViewModels.DashboardViewModel --> AssemblyCatalog
(Assembly="Civica.Housing.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
2) More than one export was found that matches the constraint '((exportDefinition.ContractName ==
"Civica.Housing.Services.IRepairsDataService") AndAlso (exportDefinition.Metadata.ContainsKey
("ExportTypeIdentity") AndAlso "Civica.Housing.Services.IRepairsDataService".Equals
(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))'.
Resulting in: Cannot set import 'Civica.Housing.Security.ViewModels.ShortcutViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")'
on part 'Civica.Housing.Security.ViewModels.ShortcutViewModel'.
Element: Civica.Housing.Security.ViewModels.ShortcutViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")
--> Civica.Housing.Security.ViewModels.ShortcutViewModel --> AssemblyCatalog
(Assembly="Civica.Housing.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
3) More than one export was found that matches the constraint '((exportDefinition.ContractName ==
"Civica.Housing.Services.IRepairsDataService") AndAlso (exportDefinition.Metadata.ContainsKey
("ExportTypeIdentity") AndAlso "Civica.Housing.Services.IRepairsDataService".Equals
(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))'.
Resulting in: Cannot set import 'Civica.Housing.Security.ViewModels.HeaderViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")'
on part 'Civica.Housing.Security.ViewModels.HeaderViewModel'.
Element: Civica.Housing.Security.ViewModels.HeaderViewModel..ctor
(Parameter="_iRepairsDataService", ContractName="Civica.Housing.Services.IRepairsDataService")
--> Civica.Housing.Security.ViewModels.HeaderViewModel --> AssemblyCatalog
(Assembly="Civica.Housing.Security, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
at System.ComponentModel.Composition.CompositionResult.ThrowOnErrors(AtomicComposition
atomicComposition)
at System.ComponentModel.Composition.Hosting.ExportProvider.OnExportsChanging
(ExportsChangeEventArgs e)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.OnCatalogChanging(Object
sender, ComposablePartCatalogChangeEventArgs e)
at System.ComponentModel.Composition.Hosting.ComposablePartCatalogCollection.OnChanging(Object
sender, ComposablePartCatalogChangeEventArgs e)
at System.ComponentModel.Composition.Hosting.AggregateCatalog.OnChanging
(ComposablePartCatalogChangeEventArgs e)
at
System.ComponentModel.Composition.Hosting.ComposablePartCatalogCollection.RaiseChangingEvent
(Lazy`1 addedDefinitions, Lazy`1 removedDefinitions, AtomicComposition atomicComposition)
at System.ComponentModel.Composition.Hosting.ComposablePartCatalogCollection.Add
(ComposablePartCatalog item)
at Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleInitializer.CreateModule
(ModuleInfo moduleInfo)
at Microsoft.Practices.Prism.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo)
--- End of inner exception stack trace ---
at Microsoft.Practices.Prism.Modularity.ModuleInitializer.HandleModuleInitializationError
(ModuleInfo moduleInfo, String assemblyName, Exception exception)
at Microsoft.Practices.Prism.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo)
at Microsoft.Practices.Prism.Modularity.ModuleManager.InitializeModule(ModuleInfo moduleInfo)
at Microsoft.Practices.Prism.Modularity.ModuleManager.LoadModulesThatAreReadyForLoad()
at Microsoft.Practices.Prism.Modularity.ModuleManager.IModuleTypeLoader_LoadModuleCompleted
(Object sender, LoadModuleCompletedEventArgs e)
at
Microsoft.Practices.Prism.MefExtensions.Modularity.MefXapModuleTypeLoader.RaiseLoadModuleComplete
d(LoadModuleCompletedEventArgs e)
at
Microsoft.Practices.Prism.MefExtensions.Modularity.MefXapModuleTypeLoader.RaiseLoadModuleComplete
d(ModuleInfo moduleInfo, Exception error)
at
Microsoft.Practices.Prism.MefExtensions.Modularity.MefXapModuleTypeLoader.HandleDownloadCompleted
(DeploymentCatalog deploymentCatalog, AsyncCompletedEventArgs e)
at
Microsoft.Practices.Prism.MefExtensions.Modularity.MefXapModuleTypeLoader.DeploymentCatalog_Downl
oadCompleted(Object sender, AsyncCompletedEventArgs e)
at System.ComponentModel.Composition.Hosting.DeploymentCatalog.OnDownloadCompleted
(AsyncCompletedEventArgs e)
at System.ComponentModel.Composition.Hosting.DeploymentCatalog.HandleOpenReadCompleted(Object
sender, OpenReadCompletedEventArgs e)
at System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)
at System.Net.WebClient.OpenReadOperationCompleted(Object arg)
Line: 56
Char: 13
Code: 0
URI: http://localhost:61228/Civica.Housing.aspx
Важное примечание: Отладчик вообще не запускает CivicaHousingRepairsModule Если я вставляю точку останова
вв первой строке ничего не найдено.
Я пытался выполнить : 1. Я установил все библиотеки PRISM для localcopy на false.
Пожалуйста, дайте мне знать, если у вас естьстолкнулся с той же проблемой, и у вас есть хорошее решение для нее.Ваши ответы или предложения будут оценены.