I guess you will have to live with the fact that Windsor doesn't work when developing applications in design-mode. Maybe there's a workaround, I don't work with winforms nor WPF myself.
[email protected] wrote: > I tried this, but without any success :-) The eventhandler will not be > called while in > design mode . If i run the application everything is fine, even > without the > eventhandler. > Furthermore i don't want to load any assembly by hand. I use > the container to exactly avoid this. For testing purposes i tried this > way, but > i don't want to have a reference to Persistence.Broker.NHibernate > anywhere in > the application, beside the xml configuration. > > I could cry...:-( > > On May 18, 10:56 am, Jimmy Shimizu <[email protected]> wrote: > >> If you use Assembly.Load, Castle wont be able to resolve it unless you >> create a custom AssemblyResolve-eventhandler, like this: >> >> private static Assembly AssemblyResolveEventHandler( object sender, >> ResolveEventArgs args ) >> { >> var assemblies = AppDomain.CurrentDomain.GetAssemblies(); >> foreach ( var assembly in assemblies ) >> { >> var assemblyName = assembly.GetName(); >> >> if ( assemblyName.Name == args.Name ) >> { >> return assembly; >> } >> } >> >> // Failed to find the desired assembly >> return null; >> >> } >> >> And then you need to add this handler like this: >> >> AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolveEventHandler; >> >> [email protected] wrote: >> >>>> If you have a project reference, it should work out of the box afaik. >>>> >>> That was my assumption too.The project UI.Contol wich contains >>> the Objectsoure, has a reference to Persistence.Broker and a reference >>> to Core.Infrastructure to access the container. Both have the property >>> "copy local" enabled. But in Design Time my application is not >>> running and VS copies nothing to the temp directory is uses. >>> So then i started out to load the assemblies manually, but it all >>> doesn't work. As far as i can see, i did all from Assembly.Load to >>> Switching the load context...without any success, Castle is not >>> able to resolve the correct type. >>> Now i tried to remove the "service" tag from the configuration >>> >>> <component >>> id="IPersistenceClient_NH" >>> type="Persistence.Broker.NHibernate.PersistenceService, >>> Persistence.Broker.NHibernate"> >>> </component> >>> >>> and added a reference to Persistence.Broker.NHibernate to the >>> UI.Control project. >>> >>> IPersistenceService pPService = (IPersistenceService) >>> CoreApplication.Application.ServiceManager.doResolveByKey >>> ("IPersistenceClient_NH"); >>> >>> This leads to the error: ComponentActivator: Could not instantiate >>> Persistence.Broker.NHibernate >>> >>> Volker >>> >>> On 18 Mai, 09:54, Jimmy Shimizu <[email protected]> wrote: >>> >>>> I think you have come across the issue where manually loaded assemblies >>>> ( Assembly.Load() ) can't be found automatically when you're trying to >>>> access them. >>>> >>>> Please check this >>>> post:http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx >>>> >>>> However, you shouldn't need to load your assemblies manually, just make >>>> sure your Persistence.Broker.NHibernate-assembly is in your working >>>> directory. If you've added it as a reference to your project, make sure >>>> you enable "copy local" in the properties for that reference. If you >>>> have a project reference, it should work out of the box afaik. >>>> >>>> VolkerR wrote: >>>> >>>>> Hi, >>>>> i'm working on a application using Windows Forms. The app builds upon >>>>> Castle and NHibernate. Because >>>>> i don't want to have any references to NHibernate in the domain model >>>>> or the view, i use a separate layer to >>>>> access persistent objects. This is done through castle, with the >>>>> following sample configuration: >>>>> <configuration> >>>>> <components> >>>>> <component >>>>> id="IPersistenceService" >>>>> service="Persistence.Broker.Definition.IPersistenceService, >>>>> Persistence.Broker" >>>>> type="Persistence.Broker.NHibernate.PersistenceService, >>>>> Persistence.Broker.NHibernate"> >>>>> </component> >>>>> <component >>>>> id="IRepository" >>>>> service="Persistence.Broker.Definition.IRepository`1, >>>>> Persistence.Broker" >>>>> type="Persistence.Broker.NHibernate.NHibernateRepository`1, >>>>> Persistence.Broker.NHibernate" >>>>> lifestyle="transient"> >>>>> </component> >>>>> </components> >>>>> </configuration> >>>>> >>>>> So far so good. Everything works fine while running the application. >>>>> The IPersistenceService provides >>>>> access to metadata informations about the domain model. This >>>>> information is needed for certain >>>>> circumstances. One example is data binding. And here we come close to >>>>> the problem. For example I want to write an ObjectSource - class, >>>>> based on BindingSource. The ObjectSource should provide an >>>>> implementation >>>>> for the >>>>> >>>>> PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] >>>>> listAccessors) >>>>> >>>>> method that returns a PropertyDescriptorCollection based on the class, >>>>> the ObjectSource is responsible for. >>>>> To achieve this, the ObjectSource needs a property that specifies the >>>>> IClassDefinition that holds the information about attributes etc. For >>>>> this reason i build an UITypeEditor that simply displays a ListBox >>>>> where the >>>>> developer can select the needed IClassDefinition. The UITypeEditor >>>>> needs access to the metadata information at design time and that >>>>> means, it needs access to an instance of IPersistenceService. And here >>>>> we are...i have to build a WindsorContainer at design time that wires >>>>> up the services correctly. But this does not work. I can build the >>>>> container and load the configuration XML, but Castle can not resolve >>>>> the type for Persistence.Broker.NHibernate.PersistenceService. So my >>>>> first thougth was, that the assemblies could not be find. This is >>>>> surely true, because the VS FormDesigner stores files in an temp >>>>> directory. So I tried to give the assemblies strong names to put them >>>>> in the GAC. But the container still complains about not resolving the >>>>> type Persistence.Broker.NHibernate.PersistenceService. The next try >>>>> was to load the necessary assemblies by myself. There was no failure >>>>> loading them at design time, but der Container still was not able to >>>>> resolve then correct type. So I ended up, building an application >>>>> object just for design time purposes, that uses an own application >>>>> domain with the base directory pointing to the assemblies. I created >>>>> the Container in the context of the new domain, but it still does not >>>>> work. >>>>> So now i have no further idea, how to solve this. I have to admit that >>>>> i'm not so deep in all the .net internals rigth now, because i just >>>>> came over from C++/Delphi. Maybe the solution is really simple, and i >>>>> just can not see it :-) >>>>> So, if you anyone could give me a hint, maybe just about how Castle >>>>> resolves assemblies at all, it would be very grateful. >>>>> >>>>> Thanks for reading >>>>> Volker >>>>> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
