Giter VIP home page Giter VIP logo

Comments (3)

John0King avatar John0King commented on May 25, 2024

Can this library work as Plugin Loader

yes, but you may want to use DotnetCorePlugins because this project is in slow development and for reseach purpose currently (no officol release on nuget.org)

but this have bug in razor that your library solves

well, there are only two ways to acrchve plugins, 1). Assembly.Load and use MemeoryStream or byte[] 2) AssemblyLoadContext aka ALC. the problem that razor happed is that the razor is load to Default ALC in "hard code" way (ps: .net 6 + Source Generator should fixed this because now the razor files are generat .g.cs in your project obj folder and there are no additional assembly need to be load).
and (for below .net 6 ) this project fix it in a very simple way , it add a fallback method to the default ALC and forward it to the plugin ALC.

// razor bug fix
AssemblyLoadContext.Default.Resolving += (alc, asbn) =>
{
return AssemblyLoadContext.All.OfType<PluginAssemblyLoadContext>()
.Where(x => x.PluginInfo.PluginName.Equals(asbn.Name, StringComparison.OrdinalIgnoreCase))
.FirstOrDefault()?.LoadFromAssemblyName(asbn);
//if (AssemblyLoadContext.CurrentContextualReflectionContext == null)
//{
// return null;
//}
//if (AssemblyLoadContext.CurrentContextualReflectionContext == alc)
//{
// return null;
//}
//if (dic.TryGetValue(asbn.FullName, out var c))
//{
// if (c > 0)
// {
// return null;
// }
//}
//if (dic.ContainsKey(asbn.FullName))
//{
// dic[asbn.FullName] = dic[asbn.FullName] + 1;
//}
//else
//{
// dic[asbn.FullName] = 0;
//}
//return AssemblyLoadContext.CurrentContextualReflectionContext.LoadFromAssemblyName(asbn);
};
app.UseSubAppModules("/m");

and that means you can not make a razor dll's assembly name as same as other plugins (because the way that razor add to Default ALC is not compatiable with the "Plugin architecture" )

from lazyman.modularloader.

John0King avatar John0King commented on May 25, 2024

be notice that unloadable ALC have many limit as #1 meation ,
for example :

  • unloadable ALC must not use dynamic proxy
  • all asp.net core assembly must in "plugin host"
  • only work with "framework dependend publish" (all because the 2nd issue, you must very careful to not add any host used asembly in your plugin, otherwise the Type mismatch as I meation in dotnet/runtime#37576)

and thats why this project no active develop.

from lazyman.modularloader.

aloksharma1 avatar aloksharma1 commented on May 25, 2024

ok, so i will try to do this in net 6 but i am also ready to wait till net 7 if that's going to solve these issues that you have pointed out.
i am very careful about point 2 as all development follow one common project as reference assembly holder+host & plugin folders only use specific refernces when/if required and not available in main project.

from lazyman.modularloader.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.