本文整理汇总了C#中AssemblyNode.GetRuntimeAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyNode.GetRuntimeAssembly方法的具体用法?C# AssemblyNode.GetRuntimeAssembly怎么用?C# AssemblyNode.GetRuntimeAssembly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssemblyNode
的用法示例。
在下文中一共展示了AssemblyNode.GetRuntimeAssembly方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveOrLoadAssembly
public virtual void SaveOrLoadAssembly(AssemblyNode assem, CompilerParameters options, CompilerResults results, ErrorNodeList errorNodes){
if (assem == null) return;
AssemblyReferenceList arefs = assem.AssemblyReferences;
//TODO: give the error in the context of the member that made the reference
for (int i = 0, n = arefs == null ? 0 : arefs.Count; i < n; i++){
AssemblyReference aref = arefs[i];
if (aref == null || aref.Assembly == null) continue;
ArrayList metadataErrors = aref.Assembly.MetadataImportErrors;
if (metadataErrors == null) continue;
foreach (Exception mdErr in metadataErrors)
if (mdErr.Message.StartsWith("Assembly reference not resolved"))
results.Errors.Add(new CompilerError(aref.Assembly.Name+".dll", 0, 0, "0", mdErr.Message));
}
if (results.NativeCompilerReturnValue != 0) return; //TODO: allow option to override this
if (options.GenerateInMemory){
System.Security.Policy.Evidence evidence = options.Evidence;
CompilerOptions cOptions = options as CompilerOptions;
System.AppDomain targetDomain = cOptions == null ? null : cOptions.TargetAppDomain;
if (targetDomain == null) targetDomain = AppDomain.CurrentDomain;
for (int i = 0, n = arefs == null ? 0 : arefs.Count; i < n; i++){
AssemblyReference aref = arefs[i];
if (aref == null || aref.Assembly == null) continue;
aref.Assembly.GetRuntimeAssembly(evidence, targetDomain);
}
results.CompiledAssembly = assem.GetRuntimeAssembly(evidence, targetDomain);
}else{
ErrorNodeList errors = new ErrorNodeList(0);
string fileName = this.GetTargetFileName(options, errors);
this.AddResourcesAndIcons(assem, options, errors);
if (errors.Count == 0){
try{
assem.WriteModule(fileName, options);
}catch(KeyFileNotFoundException){
ErrorNode keyFileMissing = this.CreateErrorNode(Error.AssemblyKeyFileMissing, ((CompilerOptions)options).AssemblyKeyFile);
errors.Add(this.CreateErrorNode(Error.AssemblyCouldNotBeSigned, assem.Location, keyFileMissing.GetMessage()));
errorNodes.Add(errors[0]);
this.ProcessErrors(options, results, errors);
}catch(AssemblyCouldNotBeSignedException){
ErrorNode unknownCryptoFailure = this.CreateErrorNode(Error.UnknownCryptoFailure);
errors.Add(this.CreateErrorNode(Error.AssemblyCouldNotBeSigned, assem.Location, unknownCryptoFailure.GetMessage()));
errorNodes.Add(errors[0]);
this.ProcessErrors(options, results, errors);
}catch(Exception e){
errors.Add(this.CreateErrorNode(Error.InternalCompilerError, e.Message));
errorNodes.Add(errors[0]);
this.ProcessErrors(options, results, errors);
}
CompilerOptions coptions = options as CompilerOptions;
if (coptions != null && coptions.XMLDocFileName != null && coptions.XMLDocFileName.Length > 0)
assem.WriteDocumentation(new StreamWriter(coptions.XMLDocFileName));
results.PathToAssembly = fileName;
}else{
this.ProcessErrors(options, results, errors);
for (int i = 0, n = errors.Count; i < n; i++)
errorNodes.Add(errors[i]);
}
}
}