本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ToMetadataReference方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpCompilation.ToMetadataReference方法的具体用法?C# CSharpCompilation.ToMetadataReference怎么用?C# CSharpCompilation.ToMetadataReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.CSharpCompilation
的用法示例。
在下文中一共展示了CSharpCompilation.ToMetadataReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildAssembly
/// <summary>
/// Builds the assembly.
/// </summary>
protected virtual Assembly BuildAssembly(CSharpCompilation compilation)
{
using (var ms = new MemoryStream())
{
var result = compilation.Emit(ms);
if (result.Success)
{
var assembly = Assembly.Load(ms.ToArray());
assemblyCache.AddAssembly(assembly, compilation.ToMetadataReference());
return assembly;
}
else
{
throw new Exception("The compilation failed! This is most probably bug in the DotVVM framework.\r\n\r\n"
+ string.Join("\r\n", result.Diagnostics)
+ "\r\n\r\n" + compilation.SyntaxTrees[0].GetRoot().NormalizeWhitespace() + "\r\n\r\n"
+ "References: " + string.Join("\r\n", compilation.ReferencedAssemblyNames.Select(n => n.Name)));
}
}
}