New classes added to assembly not found through reflection

We have a rule processing system where each rule is represented by a class, and all the rules implement a common interface. Sometimes we add a rule (class) to the assembly, but when this rule appears for processing, the system cannot find this class. The code we use to run the rules is as follows.

private void runClass(string dllName, string className, string methodName, string ruleNamespace)
{
    Assembly _Assemblies = Assembly.LoadFrom(dllName);

    Type _Type = null;
    string nameSpace = _Assemblies.ManifestModule.Name.Substring(0, _Assemblies.ManifestModule.Name.ToLower().IndexOf(".dll"));
    if (ruleNamespace.Trim() != "")
        nameSpace = nameSpace + "." + ruleNamespace;
    _Type = _Assemblies.GetType(nameSpace + "." + className);
    if (_Type == null)
        throw new Exception("Cannot find class " + className + " in " +     nameSpace + ".");

    IRule rule = (IRule)Activator.CreateInstance(_Type);
    rule.Process();
}

I tried to clean the assembly, rebuild from scratch, reload, wipe the DLL manually and rebuild, as well as several other things that I can’t remember right now. The bizarre part is that there can be 50 rules in the assembly, and 48 of them are found, but two are not, and two that are not found are those that were just added. Can anyone think of what might cause this?

: , , . : dev QA dev. - , , aspnet_wp.exe, . , , , QA -, ; , . , , , , , .:)

+3
2

, 1 3 .

  • .

  • .

  • , /.


, , №3.


UPDATE
: , .

, , , . VS , , .

, , . , - VS ( ) , GAC . - .

, , DLL .

+2

, , , - Assembly.LoadFrom, , .

LoadFile. . .

, . , , , dllPath Reflector ( :-) , .

, , .

+1

Source: https://habr.com/ru/post/1793892/


All Articles