c# - assembly attributes not being emitted by roslyn -
i'm generating assemblies using roslyn, signing them using sn.exe tool, called in generatesnk method, below. use snk keyfile desktopstrongnameprovider pass in compilation option.
var snk = generatesnk($"{assemblyname}_key{revision}.snk", $@"{assemblyname}\{revision}\"); var snkpaths = immutablearray.create<string>(snk); var snprovider = new desktopstrongnameprovider(snkpaths); csharpcompilation compilation = csharpcompilation.create( assemblyname, syntaxtrees: new[] { syntaxtree}, references:references, options:new csharpcompilationoptions( outputkind.dynamicallylinkedlibrary ,strongnameprovider:snprovider ) );
when try load assembly using:
assemblyloadcontext.default.loadfromassemblypath(assemblypath);
it works first time, when edit source code , make second version compile (using new strong name key sign with), while compilation succeeds, loading assembly using above code gives error:
system.io.fileloadexception: 'assembly same name loaded'
now usually, can load 2 versions of same assembly without issue, long both have different strong name keys. mean there problem way handling signing process?
here generatesnk method, reference:
public string generatesnk(string name,string subdir="") { processstartinfo startinfo = new processstartinfo(); startinfo.createnowindow = true; startinfo.useshellexecute = false; startinfo.filename = "\""+this._sntoolpath+"\""; var outputdir = this._keyfileoutputdir + subdir; directory.createdirectory(outputdir); startinfo.arguments = "-k \""+outputdir+name+"\""; using (var process = process.start(startinfo)) { process.waitforexit(); } return outputdir+name; }
the key files generated, don't know what's going on. maybe i'm supposed implement strongnameprovider rather using desktopstrongnameprovider?
Comments
Post a Comment