May I offer you this nugget:
class ScopedCecilAssemblyResolver : IDisposable
{
private DefaultAssemblyResolver _resolver;
private StringCollection _referencePaths;
public ScopedCecilAssemblyResolver( StringCollection
referencePaths, DefaultAssemblyResolver resolver )
{
if ( referencePaths == null )
throw new ArgumentNullException( "referencePaths" );
if ( resolver == null )
throw new ArgumentNullException( "resolver" );
_referencePaths = referencePaths;
_resolver = resolver;
EnlistDirectoriesInCecilsGlobalResolver();
}
private void EnlistDirectoriesInCecilsGlobalResolver()
{
foreach ( string item in _referencePaths )
_resolver.AddSearchDirectory( item );
}
private void RemoveDirectoriesFromCecilsGlobalResolver()
{
foreach ( string item in _referencePaths )
_resolver.RemoveSearchDirectory( item );
}
public void Dispose()
{
RemoveDirectoriesFromCecilsGlobalResolver();
}
}
On Mon, Dec 6, 2010 at 3:23 PM, Timwi <[email protected]> wrote:
> Currently Mono.Cecil searches for dependencies (during .Resolve()) in
> the current directory, which is sub-optimal because that directory is
> usually random and unconnected to the input assembly.
>
> It would probably be more useful if Mono.Cecil searched in the same
> directory that the input assembly was in. Do you think this would be
> doable?
>
> Of course, it would also be nice to have a way to specify explicit
> search paths, but that’s just an idea for a new feature :)
>
> --
> --
> mono-cecil
--
--
mono-cecil