Skip to content

Is there a way to resolve a type from the executing assembly in dotnetfiddle environment #887

Answered by adrianoc
Serg046 asked this question in Q&A
Discussion options

You must be logged in to vote

That is strange.

One workaround (really ugly) is to pass an assembly resolver that returns that assembly:

#define TEST
using System.IO;
using System;

var readerParams = new Mono.Cecil.ReaderParameters();

var resolver = new Mono.Cecil.DefaultAssemblyResolver();
readerParams.AssemblyResolver = resolver;

#if TEST
resolver.ResolveFailure += (sender, args) => 
{
	return Mono.Cecil.AssemblyDefinition.ReadAssembly(typeof(Program).Assembly.Location);
};
#endif

var files = Directory.GetFiles(Path.GetDirectoryName(typeof(Program).Assembly.Location));
foreach(var file in files)
	Console.WriteLine(file);

#if !TEST
System.Console.WriteLine(System.IO.Path.GetDirectoryName(typeof(Program).Assembly.L…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Serg046
Comment options

@adrianoc
Comment options

@Serg046
Comment options

@Serg046
Comment options

Answer selected by Serg046
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants