why can not create new object in other assime

Mar 29, 2012 at 3:11 AM

this is my code, but can't load other assembly object , example: DataTable, Form.

i use  Assembly.Load also fail.

 zhank's a lot tell me how to correct this question.


|  OBJECT ident_list '(' expr_list ')'
  Stack<BindHelper.ObjectPath> objs =  $2 as Stack<BindHelper.ObjectPath>;
  if (objs == null)
   objs = new Stack<BindHelper.ObjectPath>();   
  $$ = objs;  
  object self = $2;
  object op = $4;
  dynamic op2 = op;  
  Type t = bindHelper.GetValidClassType(self.ToString());
  if (t == null)
   throw new ArgumentException("the name is not found:" + self.ToString());
  dynamic q = Activator.CreateInstance(t,  (op == null) ? null : op2.ToArray()); 
  BindHelper.ObjectPath obj = new BindHelper.ObjectPath(BindHelper.SelfType.DotNetObject, q, self.ToString(), t);
  obj.AddArgs =  (op == null) ? null : op2.ToArray();
  obj.IsValid = true;

Mar 29, 2012 at 6:47 AM


I am sorry, but I do not understand what your code is trying to do.  You also did not say what happens with this code: does it compile ok?  Does it throw an exception, and if so what kind of exception.

May I suggest that you move most of this code out to a helper procedure.  The procedure might look like this --

public static void DoBinding(Stack<BindHelper.ObjectPath> objs, object self, object op) { ... }

and call this just after "$$ = objs;", by "DoBinding(objs, $2, $4);"  Everything after the $$ = $1 in your example should be in the body of the method. This will make it simpler to debug your code in Visual Studio, since you can set a breakpoint at the entry to DoBinding, check that the types of the arguments are as you expected, and step through the code.

Of course you can set a breakpoint on the semantic action itself.  It will be one of the case branches in the DoAction method of the parser.  However the parser code is harder to understand because it has all of the translation of the symbols like $N.



Mar 29, 2012 at 10:24 AM

Very thanks.

I'm try to do a c#  parser to do a  , it has a new statment. like :

q =  new ArrayList();

q = new String('c', 100);

this will ok in also loaded dll. if not, it will make a error:

q= new Form();

q = new SqlConnection();

in two example  it will say can't find object in loaded assembles.

it will also fail when i try to use  assembly.Load :

q= Assembly.Load("mscorlib"); 

 // OK

q= Assembly.Load("System.Windows.Forms");

// error :  

System.Reflection.TargetInvocationException  :  call object has error.


     System.IO.FileNotFoundException :  can't load file or assembly "System.Windows.Forms" or dep.  can't find file.



Mar 30, 2012 at 4:42 AM

Sorry, it's my wrong.

I use .net 4.0 runtime. but i use gplex is 2.0 .  After recomplier all is ok.

very thank you.

your app are very useful to us.