Bonjour, j'utilise WindsorContainer dans mon application WPF. J'ai téléchargé dll-s à partir de ce site: http://stw.castleproject.org/Windsor.MainPage.ashx. WPF est basé sur .NET Framework 4.0, donc j'ajouterImpossible de charger le fichier ou l'assemblage Castle.Windsor
- Castle.Core et
- Castle.Windsor pour .NET 4.0.
I mon projet, je Référer ce Caliburn dll-s:
- Caliburn.Castle
- Caliburn.Core
- Caliburn.PresentationFramework tout pour .NET 4.0
et aussi Microsoft.Practices.ServiceLocator est pour la version 2.0.
Mon code est ressembler à ceci:
App.cs
public partial class App : CaliburnApplication
{
private IWindsorContainer _container;
public App()
{
RegisterComponents();
}
protected override IServiceLocator CreateContainer()
{
_container = new WindsorContainer();
return new WindsorAdapter(_container);
}
protected override object CreateRootModel()
{
return _container.Resolve<IShellViewModel>();
}
protected void RegisterComponents()
{
_container.Register(Component.For<IShellViewModel>()
.ImplementedBy<ShellViewModel>()
.LifeStyle.Singleton);
}
}
App.xaml
<am:CaliburnApplication
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:am="clr-namespace:Caliburn.PresentationFramework.ApplicationModel;assembly=Caliburn.PresentationFramework"
x:Class="Spirit_Messenger.App">
<am:CaliburnApplication.Resources>
</am:CaliburnApplication.Resources>
</am:CaliburnApplication>
Lorsque je tente de compiler mon projet, je reçois cette erreur:
Impossible de charger le fichier ou l'assemblage 'Castle.Windsor, Version = 2.1.0.0, Culture = Neutre, PublicKeyToken = 407dd0808d44fbdc' ou l'une de ses dépendances. La définition de manifeste de l'assembly localisé ne correspond pas à la référence d'assembly. (Exception de HRESULT: 0x80131040)
StakTrace:
* à Spirit_Messenger.App.CreateContainer() à Caliburn.PresentationFramework.ApplicationModel.CaliburnApplication..ctor() à Spirit_Messenger.App .. ctor() dans C: \ Utilisateurs \ Jan \ Documents \ Visual Studio 2010 \ Projets \ C# \ Pokec__Messenger \ Spirit_Messenger \ App.xaml.cs: ligne 15 à Spirit_Messenger.App.Main() dans C: \ Users \ Jan \ Documents \ Visual Studio 2010 \ Projets \ C# \ Pokec__Messenger \ Spirit_Messenger \ obj \ x86 \ Release \ App.g.cs: ligne 50 à System.AppDomain._nExecuteAssembly (assembly RuntimeAssembly, Strin g [] args) à System.AppDomain.ExecuteAssembly (String assemblyFile, Evidence assemblySecurity, String [] args) à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() à System.Threading.ThreadHelper.ThreadStart_Context (état de l'objet) à System.Threading.ExecutionContext.Run (ExecutionContext ExecutionContext, ContextCallback rappel, l'état de l'objet, Boolean ignoreSyncCtx) à System.Threading.ExecutionContext.Run (ExecutionContext ExecutionContext, ContextCallback rappel, l'état de l'objet) à System.Threading.ThreadHelper.ThreadStart() *
Je suis débutant dans WPF/IoC-DI où peut être un problème. Je suis tellement confuse. Merci pour votre aide.
Salut j'utiliser ildasm sur l'assemblage Castle.Widsor.dll et manifeste je vois ceci: // version des métadonnées: v4 .0.30319 .assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 89 E0) // .z \ V.4 .. .ver 4: 0: 0: 0 } Je ne suis pas bon dans CIL, mais je pense que cet assemblage est pour CLR 4.0. J'ai raison? –
Non, ILDASM sur d'autres assemblages utilisant windsor. L'un utilise une version, l'autre une autre version. – Aliostad
J'utilise ildasm sur Castle.Windsor.dll! non sur d'autres assemblées. –