Hi all. I have a question that probably belongs on a users mailing list but I could not find one. I get the following error when trying to use my IronRuby windsor registration script: System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel I assume this has something to do with the fact that newing up an object in IronRuby isn''t the same thing as newing it up in C#. Any suggestions or guidance would be appreciated. Here is the important IronRuby code: require ''Castle.Windsor'' require ''Castle.MicroKernel'' require ''Castle.Core'' ComponentRegistration Castle::MicroKernel::Registration::ComponentRegistration ComponentModel = Castle::Core::ComponentModel Parameter = Castle::MicroKernel::Registration::Parameter Component = Castle::MicroKernel::Registration::Component def component(options) throw :classIsRequired if !options.has_key?(:class) klass = options[:class].to_clr_type if options.has_key?(:service) service = options[:service].to_clr_type else service = klass end if options.has_key?(:name) name = options[:name] else name = klass.class.name.underscore.lowercase end model = ComponentModel.new(name, service, klass) if options.has_key?(:parameters) parameters = options[:parameters] parameters.each do |p| model.Parameters.Add(p.key, p.value) end end $container.Register(ComponentRegistration.new(model)) end -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/cd1084f7/attachment.html>
How do you run this script? From command line (ir.exe script.rb) or do you use hosting API? Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Nathan Stott Sent: Wednesday, March 18, 2009 8:33 AM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] problem Hi all. I have a question that probably belongs on a users mailing list but I could not find one. I get the following error when trying to use my IronRuby windsor registration script: System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel I assume this has something to do with the fact that newing up an object in IronRuby isn''t the same thing as newing it up in C#. Any suggestions or guidance would be appreciated. Here is the important IronRuby code: require ''Castle.Windsor'' require ''Castle.MicroKernel'' require ''Castle.Core'' ComponentRegistration = Castle::MicroKernel::Registration::ComponentRegistration ComponentModel = Castle::Core::ComponentModel Parameter = Castle::MicroKernel::Registration::Parameter Component = Castle::MicroKernel::Registration::Component def component(options) throw :classIsRequired if !options.has_key?(:class) klass = options[:class].to_clr_type if options.has_key?(:service) service = options[:service].to_clr_type else service = klass end if options.has_key?(:name) name = options[:name] else name = klass.class.name.underscore.lowercase end model = ComponentModel.new(name, service, klass) if options.has_key?(:parameters) parameters = options[:parameters] parameters.each do |p| model.Parameters.Add(p.key, p.value) end end $container.Register(ComponentRegistration.new(model)) end -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/7dc12811/attachment.html>
I''m using the hosting API. This is the entire method: public void Load(IWindsorContainer container, TextReader reader) { var runtime = Ruby.CreateRuntime(); ScriptEngine engine = Ruby.GetEngine(runtime); var ctx = Ruby.GetExecutionContext(runtime); ctx.DefineReadOnlyGlobalVariable("container", container); string header @"require ''Castle.Windsor'' require ''Castle.MicroKernel'' require ''Castle.Core'' ComponentRegistration Castle::MicroKernel::Registration::ComponentRegistration ComponentModel = Castle::Core::ComponentModel Parameter = Castle::MicroKernel::Registration::Parameter Component = Castle::MicroKernel::Registration::Component def component(options) throw :classIsRequired if !options.has_key?(:class) klass = options[:class].to_clr_type if options.has_key?(:service) service = options[:service].to_clr_type else service = klass end if options.has_key?(:name) name = options[:name] else name = klass.class.name.underscore.lowercase end model = ComponentModel.new(name, service, klass) if options.has_key?(:parameters) parameters = options[:parameters] parameters.each do |p| model.Parameters.Add(p.key, p.value) end end $container.Register(ComponentRegistration.new(model)) end"; ScriptSource headerSource = engine.CreateScriptSourceFromString(header); headerSource.Execute(); string containerScript = reader.ReadToEnd(); ScriptSource source = engine.CreateScriptSourceFromString(containerScript); source.Execute(); } } 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com>> How do you run this script? From command line (ir.exe script.rb) or do > you use hosting API? > > > > Tomas > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott > *Sent:* Wednesday, March 18, 2009 8:33 AM > *To:* ironruby-core at rubyforge.org > *Subject:* [Ironruby-core] problem > > > > Hi all. I have a question that probably belongs on a users mailing list > but I could not find one. > > > > I get the following error when trying to use my IronRuby windsor > registration script: > > * > System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel > * > > > > I assume this has something to do with the fact that newing up an object in > IronRuby isn''t the same thing as newing it up in C#. > > > > Any suggestions or guidance would be appreciated. > > > > Here is the important IronRuby code: > > > > require ''Castle.Windsor'' > > require ''Castle.MicroKernel'' > > require ''Castle.Core'' > > > > ComponentRegistration > Castle::MicroKernel::Registration::ComponentRegistration > > ComponentModel = Castle::Core::ComponentModel > > Parameter = Castle::MicroKernel::Registration::Parameter > > Component = Castle::MicroKernel::Registration::Component > > > > def component(options) > > throw :classIsRequired if !options.has_key?(:class) > > > > klass = options[:class].to_clr_type > > > > if options.has_key?(:service) > > service = options[:service].to_clr_type > > else > > service = klass > > end > > > > if options.has_key?(:name) > > name = options[:name] > > else > > name = klass.class.name.underscore.lowercase > > end > > > > model = ComponentModel.new(name, service, klass) > > > > if options.has_key?(:parameters) > > parameters = options[:parameters] > > parameters.each do |p| > > model.Parameters.Add(p.key, p.value) > > end > > end > > > > $container.Register(ComponentRegistration.new(model)) > > end > > > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/1caae6e5/attachment-0001.html>
You can try using the LoadAssembly method on the runtime object runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); that should require the assembly a little nicer I think you can also use load_assembly ''Castle.Windsor'' http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 2009/3/18 Nathan Stott <nrstott at gmail.com>> I''m using the hosting API. > This is the entire method: > public void Load(IWindsorContainer container, TextReader reader) > { > var runtime = Ruby.CreateRuntime(); > ScriptEngine engine = Ruby.GetEngine(runtime); > var ctx = Ruby.GetExecutionContext(runtime); > ctx.DefineReadOnlyGlobalVariable("container", container); > > string header > @"require ''Castle.Windsor'' > require ''Castle.MicroKernel'' > require ''Castle.Core'' > > ComponentRegistration > Castle::MicroKernel::Registration::ComponentRegistration > ComponentModel = Castle::Core::ComponentModel > Parameter = Castle::MicroKernel::Registration::Parameter > Component = Castle::MicroKernel::Registration::Component > > def component(options) > throw :classIsRequired if !options.has_key?(:class) > klass = options[:class].to_clr_type > if options.has_key?(:service) > service = options[:service].to_clr_type > else > service = klass > end > if options.has_key?(:name) > name = options[:name] > else > name = klass.class.name.underscore.lowercase > end > model = ComponentModel.new(name, service, klass) > if options.has_key?(:parameters) > parameters = options[:parameters] > parameters.each do |p| > model.Parameters.Add(p.key, p.value) > end > end > $container.Register(ComponentRegistration.new(model)) > end"; > > ScriptSource headerSource = engine.CreateScriptSourceFromString(header); > headerSource.Execute(); > > string containerScript = reader.ReadToEnd(); > ScriptSource source > engine.CreateScriptSourceFromString(containerScript); > source.Execute(); > } > } > > 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com> > >> How do you run this script? From command line (ir.exe script.rb) or do >> you use hosting API? >> >> >> >> Tomas >> >> >> >> *From:* ironruby-core-bounces at rubyforge.org [mailto: >> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott >> *Sent:* Wednesday, March 18, 2009 8:33 AM >> *To:* ironruby-core at rubyforge.org >> *Subject:* [Ironruby-core] problem >> >> >> >> Hi all. I have a question that probably belongs on a users mailing list >> but I could not find one. >> >> >> >> I get the following error when trying to use my IronRuby windsor >> registration script: >> >> * >> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >> * >> >> >> >> I assume this has something to do with the fact that newing up an object >> in IronRuby isn''t the same thing as newing it up in C#. >> >> >> >> Any suggestions or guidance would be appreciated. >> >> >> >> Here is the important IronRuby code: >> >> >> >> require ''Castle.Windsor'' >> >> require ''Castle.MicroKernel'' >> >> require ''Castle.Core'' >> >> >> >> ComponentRegistration >> Castle::MicroKernel::Registration::ComponentRegistration >> >> ComponentModel = Castle::Core::ComponentModel >> >> Parameter = Castle::MicroKernel::Registration::Parameter >> >> Component = Castle::MicroKernel::Registration::Component >> >> >> >> def component(options) >> >> throw :classIsRequired if !options.has_key?(:class) >> >> >> >> klass = options[:class].to_clr_type >> >> >> >> if options.has_key?(:service) >> >> service = options[:service].to_clr_type >> >> else >> >> service = klass >> >> end >> >> >> >> if options.has_key?(:name) >> >> name = options[:name] >> >> else >> >> name = klass.class.name.underscore.lowercase >> >> end >> >> >> >> model = ComponentModel.new(name, service, klass) >> >> >> >> if options.has_key?(:parameters) >> >> parameters = options[:parameters] >> >> parameters.each do |p| >> >> model.Parameters.Add(p.key, p.value) >> >> end >> >> end >> >> >> >> $container.Register(ComponentRegistration.new(model)) >> >> end >> >> >> >> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/bb61a96e/attachment.html>
I tried that and no luck. It doesn''t seem that the assembly is not being loaded properly. I''m able to use methods on the objects fine in the script. However, it is that last call to the $container.Register(ComponentRegistration.new(model)) where for some reason it won''t work. ComponentRegistration.new() takes a ComponentModel. The error seems to indicate that it is receiving a ComponentModel even with the same namespace prefixes but somehow it''s not able to use it. 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz>> You can try using the LoadAssembly method on the runtime object > > runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); > > that should require the assembly a little nicer > > I think you can also use load_assembly ''Castle.Windsor'' > > > http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 > > http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 > > http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 > > > > 2009/3/18 Nathan Stott <nrstott at gmail.com> > > I''m using the hosting API. >> This is the entire method: >> public void Load(IWindsorContainer container, TextReader reader) >> { >> var runtime = Ruby.CreateRuntime(); >> ScriptEngine engine = Ruby.GetEngine(runtime); >> var ctx = Ruby.GetExecutionContext(runtime); >> ctx.DefineReadOnlyGlobalVariable("container", container); >> >> string header >> @"require ''Castle.Windsor'' >> require ''Castle.MicroKernel'' >> require ''Castle.Core'' >> >> ComponentRegistration >> Castle::MicroKernel::Registration::ComponentRegistration >> ComponentModel = Castle::Core::ComponentModel >> Parameter = Castle::MicroKernel::Registration::Parameter >> Component = Castle::MicroKernel::Registration::Component >> >> def component(options) >> throw :classIsRequired if !options.has_key?(:class) >> klass = options[:class].to_clr_type >> if options.has_key?(:service) >> service = options[:service].to_clr_type >> else >> service = klass >> end >> if options.has_key?(:name) >> name = options[:name] >> else >> name = klass.class.name.underscore.lowercase >> end >> model = ComponentModel.new(name, service, klass) >> if options.has_key?(:parameters) >> parameters = options[:parameters] >> parameters.each do |p| >> model.Parameters.Add(p.key, p.value) >> end >> end >> $container.Register(ComponentRegistration.new(model)) >> end"; >> >> ScriptSource headerSource = engine.CreateScriptSourceFromString(header); >> headerSource.Execute(); >> >> string containerScript = reader.ReadToEnd(); >> ScriptSource source >> engine.CreateScriptSourceFromString(containerScript); >> source.Execute(); >> } >> } >> >> 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com> >> >>> How do you run this script? From command line (ir.exe script.rb) or do >>> you use hosting API? >>> >>> >>> >>> Tomas >>> >>> >>> >>> *From:* ironruby-core-bounces at rubyforge.org [mailto: >>> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott >>> *Sent:* Wednesday, March 18, 2009 8:33 AM >>> *To:* ironruby-core at rubyforge.org >>> *Subject:* [Ironruby-core] problem >>> >>> >>> >>> Hi all. I have a question that probably belongs on a users mailing list >>> but I could not find one. >>> >>> >>> >>> I get the following error when trying to use my IronRuby windsor >>> registration script: >>> >>> * >>> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >>> * >>> >>> >>> >>> I assume this has something to do with the fact that newing up an object >>> in IronRuby isn''t the same thing as newing it up in C#. >>> >>> >>> >>> Any suggestions or guidance would be appreciated. >>> >>> >>> >>> Here is the important IronRuby code: >>> >>> >>> >>> require ''Castle.Windsor'' >>> >>> require ''Castle.MicroKernel'' >>> >>> require ''Castle.Core'' >>> >>> >>> >>> ComponentRegistration >>> Castle::MicroKernel::Registration::ComponentRegistration >>> >>> ComponentModel = Castle::Core::ComponentModel >>> >>> Parameter = Castle::MicroKernel::Registration::Parameter >>> >>> Component = Castle::MicroKernel::Registration::Component >>> >>> >>> >>> def component(options) >>> >>> throw :classIsRequired if !options.has_key?(:class) >>> >>> >>> >>> klass = options[:class].to_clr_type >>> >>> >>> >>> if options.has_key?(:service) >>> >>> service = options[:service].to_clr_type >>> >>> else >>> >>> service = klass >>> >>> end >>> >>> >>> >>> if options.has_key?(:name) >>> >>> name = options[:name] >>> >>> else >>> >>> name = klass.class.name.underscore.lowercase >>> >>> end >>> >>> >>> >>> model = ComponentModel.new(name, service, klass) >>> >>> >>> >>> if options.has_key?(:parameters) >>> >>> parameters = options[:parameters] >>> >>> parameters.each do |p| >>> >>> model.Parameters.Add(p.key, p.value) >>> >>> end >>> >>> end >>> >>> >>> >>> $container.Register(ComponentRegistration.new(model)) >>> >>> end >>> >>> >>> >>> >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/f4b452ed/attachment-0001.html>
I dont know if this helps, but this is the full output of the test: ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent : Failed CT_INIT: Object UPDATED: Object CreateInstanceSingleton affected=1 rules=0 UPDATED: Object CreateInstanceSingleton affected=1 rules=0 CT_INIT: File::Constants CT_INIT: IO CT_INIT: File UPDATED: Object CreateInstanceSingleton affected=1 rules=0 MT_INIT: Kernel MT_INIT: Object MT_INIT: <anonymous> MT_INIT: Module MT_INIT: Class MT_INIT: <anonymous> UPDATED: Object CreateInstanceSingleton affected=5 rules=1 MT_INIT: <anonymous> LOADER: Loading assembly ''Motorpool.Calendar.Web.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' and type '''' MT_INIT: Symbol MT_INIT: Enumerable MT_INIT: Hash MT_INIT: Microsoft::Scripting::Actions::TypeTracker MT_INIT: Microsoft::Scripting::Actions::TypeGroup System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel at CallSite.Target(Closure , CallSite , RubyMethodScope , Object , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>(CallSite site, T0 arg0, T1 arg1, T2 arg2) in C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 at ??;component;;10;(Closure , Object , Proc , Object ) at CallSite.Target(Closure , CallSite , RubyScope , Object , Hash ) at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>(CallSite site, T0 arg0, T1 arg1, T2 arg2) in C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 at ??;#;;0;(Closure , Scope , LanguageContext ) at Microsoft.Scripting.Runtime.LegacyScriptCode.Run() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\LegacyScriptCode.cs: line 43 at Microsoft.Scripting.SourceUnit.Execute() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\SourceUnit.cs: line 239 at Microsoft.Scripting.Hosting.ScriptSource.Execute() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Hosting\ScriptSource.cs: line 138 at Motorpool.Calendar.Service.ComponentLoader.Load(IWindsorContainer container, TextReader reader) in ComponentLoader.cs: line 64<about:file%3A%2F%2F51192FB1-7EF2-4CAF-BAF3-3F0F7A10E911%2Ff%3AComponentLoader.cs%3Fline%3D64%26column%3D1> at Motorpool.Calendar.Web.Test.ComponentLoaderRegisteringComponentContext .ShouldRegisterComponent() in ComponentLoaderRegisteringComponentContext.cs: line 26<about:file%3A%2F%2F532B0F7A-5F7B-4C0E-AF76-4BC0CE12DB4F%2Ff%3AComponentLoaderRegisteringComponentContext.cs%3Fline%3D26%26column%3D1> On Wed, Mar 18, 2009 at 1:55 PM, Nathan Stott <nrstott at gmail.com> wrote:> I tried that and no luck. > It doesn''t seem that the assembly is not being loaded properly. I''m able > to use methods on the objects fine in the script. However, it is that last > call to the $container.Register(ComponentRegistration.new(model)) where > for some reason it won''t work. > > ComponentRegistration.new() takes a ComponentModel. The error seems to > indicate that it is receiving a ComponentModel even with the same namespace > prefixes but somehow it''s not able to use it. > > 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz> > > You can try using the LoadAssembly method on the runtime object >> >> runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); >> >> that should require the assembly a little nicer >> >> I think you can also use load_assembly ''Castle.Windsor'' >> >> >> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 >> >> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 >> >> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 >> >> >> >> 2009/3/18 Nathan Stott <nrstott at gmail.com> >> >> I''m using the hosting API. >>> This is the entire method: >>> public void Load(IWindsorContainer container, TextReader reader) >>> { >>> var runtime = Ruby.CreateRuntime(); >>> ScriptEngine engine = Ruby.GetEngine(runtime); >>> var ctx = Ruby.GetExecutionContext(runtime); >>> ctx.DefineReadOnlyGlobalVariable("container", container); >>> >>> string header >>> @"require ''Castle.Windsor'' >>> require ''Castle.MicroKernel'' >>> require ''Castle.Core'' >>> >>> ComponentRegistration >>> Castle::MicroKernel::Registration::ComponentRegistration >>> ComponentModel = Castle::Core::ComponentModel >>> Parameter = Castle::MicroKernel::Registration::Parameter >>> Component = Castle::MicroKernel::Registration::Component >>> >>> def component(options) >>> throw :classIsRequired if !options.has_key?(:class) >>> klass = options[:class].to_clr_type >>> if options.has_key?(:service) >>> service = options[:service].to_clr_type >>> else >>> service = klass >>> end >>> if options.has_key?(:name) >>> name = options[:name] >>> else >>> name = klass.class.name.underscore.lowercase >>> end >>> model = ComponentModel.new(name, service, klass) >>> if options.has_key?(:parameters) >>> parameters = options[:parameters] >>> parameters.each do |p| >>> model.Parameters.Add(p.key, p.value) >>> end >>> end >>> $container.Register(ComponentRegistration.new(model)) >>> end"; >>> >>> ScriptSource headerSource = engine.CreateScriptSourceFromString(header); >>> headerSource.Execute(); >>> >>> string containerScript = reader.ReadToEnd(); >>> ScriptSource source >>> engine.CreateScriptSourceFromString(containerScript); >>> source.Execute(); >>> } >>> } >>> >>> 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com> >>> >>>> How do you run this script? From command line (ir.exe script.rb) or do >>>> you use hosting API? >>>> >>>> >>>> >>>> Tomas >>>> >>>> >>>> >>>> *From:* ironruby-core-bounces at rubyforge.org [mailto: >>>> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott >>>> *Sent:* Wednesday, March 18, 2009 8:33 AM >>>> *To:* ironruby-core at rubyforge.org >>>> *Subject:* [Ironruby-core] problem >>>> >>>> >>>> >>>> Hi all. I have a question that probably belongs on a users mailing list >>>> but I could not find one. >>>> >>>> >>>> >>>> I get the following error when trying to use my IronRuby windsor >>>> registration script: >>>> >>>> * >>>> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >>>> * >>>> >>>> >>>> >>>> I assume this has something to do with the fact that newing up an object >>>> in IronRuby isn''t the same thing as newing it up in C#. >>>> >>>> >>>> >>>> Any suggestions or guidance would be appreciated. >>>> >>>> >>>> >>>> Here is the important IronRuby code: >>>> >>>> >>>> >>>> require ''Castle.Windsor'' >>>> >>>> require ''Castle.MicroKernel'' >>>> >>>> require ''Castle.Core'' >>>> >>>> >>>> >>>> ComponentRegistration >>>> Castle::MicroKernel::Registration::ComponentRegistration >>>> >>>> ComponentModel = Castle::Core::ComponentModel >>>> >>>> Parameter = Castle::MicroKernel::Registration::Parameter >>>> >>>> Component = Castle::MicroKernel::Registration::Component >>>> >>>> >>>> >>>> def component(options) >>>> >>>> throw :classIsRequired if !options.has_key?(:class) >>>> >>>> >>>> >>>> klass = options[:class].to_clr_type >>>> >>>> >>>> >>>> if options.has_key?(:service) >>>> >>>> service = options[:service].to_clr_type >>>> >>>> else >>>> >>>> service = klass >>>> >>>> end >>>> >>>> >>>> >>>> if options.has_key?(:name) >>>> >>>> name = options[:name] >>>> >>>> else >>>> >>>> name = klass.class.name.underscore.lowercase >>>> >>>> end >>>> >>>> >>>> >>>> model = ComponentModel.new(name, service, klass) >>>> >>>> >>>> >>>> if options.has_key?(:parameters) >>>> >>>> parameters = options[:parameters] >>>> >>>> parameters.each do |p| >>>> >>>> model.Parameters.Add(p.key, >>>> p.value) >>>> >>>> end >>>> >>>> end >>>> >>>> >>>> >>>> $container.Register(ComponentRegistration.new(model)) >>>> >>>> end >>>> >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> Ironruby-core mailing list >>>> Ironruby-core at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/ironruby-core >>>> >>>> >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/d4d1e883/attachment-0001.html>
Are you using resharper for your unit tests? 2009/3/18 Nathan Stott <nrstott at gmail.com>> I dont know if this helps, but this is the full output of the test: > > ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent : Failed > CT_INIT: Object > > UPDATED: Object CreateInstanceSingleton affected=1 rules=0 > > UPDATED: Object CreateInstanceSingleton affected=1 rules=0 > CT_INIT: File::Constants > CT_INIT: IO > CT_INIT: File > > UPDATED: Object CreateInstanceSingleton affected=1 rules=0 > MT_INIT: Kernel > MT_INIT: Object > MT_INIT: <anonymous> > MT_INIT: Module > MT_INIT: Class > MT_INIT: <anonymous> > > UPDATED: Object CreateInstanceSingleton affected=5 rules=1 > MT_INIT: <anonymous> > > LOADER: Loading assembly ''Motorpool.Calendar.Web.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' and type '''' > MT_INIT: Symbol > MT_INIT: Enumerable > MT_INIT: Hash > MT_INIT: Microsoft::Scripting::Actions::TypeTracker > MT_INIT: Microsoft::Scripting::Actions::TypeGroup > > System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel > at CallSite.Target(Closure , CallSite , RubyMethodScope , Object , Object ) > at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( > CallSite site, T0 arg0, T1 arg1, T2 arg2) in > C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 > at ??;component;;10;(Closure , Object , Proc , Object ) > at CallSite.Target(Closure , CallSite , RubyScope , Object , Hash ) > at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( > CallSite site, T0 arg0, T1 arg1, T2 arg2) in > C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 > at ??;#;;0;(Closure , Scope , LanguageContext ) > at Microsoft.Scripting.Runtime.LegacyScriptCode.Run() in > C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\LegacyScriptCode.cs: line 43 > at Microsoft.Scripting.SourceUnit.Execute() in > C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\SourceUnit.cs: line 239 > at Microsoft.Scripting.Hosting.ScriptSource.Execute() in > C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Hosting\ScriptSource.cs: line 138 > at Motorpool.Calendar.Service.ComponentLoader.Load(IWindsorContainer > container, TextReader reader) in ComponentLoader.cs: line 64 > at Motorpool.Calendar.Web.Test.ComponentLoaderRegisteringComponentContext > .ShouldRegisterComponent() in > ComponentLoaderRegisteringComponentContext.cs: line 26 > > On Wed, Mar 18, 2009 at 1:55 PM, Nathan Stott <nrstott at gmail.com> wrote: > >> I tried that and no luck. >> It doesn''t seem that the assembly is not being loaded properly. I''m able >> to use methods on the objects fine in the script. However, it is that last >> call to the $container.Register(ComponentRegistration.new(model)) where >> for some reason it won''t work. >> >> ComponentRegistration.new() takes a ComponentModel. The error seems to >> indicate that it is receiving a ComponentModel even with the same namespace >> prefixes but somehow it''s not able to use it. >> >> 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz> >> >> You can try using the LoadAssembly method on the runtime object >>> >>> runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); >>> >>> that should require the assembly a little nicer >>> >>> I think you can also use load_assembly ''Castle.Windsor'' >>> >>> >>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 >>> >>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 >>> >>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 >>> >>> >>> >>> 2009/3/18 Nathan Stott <nrstott at gmail.com> >>> >>> I''m using the hosting API. >>>> This is the entire method: >>>> public void Load(IWindsorContainer container, TextReader reader) >>>> { >>>> var runtime = Ruby.CreateRuntime(); >>>> ScriptEngine engine = Ruby.GetEngine(runtime); >>>> var ctx = Ruby.GetExecutionContext(runtime); >>>> ctx.DefineReadOnlyGlobalVariable("container", container); >>>> >>>> string header >>>> @"require ''Castle.Windsor'' >>>> require ''Castle.MicroKernel'' >>>> require ''Castle.Core'' >>>> >>>> ComponentRegistration >>>> Castle::MicroKernel::Registration::ComponentRegistration >>>> ComponentModel = Castle::Core::ComponentModel >>>> Parameter = Castle::MicroKernel::Registration::Parameter >>>> Component = Castle::MicroKernel::Registration::Component >>>> >>>> def component(options) >>>> throw :classIsRequired if !options.has_key?(:class) >>>> klass = options[:class].to_clr_type >>>> if options.has_key?(:service) >>>> service = options[:service].to_clr_type >>>> else >>>> service = klass >>>> end >>>> if options.has_key?(:name) >>>> name = options[:name] >>>> else >>>> name = klass.class.name.underscore.lowercase >>>> end >>>> model = ComponentModel.new(name, service, klass) >>>> if options.has_key?(:parameters) >>>> parameters = options[:parameters] >>>> parameters.each do |p| >>>> model.Parameters.Add(p.key, p.value) >>>> end >>>> end >>>> $container.Register(ComponentRegistration.new(model)) >>>> end"; >>>> >>>> ScriptSource headerSource = engine.CreateScriptSourceFromString(header); >>>> headerSource.Execute(); >>>> >>>> string containerScript = reader.ReadToEnd(); >>>> ScriptSource source >>>> engine.CreateScriptSourceFromString(containerScript); >>>> source.Execute(); >>>> } >>>> } >>>> >>>> 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com> >>>> >>>>> How do you run this script? From command line (ir.exe script.rb) or >>>>> do you use hosting API? >>>>> >>>>> >>>>> >>>>> Tomas >>>>> >>>>> >>>>> >>>>> *From:* ironruby-core-bounces at rubyforge.org [mailto: >>>>> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott >>>>> *Sent:* Wednesday, March 18, 2009 8:33 AM >>>>> *To:* ironruby-core at rubyforge.org >>>>> *Subject:* [Ironruby-core] problem >>>>> >>>>> >>>>> >>>>> Hi all. I have a question that probably belongs on a users mailing >>>>> list but I could not find one. >>>>> >>>>> >>>>> >>>>> I get the following error when trying to use my IronRuby windsor >>>>> registration script: >>>>> >>>>> * >>>>> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >>>>> * >>>>> >>>>> >>>>> >>>>> I assume this has something to do with the fact that newing up an >>>>> object in IronRuby isn''t the same thing as newing it up in C#. >>>>> >>>>> >>>>> >>>>> Any suggestions or guidance would be appreciated. >>>>> >>>>> >>>>> >>>>> Here is the important IronRuby code: >>>>> >>>>> >>>>> >>>>> require ''Castle.Windsor'' >>>>> >>>>> require ''Castle.MicroKernel'' >>>>> >>>>> require ''Castle.Core'' >>>>> >>>>> >>>>> >>>>> ComponentRegistration >>>>> Castle::MicroKernel::Registration::ComponentRegistration >>>>> >>>>> ComponentModel = Castle::Core::ComponentModel >>>>> >>>>> Parameter = Castle::MicroKernel::Registration::Parameter >>>>> >>>>> Component = Castle::MicroKernel::Registration::Component >>>>> >>>>> >>>>> >>>>> def component(options) >>>>> >>>>> throw :classIsRequired if !options.has_key?(:class) >>>>> >>>>> >>>>> >>>>> klass = options[:class].to_clr_type >>>>> >>>>> >>>>> >>>>> if options.has_key?(:service) >>>>> >>>>> service = options[:service].to_clr_type >>>>> >>>>> else >>>>> >>>>> service = klass >>>>> >>>>> end >>>>> >>>>> >>>>> >>>>> if options.has_key?(:name) >>>>> >>>>> name = options[:name] >>>>> >>>>> else >>>>> >>>>> name = klass.class.name.underscore.lowercase >>>>> >>>>> end >>>>> >>>>> >>>>> >>>>> model = ComponentModel.new(name, service, klass) >>>>> >>>>> >>>>> >>>>> if options.has_key?(:parameters) >>>>> >>>>> parameters = options[:parameters] >>>>> >>>>> parameters.each do |p| >>>>> >>>>> model.Parameters.Add(p.key, >>>>> p.value) >>>>> >>>>> end >>>>> >>>>> end >>>>> >>>>> >>>>> >>>>> $container.Register(ComponentRegistration.new(model)) >>>>> >>>>> end >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> Ironruby-core mailing list >>>>> Ironruby-core at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/ironruby-core >>>>> >>>>> >>>> >>>> _______________________________________________ >>>> Ironruby-core mailing list >>>> Ironruby-core at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/ironruby-core >>>> >>>> >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >> > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/d5be8779/attachment-0001.html>
If so turn off shadow copy assemblies under Resharper -> options -> unit testing On Wed, Mar 18, 2009 at 8:22 PM, Ivan Porto Carrero <ivan at flanders.co.nz>wrote:> Are you using resharper for your unit tests? > > > > 2009/3/18 Nathan Stott <nrstott at gmail.com> > >> I dont know if this helps, but this is the full output of the test: >> >> ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent : >> Failed CT_INIT: Object >> >> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >> >> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >> CT_INIT: File::Constants >> CT_INIT: IO >> CT_INIT: File >> >> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >> MT_INIT: Kernel >> MT_INIT: Object >> MT_INIT: <anonymous> >> MT_INIT: Module >> MT_INIT: Class >> MT_INIT: <anonymous> >> >> UPDATED: Object CreateInstanceSingleton affected=5 rules=1 >> MT_INIT: <anonymous> >> >> LOADER: Loading assembly ''Motorpool.Calendar.Web.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' and type '''' >> MT_INIT: Symbol >> MT_INIT: Enumerable >> MT_INIT: Hash >> MT_INIT: Microsoft::Scripting::Actions::TypeTracker >> MT_INIT: Microsoft::Scripting::Actions::TypeGroup >> >> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >> at CallSite.Target(Closure , CallSite , RubyMethodScope , Object , Object >> ) >> at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( >> CallSite site, T0 arg0, T1 arg1, T2 arg2) in >> C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 >> at ??;component;;10;(Closure , Object , Proc , Object ) >> at CallSite.Target(Closure , CallSite , RubyScope , Object , Hash ) >> at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( >> CallSite site, T0 arg0, T1 arg1, T2 arg2) in >> C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 >> at ??;#;;0;(Closure , Scope , LanguageContext ) >> at Microsoft.Scripting.Runtime.LegacyScriptCode.Run() in >> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\LegacyScriptCode.cs: line 43 >> at Microsoft.Scripting.SourceUnit.Execute() in >> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\SourceUnit.cs: line 239 >> at Microsoft.Scripting.Hosting.ScriptSource.Execute() in >> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Hosting\ScriptSource.cs: line 138 >> at Motorpool.Calendar.Service.ComponentLoader.Load(IWindsorContainer >> container, TextReader reader) in ComponentLoader.cs: line 64 >> at Motorpool.Calendar.Web.Test.ComponentLoaderRegisteringComponentContext >> .ShouldRegisterComponent() in >> ComponentLoaderRegisteringComponentContext.cs: line 26 >> >> On Wed, Mar 18, 2009 at 1:55 PM, Nathan Stott <nrstott at gmail.com> wrote: >> >>> I tried that and no luck. >>> It doesn''t seem that the assembly is not being loaded properly. I''m able >>> to use methods on the objects fine in the script. However, it is that last >>> call to the $container.Register(ComponentRegistration.new(model)) where >>> for some reason it won''t work. >>> >>> ComponentRegistration.new() takes a ComponentModel. The error seems to >>> indicate that it is receiving a ComponentModel even with the same namespace >>> prefixes but somehow it''s not able to use it. >>> >>> 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz> >>> >>> You can try using the LoadAssembly method on the runtime object >>>> >>>> runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); >>>> >>>> that should require the assembly a little nicer >>>> >>>> I think you can also use load_assembly ''Castle.Windsor'' >>>> >>>> >>>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 >>>> >>>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 >>>> >>>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 >>>> >>>> >>>> >>>> 2009/3/18 Nathan Stott <nrstott at gmail.com> >>>> >>>> I''m using the hosting API. >>>>> This is the entire method: >>>>> public void Load(IWindsorContainer container, TextReader reader) >>>>> { >>>>> var runtime = Ruby.CreateRuntime(); >>>>> ScriptEngine engine = Ruby.GetEngine(runtime); >>>>> var ctx = Ruby.GetExecutionContext(runtime); >>>>> ctx.DefineReadOnlyGlobalVariable("container", container); >>>>> >>>>> string header >>>>> @"require ''Castle.Windsor'' >>>>> require ''Castle.MicroKernel'' >>>>> require ''Castle.Core'' >>>>> >>>>> ComponentRegistration >>>>> Castle::MicroKernel::Registration::ComponentRegistration >>>>> ComponentModel = Castle::Core::ComponentModel >>>>> Parameter = Castle::MicroKernel::Registration::Parameter >>>>> Component = Castle::MicroKernel::Registration::Component >>>>> >>>>> def component(options) >>>>> throw :classIsRequired if !options.has_key?(:class) >>>>> klass = options[:class].to_clr_type >>>>> if options.has_key?(:service) >>>>> service = options[:service].to_clr_type >>>>> else >>>>> service = klass >>>>> end >>>>> if options.has_key?(:name) >>>>> name = options[:name] >>>>> else >>>>> name = klass.class.name.underscore.lowercase >>>>> end >>>>> model = ComponentModel.new(name, service, klass) >>>>> if options.has_key?(:parameters) >>>>> parameters = options[:parameters] >>>>> parameters.each do |p| >>>>> model.Parameters.Add(p.key, p.value) >>>>> end >>>>> end >>>>> $container.Register(ComponentRegistration.new(model)) >>>>> end"; >>>>> >>>>> ScriptSource headerSource >>>>> engine.CreateScriptSourceFromString(header); >>>>> headerSource.Execute(); >>>>> >>>>> string containerScript = reader.ReadToEnd(); >>>>> ScriptSource source >>>>> engine.CreateScriptSourceFromString(containerScript); >>>>> source.Execute(); >>>>> } >>>>> } >>>>> >>>>> 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com> >>>>> >>>>>> How do you run this script? From command line (ir.exe script.rb) or >>>>>> do you use hosting API? >>>>>> >>>>>> >>>>>> >>>>>> Tomas >>>>>> >>>>>> >>>>>> >>>>>> *From:* ironruby-core-bounces at rubyforge.org [mailto: >>>>>> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott >>>>>> *Sent:* Wednesday, March 18, 2009 8:33 AM >>>>>> *To:* ironruby-core at rubyforge.org >>>>>> *Subject:* [Ironruby-core] problem >>>>>> >>>>>> >>>>>> >>>>>> Hi all. I have a question that probably belongs on a users mailing >>>>>> list but I could not find one. >>>>>> >>>>>> >>>>>> >>>>>> I get the following error when trying to use my IronRuby windsor >>>>>> registration script: >>>>>> >>>>>> * >>>>>> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >>>>>> * >>>>>> >>>>>> >>>>>> >>>>>> I assume this has something to do with the fact that newing up an >>>>>> object in IronRuby isn''t the same thing as newing it up in C#. >>>>>> >>>>>> >>>>>> >>>>>> Any suggestions or guidance would be appreciated. >>>>>> >>>>>> >>>>>> >>>>>> Here is the important IronRuby code: >>>>>> >>>>>> >>>>>> >>>>>> require ''Castle.Windsor'' >>>>>> >>>>>> require ''Castle.MicroKernel'' >>>>>> >>>>>> require ''Castle.Core'' >>>>>> >>>>>> >>>>>> >>>>>> ComponentRegistration >>>>>> Castle::MicroKernel::Registration::ComponentRegistration >>>>>> >>>>>> ComponentModel = Castle::Core::ComponentModel >>>>>> >>>>>> Parameter = Castle::MicroKernel::Registration::Parameter >>>>>> >>>>>> Component = Castle::MicroKernel::Registration::Component >>>>>> >>>>>> >>>>>> >>>>>> def component(options) >>>>>> >>>>>> throw :classIsRequired if !options.has_key?(:class) >>>>>> >>>>>> >>>>>> >>>>>> klass = options[:class].to_clr_type >>>>>> >>>>>> >>>>>> >>>>>> if options.has_key?(:service) >>>>>> >>>>>> service = options[:service].to_clr_type >>>>>> >>>>>> else >>>>>> >>>>>> service = klass >>>>>> >>>>>> end >>>>>> >>>>>> >>>>>> >>>>>> if options.has_key?(:name) >>>>>> >>>>>> name = options[:name] >>>>>> >>>>>> else >>>>>> >>>>>> name = klass.class.name.underscore.lowercase >>>>>> >>>>>> end >>>>>> >>>>>> >>>>>> >>>>>> model = ComponentModel.new(name, service, klass) >>>>>> >>>>>> >>>>>> >>>>>> if options.has_key?(:parameters) >>>>>> >>>>>> parameters = options[:parameters] >>>>>> >>>>>> parameters.each do |p| >>>>>> >>>>>> model.Parameters.Add(p.key, >>>>>> p.value) >>>>>> >>>>>> end >>>>>> >>>>>> end >>>>>> >>>>>> >>>>>> >>>>>> $container.Register(ComponentRegistration.new(model)) >>>>>> >>>>>> end >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Ironruby-core mailing list >>>>>> Ironruby-core at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/ironruby-core >>>>>> >>>>>> >>>>> >>>>> _______________________________________________ >>>>> Ironruby-core mailing list >>>>> Ironruby-core at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/ironruby-core >>>>> >>>>> >>>> >>>> _______________________________________________ >>>> Ironruby-core mailing list >>>> Ironruby-core at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/ironruby-core >>>> >>>> >>> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/e15d21dc/attachment-0001.html>
Good call Ivan. The LoadAssembly apparently was doing the trick! Thanks for the help. BTW, was this the right mailing list for this question? Is there a users mailing list? 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz>> If so turn off shadow copy assemblies under Resharper -> options -> unit > testing > > On Wed, Mar 18, 2009 at 8:22 PM, Ivan Porto Carrero <ivan at flanders.co.nz>wrote: > >> Are you using resharper for your unit tests? >> >> >> >> 2009/3/18 Nathan Stott <nrstott at gmail.com> >> >>> I dont know if this helps, but this is the full output of the test: >>> >>> ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent : >>> Failed CT_INIT: Object >>> >>> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >>> >>> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >>> CT_INIT: File::Constants >>> CT_INIT: IO >>> CT_INIT: File >>> >>> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >>> MT_INIT: Kernel >>> MT_INIT: Object >>> MT_INIT: <anonymous> >>> MT_INIT: Module >>> MT_INIT: Class >>> MT_INIT: <anonymous> >>> >>> UPDATED: Object CreateInstanceSingleton affected=5 rules=1 >>> MT_INIT: <anonymous> >>> >>> LOADER: Loading assembly ''Motorpool.Calendar.Web.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' and type '''' >>> MT_INIT: Symbol >>> MT_INIT: Enumerable >>> MT_INIT: Hash >>> MT_INIT: Microsoft::Scripting::Actions::TypeTracker >>> MT_INIT: Microsoft::Scripting::Actions::TypeGroup >>> >>> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >>> at CallSite.Target(Closure , CallSite , RubyMethodScope , Object , Object >>> ) >>> at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( >>> CallSite site, T0 arg0, T1 arg1, T2 arg2) in >>> C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 >>> at ??;component;;10;(Closure , Object , Proc , Object ) >>> at CallSite.Target(Closure , CallSite , RubyScope , Object , Hash ) >>> at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( >>> CallSite site, T0 arg0, T1 arg1, T2 arg2) in >>> C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 >>> at ??;#;;0;(Closure , Scope , LanguageContext ) >>> at Microsoft.Scripting.Runtime.LegacyScriptCode.Run() in >>> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\LegacyScriptCode.cs: line 43 >>> at Microsoft.Scripting.SourceUnit.Execute() in >>> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\SourceUnit.cs: line 239 >>> at Microsoft.Scripting.Hosting.ScriptSource.Execute() in >>> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Hosting\ScriptSource.cs: line 138 >>> at Motorpool.Calendar.Service.ComponentLoader.Load(IWindsorContainer >>> container, TextReader reader) in ComponentLoader.cs: line 64 >>> at Motorpool.Calendar.Web.Test >>> .ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent() in >>> ComponentLoaderRegisteringComponentContext.cs: line 26 >>> >>> On Wed, Mar 18, 2009 at 1:55 PM, Nathan Stott <nrstott at gmail.com> wrote: >>> >>>> I tried that and no luck. >>>> It doesn''t seem that the assembly is not being loaded properly. I''m >>>> able to use methods on the objects fine in the script. However, it is that >>>> last call to the $container.Register(ComponentRegistration.new(model)) >>>> where for some reason it won''t work. >>>> >>>> ComponentRegistration.new() takes a ComponentModel. The error seems to >>>> indicate that it is receiving a ComponentModel even with the same namespace >>>> prefixes but somehow it''s not able to use it. >>>> >>>> 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz> >>>> >>>> You can try using the LoadAssembly method on the runtime object >>>>> >>>>> runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); >>>>> >>>>> that should require the assembly a little nicer >>>>> >>>>> I think you can also use load_assembly ''Castle.Windsor'' >>>>> >>>>> >>>>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 >>>>> >>>>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 >>>>> >>>>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 >>>>> >>>>> >>>>> >>>>> 2009/3/18 Nathan Stott <nrstott at gmail.com> >>>>> >>>>> I''m using the hosting API. >>>>>> This is the entire method: >>>>>> public void Load(IWindsorContainer container, TextReader reader) >>>>>> { >>>>>> var runtime = Ruby.CreateRuntime(); >>>>>> ScriptEngine engine = Ruby.GetEngine(runtime); >>>>>> var ctx = Ruby.GetExecutionContext(runtime); >>>>>> ctx.DefineReadOnlyGlobalVariable("container", container); >>>>>> >>>>>> string header >>>>>> @"require ''Castle.Windsor'' >>>>>> require ''Castle.MicroKernel'' >>>>>> require ''Castle.Core'' >>>>>> >>>>>> ComponentRegistration >>>>>> Castle::MicroKernel::Registration::ComponentRegistration >>>>>> ComponentModel = Castle::Core::ComponentModel >>>>>> Parameter = Castle::MicroKernel::Registration::Parameter >>>>>> Component = Castle::MicroKernel::Registration::Component >>>>>> >>>>>> def component(options) >>>>>> throw :classIsRequired if !options.has_key?(:class) >>>>>> klass = options[:class].to_clr_type >>>>>> if options.has_key?(:service) >>>>>> service = options[:service].to_clr_type >>>>>> else >>>>>> service = klass >>>>>> end >>>>>> if options.has_key?(:name) >>>>>> name = options[:name] >>>>>> else >>>>>> name = klass.class.name.underscore.lowercase >>>>>> end >>>>>> model = ComponentModel.new(name, service, klass) >>>>>> if options.has_key?(:parameters) >>>>>> parameters = options[:parameters] >>>>>> parameters.each do |p| >>>>>> model.Parameters.Add(p.key, p.value) >>>>>> end >>>>>> end >>>>>> $container.Register(ComponentRegistration.new(model)) >>>>>> end"; >>>>>> >>>>>> ScriptSource headerSource >>>>>> engine.CreateScriptSourceFromString(header); >>>>>> headerSource.Execute(); >>>>>> >>>>>> string containerScript = reader.ReadToEnd(); >>>>>> ScriptSource source >>>>>> engine.CreateScriptSourceFromString(containerScript); >>>>>> source.Execute(); >>>>>> } >>>>>> } >>>>>> >>>>>> 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com> >>>>>> >>>>>>> How do you run this script? From command line (ir.exe script.rb) or >>>>>>> do you use hosting API? >>>>>>> >>>>>>> >>>>>>> >>>>>>> Tomas >>>>>>> >>>>>>> >>>>>>> >>>>>>> *From:* ironruby-core-bounces at rubyforge.org [mailto: >>>>>>> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott >>>>>>> *Sent:* Wednesday, March 18, 2009 8:33 AM >>>>>>> *To:* ironruby-core at rubyforge.org >>>>>>> *Subject:* [Ironruby-core] problem >>>>>>> >>>>>>> >>>>>>> >>>>>>> Hi all. I have a question that probably belongs on a users mailing >>>>>>> list but I could not find one. >>>>>>> >>>>>>> >>>>>>> >>>>>>> I get the following error when trying to use my IronRuby windsor >>>>>>> registration script: >>>>>>> >>>>>>> * >>>>>>> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >>>>>>> * >>>>>>> >>>>>>> >>>>>>> >>>>>>> I assume this has something to do with the fact that newing up an >>>>>>> object in IronRuby isn''t the same thing as newing it up in C#. >>>>>>> >>>>>>> >>>>>>> >>>>>>> Any suggestions or guidance would be appreciated. >>>>>>> >>>>>>> >>>>>>> >>>>>>> Here is the important IronRuby code: >>>>>>> >>>>>>> >>>>>>> >>>>>>> require ''Castle.Windsor'' >>>>>>> >>>>>>> require ''Castle.MicroKernel'' >>>>>>> >>>>>>> require ''Castle.Core'' >>>>>>> >>>>>>> >>>>>>> >>>>>>> ComponentRegistration >>>>>>> Castle::MicroKernel::Registration::ComponentRegistration >>>>>>> >>>>>>> ComponentModel = Castle::Core::ComponentModel >>>>>>> >>>>>>> Parameter = Castle::MicroKernel::Registration::Parameter >>>>>>> >>>>>>> Component = Castle::MicroKernel::Registration::Component >>>>>>> >>>>>>> >>>>>>> >>>>>>> def component(options) >>>>>>> >>>>>>> throw :classIsRequired if !options.has_key?(:class) >>>>>>> >>>>>>> >>>>>>> >>>>>>> klass = options[:class].to_clr_type >>>>>>> >>>>>>> >>>>>>> >>>>>>> if options.has_key?(:service) >>>>>>> >>>>>>> service = options[:service].to_clr_type >>>>>>> >>>>>>> else >>>>>>> >>>>>>> service = klass >>>>>>> >>>>>>> end >>>>>>> >>>>>>> >>>>>>> >>>>>>> if options.has_key?(:name) >>>>>>> >>>>>>> name = options[:name] >>>>>>> >>>>>>> else >>>>>>> >>>>>>> name = klass.class.name.underscore.lowercase >>>>>>> >>>>>>> end >>>>>>> >>>>>>> >>>>>>> >>>>>>> model = ComponentModel.new(name, service, klass) >>>>>>> >>>>>>> >>>>>>> >>>>>>> if options.has_key?(:parameters) >>>>>>> >>>>>>> parameters = options[:parameters] >>>>>>> >>>>>>> parameters.each do |p| >>>>>>> >>>>>>> model.Parameters.Add(p.key, >>>>>>> p.value) >>>>>>> >>>>>>> end >>>>>>> >>>>>>> end >>>>>>> >>>>>>> >>>>>>> >>>>>>> $container.Register(ComponentRegistration.new(model)) >>>>>>> >>>>>>> end >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Ironruby-core mailing list >>>>>>> Ironruby-core at rubyforge.org >>>>>>> http://rubyforge.org/mailman/listinfo/ironruby-core >>>>>>> >>>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Ironruby-core mailing list >>>>>> Ironruby-core at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/ironruby-core >>>>>> >>>>>> >>>>> >>>>> _______________________________________________ >>>>> Ironruby-core mailing list >>>>> Ironruby-core at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/ironruby-core >>>>> >>>>> >>>> >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >> > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/b4abb887/attachment-0001.html>
The assembly seems to be loaded twice into 2 different loader contexts. ?require? with a simple name (as opposed to strong name ?Assembly, Version=?, Culture=?, PublicKeyToken=?? or Kernel#load_assembly) uses Assembly.LoadFrom to load the assembly. If you have a reference to the assembly in your C# host that loads it using Assembly.Load, which loads to a different context. So you might end up loading the assembly (and types that are defined there) twice. The runtime then as two different Type objects for a single logical type. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Ivan Porto Carrero Sent: Wednesday, March 18, 2009 12:23 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] problem Are you using resharper for your unit tests? 2009/3/18 Nathan Stott <nrstott at gmail.com<mailto:nrstott at gmail.com>> I dont know if this helps, but this is the full output of the test: ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent : Failed CT_INIT: Object UPDATED: Object CreateInstanceSingleton affected=1 rules=0 UPDATED: Object CreateInstanceSingleton affected=1 rules=0 CT_INIT: File::Constants CT_INIT: IO CT_INIT: File UPDATED: Object CreateInstanceSingleton affected=1 rules=0 MT_INIT: Kernel MT_INIT: Object MT_INIT: <anonymous> MT_INIT: Module MT_INIT: Class MT_INIT: <anonymous> UPDATED: Object CreateInstanceSingleton affected=5 rules=1 MT_INIT: <anonymous> LOADER: Loading assembly ''Motorpool.Calendar.Web.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' and type '''' MT_INIT: Symbol MT_INIT: Enumerable MT_INIT: Hash MT_INIT: Microsoft::Scripting::Actions::TypeTracker MT_INIT: Microsoft::Scripting::Actions::TypeGroup System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel at CallSite.Target(Closure , CallSite , RubyMethodScope , Object , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>(CallSite site, T0 arg0, T1 arg1, T2 arg2) in C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 at ??;component;;10;(Closure , Object , Proc , Object ) at CallSite.Target(Closure , CallSite , RubyScope , Object , Hash ) at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>(CallSite site, T0 arg0, T1 arg1, T2 arg2) in C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 at ??;#;;0;(Closure , Scope , LanguageContext ) at Microsoft.Scripting.Runtime.LegacyScriptCode.Run() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\LegacyScriptCode.cs: line 43 at Microsoft.Scripting.SourceUnit.Execute() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\SourceUnit.cs: line 239 at Microsoft.Scripting.Hosting.ScriptSource.Execute() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Hosting\ScriptSource.cs: line 138 at Motorpool.Calendar.Service.ComponentLoader.Load(IWindsorContainer container, TextReader reader) in ComponentLoader.cs: line 64 at Motorpool.Calendar.Web.Test.ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent() in ComponentLoaderRegisteringComponentContext.cs: line 26 On Wed, Mar 18, 2009 at 1:55 PM, Nathan Stott <nrstott at gmail.com<mailto:nrstott at gmail.com>> wrote: I tried that and no luck. It doesn''t seem that the assembly is not being loaded properly. I''m able to use methods on the objects fine in the script. However, it is that last call to the $container.Register(ComponentRegistration.new(model)) where for some reason it won''t work. ComponentRegistration.new() takes a ComponentModel. The error seems to indicate that it is receiving a ComponentModel even with the same namespace prefixes but somehow it''s not able to use it. 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz<mailto:ivan at flanders.co.nz>> You can try using the LoadAssembly method on the runtime object runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); that should require the assembly a little nicer I think you can also use load_assembly ''Castle.Windsor'' http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 2009/3/18 Nathan Stott <nrstott at gmail.com<mailto:nrstott at gmail.com>> I''m using the hosting API. This is the entire method: public void Load(IWindsorContainer container, TextReader reader) { var runtime = Ruby.CreateRuntime(); ScriptEngine engine = Ruby.GetEngine(runtime); var ctx = Ruby.GetExecutionContext(runtime); ctx.DefineReadOnlyGlobalVariable("container", container); string header @"require ''Castle.Windsor'' require ''Castle.MicroKernel'' require ''Castle.Core'' ComponentRegistration = Castle::MicroKernel::Registration::ComponentRegistration ComponentModel = Castle::Core::ComponentModel Parameter = Castle::MicroKernel::Registration::Parameter Component = Castle::MicroKernel::Registration::Component def component(options) throw :classIsRequired if !options.has_key?(:class) klass = options[:class].to_clr_type if options.has_key?(:service) service = options[:service].to_clr_type else service = klass end if options.has_key?(:name) name = options[:name] else name = klass.class.name.underscore.lowercase end model = ComponentModel.new(name, service, klass) if options.has_key?(:parameters) parameters = options[:parameters] parameters.each do |p| model.Parameters.Add(p.key, p.value) end end $container.Register(ComponentRegistration.new(model)) end"; ScriptSource headerSource = engine.CreateScriptSourceFromString(header); headerSource.Execute(); string containerScript = reader.ReadToEnd(); ScriptSource source = engine.CreateScriptSourceFromString(containerScript); source.Execute(); } } 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> How do you run this script? From command line (ir.exe script.rb) or do you use hosting API? Tomas From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Nathan Stott Sent: Wednesday, March 18, 2009 8:33 AM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: [Ironruby-core] problem Hi all. I have a question that probably belongs on a users mailing list but I could not find one. I get the following error when trying to use my IronRuby windsor registration script: System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel I assume this has something to do with the fact that newing up an object in IronRuby isn''t the same thing as newing it up in C#. Any suggestions or guidance would be appreciated. Here is the important IronRuby code: require ''Castle.Windsor'' require ''Castle.MicroKernel'' require ''Castle.Core'' ComponentRegistration = Castle::MicroKernel::Registration::ComponentRegistration ComponentModel = Castle::Core::ComponentModel Parameter = Castle::MicroKernel::Registration::Parameter Component = Castle::MicroKernel::Registration::Component def component(options) throw :classIsRequired if !options.has_key?(:class) klass = options[:class].to_clr_type if options.has_key?(:service) service = options[:service].to_clr_type else service = klass end if options.has_key?(:name) name = options[:name] else name = klass.class.name.underscore.lowercase end model = ComponentModel.new(name, service, klass) if options.has_key?(:parameters) parameters = options[:parameters] parameters.each do |p| model.Parameters.Add(p.key, p.value) end end $container.Register(ComponentRegistration.new(model)) end _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/c8f77919/attachment-0001.html>
We haven?t branched a users mailing list, so this is the perfect mailing list for questions like this. JD From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Nathan Stott Sent: Wednesday, March 18, 2009 12:55 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] problem Good call Ivan. The LoadAssembly apparently was doing the trick! Thanks for the help. BTW, was this the right mailing list for this question? Is there a users mailing list? 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz<mailto:ivan at flanders.co.nz>> If so turn off shadow copy assemblies under Resharper -> options -> unit testing On Wed, Mar 18, 2009 at 8:22 PM, Ivan Porto Carrero <ivan at flanders.co.nz<mailto:ivan at flanders.co.nz>> wrote: Are you using resharper for your unit tests? 2009/3/18 Nathan Stott <nrstott at gmail.com<mailto:nrstott at gmail.com>> I dont know if this helps, but this is the full output of the test: ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent : Failed CT_INIT: Object UPDATED: Object CreateInstanceSingleton affected=1 rules=0 UPDATED: Object CreateInstanceSingleton affected=1 rules=0 CT_INIT: File::Constants CT_INIT: IO CT_INIT: File UPDATED: Object CreateInstanceSingleton affected=1 rules=0 MT_INIT: Kernel MT_INIT: Object MT_INIT: <anonymous> MT_INIT: Module MT_INIT: Class MT_INIT: <anonymous> UPDATED: Object CreateInstanceSingleton affected=5 rules=1 MT_INIT: <anonymous> LOADER: Loading assembly ''Motorpool.Calendar.Web.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' and type '''' MT_INIT: Symbol MT_INIT: Enumerable MT_INIT: Hash MT_INIT: Microsoft::Scripting::Actions::TypeTracker MT_INIT: Microsoft::Scripting::Actions::TypeGroup System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel at CallSite.Target(Closure , CallSite , RubyMethodScope , Object , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>(CallSite site, T0 arg0, T1 arg1, T2 arg2) in C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 at ??;component;;10;(Closure , Object , Proc , Object ) at CallSite.Target(Closure , CallSite , RubyScope , Object , Hash ) at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>(CallSite site, T0 arg0, T1 arg1, T2 arg2) in C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 at ??;#;;0;(Closure , Scope , LanguageContext ) at Microsoft.Scripting.Runtime.LegacyScriptCode.Run() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\LegacyScriptCode.cs: line 43 at Microsoft.Scripting.SourceUnit.Execute() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\SourceUnit.cs: line 239 at Microsoft.Scripting.Hosting.ScriptSource.Execute() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Hosting\ScriptSource.cs: line 138 at Motorpool.Calendar.Service.ComponentLoader.Load(IWindsorContainer container, TextReader reader) in ComponentLoader.cs: line 64 at Motorpool.Calendar.Web.Test.ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent() in ComponentLoaderRegisteringComponentContext.cs: line 26 On Wed, Mar 18, 2009 at 1:55 PM, Nathan Stott <nrstott at gmail.com<mailto:nrstott at gmail.com>> wrote: I tried that and no luck. It doesn''t seem that the assembly is not being loaded properly. I''m able to use methods on the objects fine in the script. However, it is that last call to the $container.Register(ComponentRegistration.new(model)) where for some reason it won''t work. ComponentRegistration.new() takes a ComponentModel. The error seems to indicate that it is receiving a ComponentModel even with the same namespace prefixes but somehow it''s not able to use it. 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz<mailto:ivan at flanders.co.nz>> You can try using the LoadAssembly method on the runtime object runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); that should require the assembly a little nicer I think you can also use load_assembly ''Castle.Windsor'' http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 2009/3/18 Nathan Stott <nrstott at gmail.com<mailto:nrstott at gmail.com>> I''m using the hosting API. This is the entire method: public void Load(IWindsorContainer container, TextReader reader) { var runtime = Ruby.CreateRuntime(); ScriptEngine engine = Ruby.GetEngine(runtime); var ctx = Ruby.GetExecutionContext(runtime); ctx.DefineReadOnlyGlobalVariable("container", container); string header @"require ''Castle.Windsor'' require ''Castle.MicroKernel'' require ''Castle.Core'' ComponentRegistration = Castle::MicroKernel::Registration::ComponentRegistration ComponentModel = Castle::Core::ComponentModel Parameter = Castle::MicroKernel::Registration::Parameter Component = Castle::MicroKernel::Registration::Component def component(options) throw :classIsRequired if !options.has_key?(:class) klass = options[:class].to_clr_type if options.has_key?(:service) service = options[:service].to_clr_type else service = klass end if options.has_key?(:name) name = options[:name] else name = klass.class.name.underscore.lowercase end model = ComponentModel.new(name, service, klass) if options.has_key?(:parameters) parameters = options[:parameters] parameters.each do |p| model.Parameters.Add(p.key, p.value) end end $container.Register(ComponentRegistration.new(model)) end"; ScriptSource headerSource = engine.CreateScriptSourceFromString(header); headerSource.Execute(); string containerScript = reader.ReadToEnd(); ScriptSource source = engine.CreateScriptSourceFromString(containerScript); source.Execute(); } } 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> How do you run this script? From command line (ir.exe script.rb) or do you use hosting API? Tomas From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Nathan Stott Sent: Wednesday, March 18, 2009 8:33 AM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: [Ironruby-core] problem Hi all. I have a question that probably belongs on a users mailing list but I could not find one. I get the following error when trying to use my IronRuby windsor registration script: System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel I assume this has something to do with the fact that newing up an object in IronRuby isn''t the same thing as newing it up in C#. Any suggestions or guidance would be appreciated. Here is the important IronRuby code: require ''Castle.Windsor'' require ''Castle.MicroKernel'' require ''Castle.Core'' ComponentRegistration = Castle::MicroKernel::Registration::ComponentRegistration ComponentModel = Castle::Core::ComponentModel Parameter = Castle::MicroKernel::Registration::Parameter Component = Castle::MicroKernel::Registration::Component def component(options) throw :classIsRequired if !options.has_key?(:class) klass = options[:class].to_clr_type if options.has_key?(:service) service = options[:service].to_clr_type else service = klass end if options.has_key?(:name) name = options[:name] else name = klass.class.name.underscore.lowercase end model = ComponentModel.new(name, service, klass) if options.has_key?(:parameters) parameters = options[:parameters] parameters.each do |p| model.Parameters.Add(p.key, p.value) end end $container.Register(ComponentRegistration.new(model)) end _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/cc26156e/attachment-0001.html>
Yes, this was the right list ? we don?t have any other. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Nathan Stott Sent: Wednesday, March 18, 2009 12:55 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] problem Good call Ivan. The LoadAssembly apparently was doing the trick! Thanks for the help. BTW, was this the right mailing list for this question? Is there a users mailing list? 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz<mailto:ivan at flanders.co.nz>> If so turn off shadow copy assemblies under Resharper -> options -> unit testing On Wed, Mar 18, 2009 at 8:22 PM, Ivan Porto Carrero <ivan at flanders.co.nz<mailto:ivan at flanders.co.nz>> wrote: Are you using resharper for your unit tests? 2009/3/18 Nathan Stott <nrstott at gmail.com<mailto:nrstott at gmail.com>> I dont know if this helps, but this is the full output of the test: ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent : Failed CT_INIT: Object UPDATED: Object CreateInstanceSingleton affected=1 rules=0 UPDATED: Object CreateInstanceSingleton affected=1 rules=0 CT_INIT: File::Constants CT_INIT: IO CT_INIT: File UPDATED: Object CreateInstanceSingleton affected=1 rules=0 MT_INIT: Kernel MT_INIT: Object MT_INIT: <anonymous> MT_INIT: Module MT_INIT: Class MT_INIT: <anonymous> UPDATED: Object CreateInstanceSingleton affected=5 rules=1 MT_INIT: <anonymous> LOADER: Loading assembly ''Motorpool.Calendar.Web.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' and type '''' MT_INIT: Symbol MT_INIT: Enumerable MT_INIT: Hash MT_INIT: Microsoft::Scripting::Actions::TypeTracker MT_INIT: Microsoft::Scripting::Actions::TypeGroup System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel at CallSite.Target(Closure , CallSite , RubyMethodScope , Object , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>(CallSite site, T0 arg0, T1 arg1, T2 arg2) in C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 at ??;component;;10;(Closure , Object , Proc , Object ) at CallSite.Target(Closure , CallSite , RubyScope , Object , Hash ) at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>(CallSite site, T0 arg0, T1 arg1, T2 arg2) in C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 at ??;#;;0;(Closure , Scope , LanguageContext ) at Microsoft.Scripting.Runtime.LegacyScriptCode.Run() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\LegacyScriptCode.cs: line 43 at Microsoft.Scripting.SourceUnit.Execute() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\SourceUnit.cs: line 239 at Microsoft.Scripting.Hosting.ScriptSource.Execute() in C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Hosting\ScriptSource.cs: line 138 at Motorpool.Calendar.Service.ComponentLoader.Load(IWindsorContainer container, TextReader reader) in ComponentLoader.cs: line 64 at Motorpool.Calendar.Web.Test.ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent() in ComponentLoaderRegisteringComponentContext.cs: line 26 On Wed, Mar 18, 2009 at 1:55 PM, Nathan Stott <nrstott at gmail.com<mailto:nrstott at gmail.com>> wrote: I tried that and no luck. It doesn''t seem that the assembly is not being loaded properly. I''m able to use methods on the objects fine in the script. However, it is that last call to the $container.Register(ComponentRegistration.new(model)) where for some reason it won''t work. ComponentRegistration.new() takes a ComponentModel. The error seems to indicate that it is receiving a ComponentModel even with the same namespace prefixes but somehow it''s not able to use it. 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz<mailto:ivan at flanders.co.nz>> You can try using the LoadAssembly method on the runtime object runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); that should require the assembly a little nicer I think you can also use load_assembly ''Castle.Windsor'' http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 2009/3/18 Nathan Stott <nrstott at gmail.com<mailto:nrstott at gmail.com>> I''m using the hosting API. This is the entire method: public void Load(IWindsorContainer container, TextReader reader) { var runtime = Ruby.CreateRuntime(); ScriptEngine engine = Ruby.GetEngine(runtime); var ctx = Ruby.GetExecutionContext(runtime); ctx.DefineReadOnlyGlobalVariable("container", container); string header @"require ''Castle.Windsor'' require ''Castle.MicroKernel'' require ''Castle.Core'' ComponentRegistration = Castle::MicroKernel::Registration::ComponentRegistration ComponentModel = Castle::Core::ComponentModel Parameter = Castle::MicroKernel::Registration::Parameter Component = Castle::MicroKernel::Registration::Component def component(options) throw :classIsRequired if !options.has_key?(:class) klass = options[:class].to_clr_type if options.has_key?(:service) service = options[:service].to_clr_type else service = klass end if options.has_key?(:name) name = options[:name] else name = klass.class.name.underscore.lowercase end model = ComponentModel.new(name, service, klass) if options.has_key?(:parameters) parameters = options[:parameters] parameters.each do |p| model.Parameters.Add(p.key, p.value) end end $container.Register(ComponentRegistration.new(model)) end"; ScriptSource headerSource = engine.CreateScriptSourceFromString(header); headerSource.Execute(); string containerScript = reader.ReadToEnd(); ScriptSource source = engine.CreateScriptSourceFromString(containerScript); source.Execute(); } } 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> How do you run this script? From command line (ir.exe script.rb) or do you use hosting API? Tomas From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Nathan Stott Sent: Wednesday, March 18, 2009 8:33 AM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: [Ironruby-core] problem Hi all. I have a question that probably belongs on a users mailing list but I could not find one. I get the following error when trying to use my IronRuby windsor registration script: System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel I assume this has something to do with the fact that newing up an object in IronRuby isn''t the same thing as newing it up in C#. Any suggestions or guidance would be appreciated. Here is the important IronRuby code: require ''Castle.Windsor'' require ''Castle.MicroKernel'' require ''Castle.Core'' ComponentRegistration = Castle::MicroKernel::Registration::ComponentRegistration ComponentModel = Castle::Core::ComponentModel Parameter = Castle::MicroKernel::Registration::Parameter Component = Castle::MicroKernel::Registration::Component def component(options) throw :classIsRequired if !options.has_key?(:class) klass = options[:class].to_clr_type if options.has_key?(:service) service = options[:service].to_clr_type else service = klass end if options.has_key?(:name) name = options[:name] else name = klass.class.name.underscore.lowercase end model = ComponentModel.new(name, service, klass) if options.has_key?(:parameters) parameters = options[:parameters] parameters.each do |p| model.Parameters.Add(p.key, p.value) end end $container.Register(ComponentRegistration.new(model)) end _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/be8c77c6/attachment-0001.html>
Excellent. Thanks for your help, guys. I''m now able to use IronRuby for my windsor registration DSL. I''m very pleased so far. I have one other question, how can I take a clr type and get its clr name? When I do this: sometype.to_clr_type.class.name I always get System::RuntimeType 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com>> Yes, this was the right list ? we don?t have any other. > > > > Tomas > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott > *Sent:* Wednesday, March 18, 2009 12:55 PM > *To:* ironruby-core at rubyforge.org > *Subject:* Re: [Ironruby-core] problem > > > > Good call Ivan. > > > > The LoadAssembly apparently was doing the trick! > > > > Thanks for the help. > > > BTW, was this the right mailing list for this question? Is there a users > mailing list? > > > > 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz> > > If so turn off shadow copy assemblies under Resharper -> options -> unit > testing > > On Wed, Mar 18, 2009 at 8:22 PM, Ivan Porto Carrero <ivan at flanders.co.nz> > wrote: > > Are you using resharper for your unit tests? > > > > 2009/3/18 Nathan Stott <nrstott at gmail.com> > > I dont know if this helps, but this is the full output of the test: > ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent : > Failed > > CT_INIT: Object > > UPDATED: Object CreateInstanceSingleton affected=1 rules=0 > > UPDATED: Object CreateInstanceSingleton affected=1 rules=0 > CT_INIT: File::Constants > CT_INIT: IO > CT_INIT: File > > UPDATED: Object CreateInstanceSingleton affected=1 rules=0 > MT_INIT: Kernel > MT_INIT: Object > MT_INIT: <anonymous> > MT_INIT: Module > MT_INIT: Class > MT_INIT: <anonymous> > > UPDATED: Object CreateInstanceSingleton affected=5 rules=1 > MT_INIT: <anonymous> > > LOADER: Loading assembly ''Motorpool.Calendar.Web.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' and type '''' > MT_INIT: Symbol > MT_INIT: Enumerable > MT_INIT: Hash > MT_INIT: Microsoft::Scripting::Actions::TypeTracker > MT_INIT: Microsoft::Scripting::Actions::TypeGroup > > > System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel > > at CallSite.Target(Closure , CallSite , RubyMethodScope , Object , Object ) > at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( > CallSite site, T0 arg0, T1 arg1, T2 arg2) in > C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 > at ??;component;;10;(Closure , Object , Proc , Object ) > at CallSite.Target(Closure , CallSite , RubyScope , Object , Hash ) > at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( > CallSite site, T0 arg0, T1 arg1, T2 arg2) in > C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 > at ??;#;;0;(Closure , Scope , LanguageContext ) > at Microsoft.Scripting.Runtime.LegacyScriptCode.Run() in > C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\LegacyScriptCode.cs: line 43 > at Microsoft.Scripting.SourceUnit.Execute() in > C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\SourceUnit.cs: line 239 > at Microsoft.Scripting.Hosting.ScriptSource.Execute() in > C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Hosting\ScriptSource.cs: line 138 > at Motorpool.Calendar.Service.ComponentLoader.Load(IWindsorContainer > container, TextReader reader) in ComponentLoader.cs: line 64 > at Motorpool.Calendar.Web.Test.ComponentLoaderRegisteringComponentContext > .ShouldRegisterComponent() in > ComponentLoaderRegisteringComponentContext.cs: line 26 > > > > On Wed, Mar 18, 2009 at 1:55 PM, Nathan Stott <nrstott at gmail.com> wrote: > > I tried that and no luck. > > > > It doesn''t seem that the assembly is not being loaded properly. I''m able > to use methods on the objects fine in the script. However, it is that last > call to the $container.Register(ComponentRegistration.new(model)) where for > some reason it won''t work. > > > > ComponentRegistration.new() takes a ComponentModel. The error seems to > indicate that it is receiving a ComponentModel even with the same namespace > prefixes but somehow it''s not able to use it. > > 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz> > > > > You can try using the LoadAssembly method on the runtime object > > runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); > > that should require the assembly a little nicer > > I think you can also use load_assembly ''Castle.Windsor'' > > > http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 > > http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 > > http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 > > > 2009/3/18 Nathan Stott <nrstott at gmail.com> > > > > I''m using the hosting API. > > > > This is the entire method: > > public void Load(IWindsorContainer container, TextReader > reader) > > { > > var runtime = Ruby.CreateRuntime(); > > ScriptEngine engine = Ruby.GetEngine(runtime); > > var ctx = Ruby.GetExecutionContext(runtime); > > ctx.DefineReadOnlyGlobalVariable("container", > container); > > > > string header > > @"require ''Castle.Windsor'' > > require ''Castle.MicroKernel'' > > require ''Castle.Core'' > > > > ComponentRegistration > Castle::MicroKernel::Registration::ComponentRegistration > > ComponentModel = Castle::Core::ComponentModel > > Parameter = Castle::MicroKernel::Registration::Parameter > > Component = Castle::MicroKernel::Registration::Component > > > > def component(options) > > throw :classIsRequired if !options.has_key?(:class) > > > > klass = options[:class].to_clr_type > > > > if options.has_key?(:service) > > service = options[:service].to_clr_type > > else > > service = klass > > end > > > > if options.has_key?(:name) > > name = options[:name] > > else > > name = klass.class.name.underscore.lowercase > > end > > > > model = ComponentModel.new(name, service, klass) > > > > if options.has_key?(:parameters) > > parameters = options[:parameters] > > parameters.each do |p| > > model.Parameters.Add(p.key, p.value) > > end > > end > > > > $container.Register(ComponentRegistration.new(model)) > > end"; > > > > ScriptSource headerSource > engine.CreateScriptSourceFromString(header); > > headerSource.Execute(); > > > > string containerScript = reader.ReadToEnd(); > > ScriptSource source > engine.CreateScriptSourceFromString(containerScript); > > source.Execute(); > > } > > } > > > > 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com> > > How do you run this script? From command line (ir.exe script.rb) or do you > use hosting API? > > > > Tomas > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott > *Sent:* Wednesday, March 18, 2009 8:33 AM > *To:* ironruby-core at rubyforge.org > *Subject:* [Ironruby-core] problem > > > > Hi all. I have a question that probably belongs on a users mailing list > but I could not find one. > > > > I get the following error when trying to use my IronRuby windsor > registration script: > > * > System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel > * > > > > I assume this has something to do with the fact that newing up an object in > IronRuby isn''t the same thing as newing it up in C#. > > > > Any suggestions or guidance would be appreciated. > > > > Here is the important IronRuby code: > > > > require ''Castle.Windsor'' > > require ''Castle.MicroKernel'' > > require ''Castle.Core'' > > > > ComponentRegistration > Castle::MicroKernel::Registration::ComponentRegistration > > ComponentModel = Castle::Core::ComponentModel > > Parameter = Castle::MicroKernel::Registration::Parameter > > Component = Castle::MicroKernel::Registration::Component > > > > def component(options) > > throw :classIsRequired if !options.has_key?(:class) > > > > klass = options[:class].to_clr_type > > > > if options.has_key?(:service) > > service = options[:service].to_clr_type > > else > > service = klass > > end > > > > if options.has_key?(:name) > > name = options[:name] > > else > > name = klass.class.name.underscore.lowercase > > end > > > > model = ComponentModel.new(name, service, klass) > > > > if options.has_key?(:parameters) > > parameters = options[:parameters] > > parameters.each do |p| > > model.Parameters.Add(p.key, p.value) > > end > > end > > > > $container.Register(ComponentRegistration.new(model)) > > end > > > > > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > > > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/7afe639b/attachment-0001.html>
sometype.to_clr_type.name :) you can look in the ninject stuff I did.. i bet it has a lot of the stuff you will need for your windsor dsl 2009/3/18 Nathan Stott <nrstott at gmail.com>> Excellent. > Thanks for your help, guys. > > I''m now able to use IronRuby for my windsor registration DSL. I''m very > pleased so far. > > I have one other question, how can I take a clr type and get its clr name? > > When I do this: > sometype.to_clr_type.class.name > > I always get System::RuntimeType > > 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com> > >> Yes, this was the right list ? we don?t have any other. >> >> >> >> Tomas >> >> >> >> *From:* ironruby-core-bounces at rubyforge.org [mailto: >> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott >> *Sent:* Wednesday, March 18, 2009 12:55 PM >> *To:* ironruby-core at rubyforge.org >> *Subject:* Re: [Ironruby-core] problem >> >> >> >> Good call Ivan. >> >> >> >> The LoadAssembly apparently was doing the trick! >> >> >> >> Thanks for the help. >> >> >> BTW, was this the right mailing list for this question? Is there a users >> mailing list? >> >> >> >> 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz> >> >> If so turn off shadow copy assemblies under Resharper -> options -> unit >> testing >> >> On Wed, Mar 18, 2009 at 8:22 PM, Ivan Porto Carrero <ivan at flanders.co.nz> >> wrote: >> >> Are you using resharper for your unit tests? >> >> >> >> 2009/3/18 Nathan Stott <nrstott at gmail.com> >> >> I dont know if this helps, but this is the full output of the test: >> ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent : >> Failed >> >> CT_INIT: Object >> >> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >> >> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >> CT_INIT: File::Constants >> CT_INIT: IO >> CT_INIT: File >> >> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >> MT_INIT: Kernel >> MT_INIT: Object >> MT_INIT: <anonymous> >> MT_INIT: Module >> MT_INIT: Class >> MT_INIT: <anonymous> >> >> UPDATED: Object CreateInstanceSingleton affected=5 rules=1 >> MT_INIT: <anonymous> >> >> LOADER: Loading assembly ''Motorpool.Calendar.Web.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' and type '''' >> MT_INIT: Symbol >> MT_INIT: Enumerable >> MT_INIT: Hash >> MT_INIT: Microsoft::Scripting::Actions::TypeTracker >> MT_INIT: Microsoft::Scripting::Actions::TypeGroup >> >> >> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >> >> at CallSite.Target(Closure , CallSite , RubyMethodScope , Object , Object >> ) >> at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( >> CallSite site, T0 arg0, T1 arg1, T2 arg2) in >> C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 >> at ??;component;;10;(Closure , Object , Proc , Object ) >> at CallSite.Target(Closure , CallSite , RubyScope , Object , Hash ) >> at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( >> CallSite site, T0 arg0, T1 arg1, T2 arg2) in >> C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 >> at ??;#;;0;(Closure , Scope , LanguageContext ) >> at Microsoft.Scripting.Runtime.LegacyScriptCode.Run() in >> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\LegacyScriptCode.cs: line 43 >> at Microsoft.Scripting.SourceUnit.Execute() in >> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\SourceUnit.cs: line 239 >> at Microsoft.Scripting.Hosting.ScriptSource.Execute() in >> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Hosting\ScriptSource.cs: line 138 >> at Motorpool.Calendar.Service.ComponentLoader.Load(IWindsorContainer >> container, TextReader reader) in ComponentLoader.cs: line 64 >> at Motorpool.Calendar.Web.Test.ComponentLoaderRegisteringComponentContext >> .ShouldRegisterComponent() in >> ComponentLoaderRegisteringComponentContext.cs: line 26 >> >> >> >> On Wed, Mar 18, 2009 at 1:55 PM, Nathan Stott <nrstott at gmail.com> wrote: >> >> I tried that and no luck. >> >> >> >> It doesn''t seem that the assembly is not being loaded properly. I''m able >> to use methods on the objects fine in the script. However, it is that last >> call to the $container.Register(ComponentRegistration.new(model)) where for >> some reason it won''t work. >> >> >> >> ComponentRegistration.new() takes a ComponentModel. The error seems to >> indicate that it is receiving a ComponentModel even with the same namespace >> prefixes but somehow it''s not able to use it. >> >> 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz> >> >> >> >> You can try using the LoadAssembly method on the runtime object >> >> runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); >> >> that should require the assembly a little nicer >> >> I think you can also use load_assembly ''Castle.Windsor'' >> >> >> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 >> >> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 >> >> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 >> >> >> 2009/3/18 Nathan Stott <nrstott at gmail.com> >> >> >> >> I''m using the hosting API. >> >> >> >> This is the entire method: >> >> public void Load(IWindsorContainer container, TextReader >> reader) >> >> { >> >> var runtime = Ruby.CreateRuntime(); >> >> ScriptEngine engine = Ruby.GetEngine(runtime); >> >> var ctx = Ruby.GetExecutionContext(runtime); >> >> ctx.DefineReadOnlyGlobalVariable("container", >> container); >> >> >> >> string header >> >> @"require ''Castle.Windsor'' >> >> require ''Castle.MicroKernel'' >> >> require ''Castle.Core'' >> >> >> >> ComponentRegistration >> Castle::MicroKernel::Registration::ComponentRegistration >> >> ComponentModel = Castle::Core::ComponentModel >> >> Parameter = Castle::MicroKernel::Registration::Parameter >> >> Component = Castle::MicroKernel::Registration::Component >> >> >> >> def component(options) >> >> throw :classIsRequired if !options.has_key?(:class) >> >> >> >> klass = options[:class].to_clr_type >> >> >> >> if options.has_key?(:service) >> >> service = options[:service].to_clr_type >> >> else >> >> service = klass >> >> end >> >> >> >> if options.has_key?(:name) >> >> name = options[:name] >> >> else >> >> name = klass.class.name.underscore.lowercase >> >> end >> >> >> >> model = ComponentModel.new(name, service, klass) >> >> >> >> if options.has_key?(:parameters) >> >> parameters = options[:parameters] >> >> parameters.each do |p| >> >> model.Parameters.Add(p.key, p.value) >> >> end >> >> end >> >> >> >> $container.Register(ComponentRegistration.new(model)) >> >> end"; >> >> >> >> ScriptSource headerSource >> engine.CreateScriptSourceFromString(header); >> >> headerSource.Execute(); >> >> >> >> string containerScript = reader.ReadToEnd(); >> >> ScriptSource source >> engine.CreateScriptSourceFromString(containerScript); >> >> source.Execute(); >> >> } >> >> } >> >> >> >> 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com> >> >> How do you run this script? >From command line (ir.exe script.rb) or do >> you use hosting API? >> >> >> >> Tomas >> >> >> >> *From:* ironruby-core-bounces at rubyforge.org [mailto: >> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott >> *Sent:* Wednesday, March 18, 2009 8:33 AM >> *To:* ironruby-core at rubyforge.org >> *Subject:* [Ironruby-core] problem >> >> >> >> Hi all. I have a question that probably belongs on a users mailing list >> but I could not find one. >> >> >> >> I get the following error when trying to use my IronRuby windsor >> registration script: >> >> * >> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >> * >> >> >> >> I assume this has something to do with the fact that newing up an object >> in IronRuby isn''t the same thing as newing it up in C#. >> >> >> >> Any suggestions or guidance would be appreciated. >> >> >> >> Here is the important IronRuby code: >> >> >> >> require ''Castle.Windsor'' >> >> require ''Castle.MicroKernel'' >> >> require ''Castle.Core'' >> >> >> >> ComponentRegistration >> Castle::MicroKernel::Registration::ComponentRegistration >> >> ComponentModel = Castle::Core::ComponentModel >> >> Parameter = Castle::MicroKernel::Registration::Parameter >> >> Component = Castle::MicroKernel::Registration::Component >> >> >> >> def component(options) >> >> throw :classIsRequired if !options.has_key?(:class) >> >> >> >> klass = options[:class].to_clr_type >> >> >> >> if options.has_key?(:service) >> >> service = options[:service].to_clr_type >> >> else >> >> service = klass >> >> end >> >> >> >> if options.has_key?(:name) >> >> name = options[:name] >> >> else >> >> name = klass.class.name.underscore.lowercase >> >> end >> >> >> >> model = ComponentModel.new(name, service, klass) >> >> >> >> if options.has_key?(:parameters) >> >> parameters = options[:parameters] >> >> parameters.each do |p| >> >> model.Parameters.Add(p.key, p.value) >> >> end >> >> end >> >> >> >> $container.Register(ComponentRegistration.new(model)) >> >> end >> >> >> >> >> >> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> >> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> >> >> >> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> >> >> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/cf7a83e9/attachment-0001.html>
Hey Ivan, thanks. I found your post about ninject. Good stuff. 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz>> sometype.to_clr_type.name :) > > you can look in the ninject stuff I did.. i bet it has a lot of the stuff > you will need for your windsor dsl > > > > 2009/3/18 Nathan Stott <nrstott at gmail.com> > >> Excellent. >> Thanks for your help, guys. >> >> I''m now able to use IronRuby for my windsor registration DSL. I''m very >> pleased so far. >> >> I have one other question, how can I take a clr type and get its clr name? >> >> When I do this: >> sometype.to_clr_type.class.name >> >> I always get System::RuntimeType >> >> 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com> >> >>> Yes, this was the right list ? we don?t have any other. >>> >>> >>> >>> Tomas >>> >>> >>> >>> *From:* ironruby-core-bounces at rubyforge.org [mailto: >>> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott >>> *Sent:* Wednesday, March 18, 2009 12:55 PM >>> *To:* ironruby-core at rubyforge.org >>> *Subject:* Re: [Ironruby-core] problem >>> >>> >>> >>> Good call Ivan. >>> >>> >>> >>> The LoadAssembly apparently was doing the trick! >>> >>> >>> >>> Thanks for the help. >>> >>> >>> BTW, was this the right mailing list for this question? Is there a users >>> mailing list? >>> >>> >>> >>> 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz> >>> >>> If so turn off shadow copy assemblies under Resharper -> options -> unit >>> testing >>> >>> On Wed, Mar 18, 2009 at 8:22 PM, Ivan Porto Carrero <ivan at flanders.co.nz> >>> wrote: >>> >>> Are you using resharper for your unit tests? >>> >>> >>> >>> 2009/3/18 Nathan Stott <nrstott at gmail.com> >>> >>> I dont know if this helps, but this is the full output of the test: >>> ComponentLoaderRegisteringComponentContext.ShouldRegisterComponent : >>> Failed >>> >>> CT_INIT: Object >>> >>> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >>> >>> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >>> CT_INIT: File::Constants >>> CT_INIT: IO >>> CT_INIT: File >>> >>> UPDATED: Object CreateInstanceSingleton affected=1 rules=0 >>> MT_INIT: Kernel >>> MT_INIT: Object >>> MT_INIT: <anonymous> >>> MT_INIT: Module >>> MT_INIT: Class >>> MT_INIT: <anonymous> >>> >>> UPDATED: Object CreateInstanceSingleton affected=5 rules=1 >>> MT_INIT: <anonymous> >>> >>> LOADER: Loading assembly ''Motorpool.Calendar.Web.Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'' and type '''' >>> MT_INIT: Symbol >>> MT_INIT: Enumerable >>> MT_INIT: Hash >>> MT_INIT: Microsoft::Scripting::Actions::TypeTracker >>> MT_INIT: Microsoft::Scripting::Actions::TypeGroup >>> >>> >>> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >>> >>> at CallSite.Target(Closure , CallSite , RubyMethodScope , Object , Object >>> ) >>> at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( >>> CallSite site, T0 arg0, T1 arg1, T2 arg2) in >>> C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 >>> at ??;component;;10;(Closure , Object , Proc , Object ) >>> at CallSite.Target(Closure , CallSite , RubyScope , Object , Hash ) >>> at System.Dynamic.UpdateDelegates.UpdateAndExecute3<T0,T1,T2,TRet>( >>> CallSite site, T0 arg0, T1 arg1, T2 arg2) in >>> C:\git\ironruby\ndp\fx\src\Core\Microsoft\Scripting\Actions\UpdateDelegates.Generated.cs: line 509 >>> at ??;#;;0;(Closure , Scope , LanguageContext ) >>> at Microsoft.Scripting.Runtime.LegacyScriptCode.Run() in >>> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Runtime\LegacyScriptCode.cs: line 43 >>> at Microsoft.Scripting.SourceUnit.Execute() in >>> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\SourceUnit.cs: line 239 >>> at Microsoft.Scripting.Hosting.ScriptSource.Execute() in >>> C:\git\ironruby\Merlin\Main\Runtime\Microsoft.Scripting\Hosting\ScriptSource.cs: line 138 >>> at Motorpool.Calendar.Service.ComponentLoader.Load(IWindsorContainer >>> container, TextReader reader) in ComponentLoader.cs: line 64 >>> at >>> Motorpool.Calendar.Web.Test.ComponentLoaderRegisteringComponentContext >>> .ShouldRegisterComponent() in >>> ComponentLoaderRegisteringComponentContext.cs: line 26 >>> >>> >>> >>> On Wed, Mar 18, 2009 at 1:55 PM, Nathan Stott <nrstott at gmail.com> wrote: >>> >>> I tried that and no luck. >>> >>> >>> >>> It doesn''t seem that the assembly is not being loaded properly. I''m able >>> to use methods on the objects fine in the script. However, it is that last >>> call to the $container.Register(ComponentRegistration.new(model)) where for >>> some reason it won''t work. >>> >>> >>> >>> ComponentRegistration.new() takes a ComponentModel. The error seems to >>> indicate that it is receiving a ComponentModel even with the same namespace >>> prefixes but somehow it''s not able to use it. >>> >>> 2009/3/18 Ivan Porto Carrero <ivan at flanders.co.nz> >>> >>> >>> >>> You can try using the LoadAssembly method on the runtime object >>> >>> runtime.LoadAssembly(typeof(IWindsorContainer).Assembly); >>> >>> that should require the assembly a little nicer >>> >>> I think you can also use load_assembly ''Castle.Windsor'' >>> >>> >>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L166 >>> >>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L142 >>> >>> http://github.com/casualjim/ninject-dynamic/blob/0b531d9e3ae46cc3e8549c9cfc078a8c27e5dda7/src/Ninject.Dynamic/RubyEngine.cs#L90 >>> >>> >>> 2009/3/18 Nathan Stott <nrstott at gmail.com> >>> >>> >>> >>> I''m using the hosting API. >>> >>> >>> >>> This is the entire method: >>> >>> public void Load(IWindsorContainer container, TextReader >>> reader) >>> >>> { >>> >>> var runtime = Ruby.CreateRuntime(); >>> >>> ScriptEngine engine >>> Ruby.GetEngine(runtime); >>> >>> var ctx = Ruby.GetExecutionContext(runtime); >>> >>> ctx.DefineReadOnlyGlobalVariable("container", >>> container); >>> >>> >>> >>> string header >>> >>> @"require ''Castle.Windsor'' >>> >>> require ''Castle.MicroKernel'' >>> >>> require ''Castle.Core'' >>> >>> >>> >>> ComponentRegistration >>> Castle::MicroKernel::Registration::ComponentRegistration >>> >>> ComponentModel = Castle::Core::ComponentModel >>> >>> Parameter = Castle::MicroKernel::Registration::Parameter >>> >>> Component = Castle::MicroKernel::Registration::Component >>> >>> >>> >>> def component(options) >>> >>> throw :classIsRequired if !options.has_key?(:class) >>> >>> >>> >>> klass = options[:class].to_clr_type >>> >>> >>> >>> if options.has_key?(:service) >>> >>> service = options[:service].to_clr_type >>> >>> else >>> >>> service = klass >>> >>> end >>> >>> >>> >>> if options.has_key?(:name) >>> >>> name = options[:name] >>> >>> else >>> >>> name = klass.class.name.underscore.lowercase >>> >>> end >>> >>> >>> >>> model = ComponentModel.new(name, service, klass) >>> >>> >>> >>> if options.has_key?(:parameters) >>> >>> parameters = options[:parameters] >>> >>> parameters.each do |p| >>> >>> model.Parameters.Add(p.key, p.value) >>> >>> end >>> >>> end >>> >>> >>> >>> $container.Register(ComponentRegistration.new(model)) >>> >>> end"; >>> >>> >>> >>> ScriptSource headerSource >>> engine.CreateScriptSourceFromString(header); >>> >>> headerSource.Execute(); >>> >>> >>> >>> string containerScript = reader.ReadToEnd(); >>> >>> ScriptSource source >>> engine.CreateScriptSourceFromString(containerScript); >>> >>> source.Execute(); >>> >>> } >>> >>> } >>> >>> >>> >>> 2009/3/18 Tomas Matousek <Tomas.Matousek at microsoft.com> >>> >>> How do you run this script? >From command line (ir.exe script.rb) or do >>> you use hosting API? >>> >>> >>> >>> Tomas >>> >>> >>> >>> *From:* ironruby-core-bounces at rubyforge.org [mailto: >>> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Nathan Stott >>> *Sent:* Wednesday, March 18, 2009 8:33 AM >>> *To:* ironruby-core at rubyforge.org >>> *Subject:* [Ironruby-core] problem >>> >>> >>> >>> Hi all. I have a question that probably belongs on a users mailing list >>> but I could not find one. >>> >>> >>> >>> I get the following error when trying to use my IronRuby windsor >>> registration script: >>> >>> * >>> System.InvalidOperationException: can''t convert Castle::Core::ComponentModel into Castle::Core::ComponentModel >>> * >>> >>> >>> >>> I assume this has something to do with the fact that newing up an object >>> in IronRuby isn''t the same thing as newing it up in C#. >>> >>> >>> >>> Any suggestions or guidance would be appreciated. >>> >>> >>> >>> Here is the important IronRuby code: >>> >>> >>> >>> require ''Castle.Windsor'' >>> >>> require ''Castle.MicroKernel'' >>> >>> require ''Castle.Core'' >>> >>> >>> >>> ComponentRegistration >>> Castle::MicroKernel::Registration::ComponentRegistration >>> >>> ComponentModel = Castle::Core::ComponentModel >>> >>> Parameter = Castle::MicroKernel::Registration::Parameter >>> >>> Component = Castle::MicroKernel::Registration::Component >>> >>> >>> >>> def component(options) >>> >>> throw :classIsRequired if !options.has_key?(:class) >>> >>> >>> >>> klass = options[:class].to_clr_type >>> >>> >>> >>> if options.has_key?(:service) >>> >>> service = options[:service].to_clr_type >>> >>> else >>> >>> service = klass >>> >>> end >>> >>> >>> >>> if options.has_key?(:name) >>> >>> name = options[:name] >>> >>> else >>> >>> name = klass.class.name.underscore.lowercase >>> >>> end >>> >>> >>> >>> model = ComponentModel.new(name, service, klass) >>> >>> >>> >>> if options.has_key?(:parameters) >>> >>> parameters = options[:parameters] >>> >>> parameters.each do |p| >>> >>> model.Parameters.Add(p.key, p.value) >>> >>> end >>> >>> end >>> >>> >>> >>> $container.Register(ComponentRegistration.new(model)) >>> >>> end >>> >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >>> >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >>> >>> >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090318/ae65a8b0/attachment-0001.html>