is there away to access the dynamically compiled assemblies from the orchard api ?

Topics: Troubleshooting, Writing modules
Feb 26, 2013 at 6:12 PM
One of my modules which holds my entities is loaded in orchard through dynamic compilation.
In another module (which references my entities module) I would like to create instanses of an entity in a dynamic way by passing in the entity type as a string value to a method call, using reflection.

This works ok if i know the assembly name of my entities module i could call something like :
string fullyqualifiedtypename   ='EFDAL.Entity.WorkItem, MyAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
Type t = Type.GetType(fullyqualifiedtypename   , false, true);
Activator.CreateInstance(t);
But now since my entities module is dynamically compiled by orchard i cannot do it because i dont know the assembly name given by orchard via dynamic compilation in order to build the fullyqualifiedtypename.

Using the debugger the assembly name made by Orchard is called :

EFDAL.Entity.WorkItem, App_Web_fpqdyyuy, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

Its the fragment "App_Web_fpqdyyuy" which is assigned by orchard as the assembly name which i dont know how to find so i can build the fully qualified name.

Is there a way to actually find the assembly name Orchard has given to dynamically compiled assemblies in order to cover the scenario described ?
Thanks
Giannis
Coordinator
Feb 26, 2013 at 6:43 PM
Reference the project, not the dll.
Jun 9, 2013 at 1:33 AM
Edited Jun 9, 2013 at 1:34 AM
I guess your type contains a parameterless ctor. I have the problem with dynamic activating of my type which has ctor with parameters like this
public Applications(
            IRepository<SchemeRecord> schemeRepository,
            IRepository<RoundRecord> roundRepository,
            IOrchardServices services) {
            _schemeRepository = schemeRepository;
            _roundRepository = roundRepository;
            _services = services;
        }
It seems I should use one of overloaded versions of Activator.CreateInstance but I am not aware if it is possible to create an array of arguments in this case when we inject dependencies.
Any help would be greatly appreciated.
Jun 9, 2013 at 3:40 PM
Solved the problem. Just to archive the solution: all dependency injections happen in the caller and I create an array of arguments there
var args = new object[] {
                _schemeRepository,
                _roundRepository,
                _services
            };
Then I use the overloaded version
var o = Activator.CreateInstance(type, args);
and added SuppressDependency attribute to my type as
[OrchardSuppressDependency("xxx.Services.IRepository<SchemeRecord>")]
...