当前位置: 首页>>代码示例>>C#>>正文


C# AssemblyNode.GetRuntimeAssembly方法代码示例

本文整理汇总了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]);
     }
   }
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:58,代码来源:Compiler.cs


注:本文中的AssemblyNode.GetRuntimeAssembly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。