public MarshalCodeGenerator(string inputFile) { var assemblyResolver = new CustomAssemblyResolver(); assemblyDefinition = AssemblyDefinition.ReadAssembly(inputFile, new ReaderParameters { AssemblyResolver = assemblyResolver, ReadSymbols = true }); // TODO: Remove hardcoded relative paths assemblyResolver.Register(assemblyDefinition); assemblyResolver.AddSearchDirectory(Path.GetDirectoryName(assemblyDefinition.MainModule.FullyQualifiedName)); assemblyResolver.AddSearchDirectory(@"..\..\..\..\src\mcs\class\lib\net_4_5".Replace('\\', Path.DirectorySeparatorChar)); }
private static AssemblyDefinition LoadAssembly(string inputFile) { // Force PdbReader to be referenced typeof(Mono.Cecil.Pdb.PdbReader).ToString(); var assemblyResolver = new CustomAssemblyResolver(); // Check if there is a PDB var readPdb = File.Exists(System.IO.Path.ChangeExtension(inputFile, "pdb")); var assemblyDefinition = AssemblyDefinition.ReadAssembly(inputFile, new ReaderParameters { AssemblyResolver = assemblyResolver, ReadSymbols = readPdb }); // Register self to assembly resolver assemblyResolver.Register(assemblyDefinition); assemblyResolver.AddSearchDirectory(Path.GetDirectoryName(assemblyDefinition.MainModule.FullyQualifiedName)); assemblyResolver.AddSearchDirectory(@"..\..\..\..\src\mcs\class\lib\net_4_5"); return(assemblyDefinition); }