you can try copying your cmdparser.dll to the bin folder where ir.exe lives. That might work because I assume you've got it in the bin of your application already. Don't shoot me if it doesn't. I had to do this when I wanted to use particular control sets in WPF but that was a long time ago (>1yr) so things might be different now. --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero)
On Sun, Jan 10, 2010 at 12:24 AM, andrew Wilson <a.wilso...@gmail.com>wrote: > I am building a console application that uses a MSH style CmdParser ( > http://channel9.msdn.com/playground/Sandbox/52952/) to read input > parameters and reflect match them up against a data class defining their > meaning. > > In the attempt to use RSpec & IronRuby to test my .net application, the > code blows up on a call to the below method: > > private static Parameter[] GetPublicReadWriteCmdMembers(object instance) > { > if ( instance == null ) > throw new ArgumentNullException("instance"); > > ArrayList al = new ArrayList(); > Type type = instance.GetType(); > ArrayList members = new ArrayList(); > members.AddRange(type.GetProperties()); > members.AddRange(type.GetFields()); > > if ( members.Count == 0 ) > throw new ArgumentException("No public members in type."); > > foreach(MemberInfo mi in members) > { > // Only add members that have ParameterBaseAttribute(s). > if ( ! mi.IsDefined(typeof(ParameterBaseAttribute), true) ) > continue; > > switch(mi.MemberType) > { > case MemberTypes.Property: > PropertyInfo pi = (PropertyInfo)mi; > if ( ! (pi.PropertyType.IsPublic && pi.CanRead && > pi.CanWrite) ) > throw new ArgumentException("All CMD members > must be public readable and writeable."); > > // Loop here on members if parameterAttributes. > object[] pArray = > pi.GetCustomAttributes(typeof(ParameterAttribute), true); > if ( pArray != null && pArray.Length > 0 ) > { > foreach(ParameterAttribute pa in pArray) > { > Parameter p = > Parameter.CreateParameter(instance, mi, pa); > al.Add(p); > } > } > else > { > // Use default ParameterAttribute. > ParameterAttribute pa = new > ParameterAttribute(); > Parameter p = > Parameter.CreateParameter(instance, mi, pa); > al.Add(p); > } > break; > case MemberTypes.Field: > FieldInfo fi = (FieldInfo)mi; > if ( ! fi.FieldType.IsPublic ) > throw new ArgumentException("All Cmd members > must be public"); > > object[] pArray2 = > fi.GetCustomAttributes(typeof(ParameterAttribute), true); > if ( pArray2 != null && pArray2.Length > 0 ) > { > foreach(ParameterAttribute pa in pArray2) > { > Parameter p = > Parameter.CreateParameter(instance, mi, pa); > al.Add(p); > } > } > else > { > // Use default ParameterAttribute. > ParameterAttribute pa = new > ParameterAttribute(); > Parameter p = > Parameter.CreateParameter(instance, mi, pa); > al.Add(p); > } > > break; > default: > break; > } > } > return (Parameter[])al.ToArray(typeof(Parameter)); > } > > Specifically, the exception thrown is on the call: if ( ! > mi.IsDefined(typeof(ParameterBaseAttribute), true) ) which is using > reflection to figure out if the input parameter is defined in my data class > (as best I can tell). > > The exception is: > > Could not load file or assembly 'CmdParser, Version=1.5.0.0, > Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system > cannot find the file specified. > > So. I am stuck at a bit of an impasse. I tried requiring the CmdParser > assembly in the way it claims above and it indeed blows up. However, if I > call require.the dll itself and do some testing in IR I can repeat the > exception during the reflection call. > > Any ideas for how I might get through this? > > -Andrew > > -- > When I wrote this, only God and I understood what I was doing. Now, God > only knows - Karl Weierstrass > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core@rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >
_______________________________________________ Ironruby-core mailing list Ironruby-core@rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core