.net - How to use MEF and dlls embeded resources in a dll project c# -



.net - How to use MEF and dlls embeded resources in a dll project c# -

for of import project have utilize mef build big assembly. assembly must turn on web server.

my question how can load , add together embed dlls project using mef ? before have used approach works :

var catalog = new aggregatecatalog(); catalog.catalogs.add(new directorycatalog(@"r:\dnn\extensions", "*.dll")); var container = new compositioncontainer(catalog); seek { container.composeparts(this); } grab (compositionexception compositionexception) { console.writeline(compositionexception.tostring()); }

but solution dificult mantain ! can not update dlls in extansions folder when in use.

the way restart dnn cms or charge updated dlls in new folder extensionsbis.

i have find new solution compose project extarnal dlls. have seek solution embeded dlls :

var catalog = new aggregatecatalog(); var resourcenames = gettype().assembly.getmanifestresourcenames(); foreach (var resourcename in resourcenames) { using (var stream = gettype().assembly.getmanifestresourcestream(resourcename)) { if (stream == null) continue; var ba = new byte[(int)stream.length]; stream.read(ba, 0, (int)stream.length); catalog.catalogs.add(new assemblycatalog(assembly.load(ba))); } } var container = new compositioncontainer(catalog); seek { container.composeparts(this); } grab (compositionexception compositionexception) { console.writeline(compositionexception.tostring()); }

the dlls loaded , added in catalog, have no exception @ composition.

but, when seek execute exported functions or acces class @ runtime have exception "object reference not set instance of object".

the catalog.catalogs.count give rite number of charged dlls, mef composition seems fail somewhere.

is posible load mef dlls plugins way ? best practice utilize mef within dll ?

thanks help guys.

use filesystemwatcher class monitor folder plugins stored. configure event handler created event , load library using initial code block.

c# .net dll mef

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -