1
votes

I'm working on my custom CMS. I have the main application and modules. My problem is that whenever I load the view from my Module, the view cannot find the model assigned to that view.

CS0246: The type or namespace name 'EAccounting' could not be found (are you missing a using directive or an assembly reference?)

The view of that module is located in ~/Modules/EAccounting/Views/. I can call the module controller with no problem, also I can locate call the view from the controller with no problem, but the view itself cannot find the model from the loaded assemblies:

@model EAccounting.Models.Transaction

This is the code that loads the assemblies:

public class SafeDirectoryCatalog : ComposablePartCatalog
{
    private readonly AggregateCatalog _catalog;

    public SafeDirectoryCatalog(string directory)
    {
        var files = Directory.EnumerateFiles(directory, "*.dll", SearchOption.AllDirectories);

        _catalog = new AggregateCatalog();

        foreach (var file in files)
        {
            try
            {
                var asmCat = new AssemblyCatalog(file);

                //Force MEF to load the plugin and figure out if there are any exports
                // good assemblies will not throw the RTLE exception and can be added to the catalog
                if (asmCat.Parts.ToList().Count > 0)
                {
                    _catalog.Catalogs.Add(asmCat);
                }
            }
            catch (ReflectionTypeLoadException)
            {
            }
            catch (BadImageFormatException)
            {
            }
        }
    }
    public override IQueryable<ComposablePartDefinition> Parts
    {
        get { return _catalog.Parts; }
    }
}

I'm sure that is nothing wrong with the assembly loading. Also if I move my module assembly .dll to my main bin folder (~/bin/) it works fine, so the problem must be that the view only able to search for the assembly in the main/bin folder.

How can I configure my system so that the view can search the assembly from another folder? Note: The assembly is loaded at runtime tho.

1
I am having the same issue.. have you found any solution? - marsop

1 Answers

0
votes

Also your post is a few month old, I think following link could perhaps answer your question : http://shazwazza.com/post/Developing-a-plugin-framework-in-ASPNET-with-medium-trust

I hope this will help you.