Using a type from a loaded assembly with namespace

51 views
Skip to first unread message

stephen...@gmail.com

unread,
May 8, 2013, 10:41:07 AM5/8/13
to cs-s...@googlegroups.com
Hi,
 
I have an assembly "ChessingCore" that includes types such as Int2D.
I have an application "Chessing" that makes use of this assembly and these types; this obviously works fine.
 
But now I want to be able to use Int2D's in scripts called by Chessing. I just can't get this to work. Here is an example script:
 

using System;
using ChessingCore;

namespace ChessingGame
{
   public class Board
   {
      Int2D _size;
      History _history;
      // ...rest of code
   }
}

This script fails because it claims the namespace "ChessingCore" is not defined anywhere. Of course ChessingCore namespace is defined and used by all types in the ChessingCore assembly. Is this the issue here; to reference separate assemblies do I need to remove the namespace from my types?

NB: I've tried removing the "using ChessingCore;" line -- it then fails to resolve Int2D. Manually referencing ChessingCore.dll either as an argument to CSScript.Load or as a //css_ref in the script makes no apparent difference.

 

 

 

 

 

 

 

stephen...@gmail.com

unread,
May 8, 2013, 3:00:10 PM5/8/13
to cs-s...@googlegroups.com, stephen...@gmail.com
Whoops. I'd just missed a basic part of the API.

Basically my host code looked like this:

AsmHelper helper = new AsmHelper(CSScript.Load("board.cs"));
_board = helper.CreateObject("ChessingGame.Board").TryAlignToInterface<IBoard>();

All that I needed to do was use the argument true to TryAlignToInterface (= useAppDomainAssemblies).

:headslap:

Oleg Shilo

unread,
May 9, 2013, 8:46:31 AM5/9/13
to cs-s...@googlegroups.com
I also missed something. Your second post :o)

Anyway, please find the code sample for your case: https://dl.dropboxusercontent.com/u/2192462/stephen.holtom/stephen.holtom.7z

Oleg 


Reply all
Reply to author
Forward
0 new messages