The exception tells you that in order to write your assembly, Cecil needs
to read OtherDLL.
This happens when there's a metadata element that requires to read the
definition of a type in another assembly.
The solution is to pass an assembly resolver when reading the assembly that
knows how to resolve OtherDLL.
It could look like this:
var resolver = new DefaultAssemblyResolver();
resolver.AddSearchDirectory("C:\path\to\directory\which\contains\other\");
var assembly = AssemblyDefinitiob.ReadAssembly(fileName, new
ReaderParameters { AssemblyResolver = resolver });
Jb
On Tue, May 31, 2016 at 8:44 PM, Yang Zhang <[email protected]>
wrote:
> Hi,
>
> I am working on edit existing string/icon resource in assembly. I use
> mono.cecil to parse, edit the resource and save. Almost all the localized
> resource files work fine, but only the English original resource file does
> not work. The English project contains core logic code and references
> other dlls (OtherDLL.dll), this may cause exceptions when using mono.cecil,
> the test code and exception is below.
>
> AssemblyDefinition assemblyDefinition =
> AssemblyDefinition.ReadAssembly(resourceFileName);// Some code
> assemblyDefinition.Write(newFileName); // This will cause exception: "Failed
> to resolve assembly: 'OtherDLL, Version=10.1.1.1, Culture=neutral,
> PublicKeyToken=null'
>
>
> The English dll is TestDll.dll under deployment directory, and other
> localized resource dlls are TestDll.resources.dll under localized
> directory, like /de/TestDll.resources.dll and /zh-CN/TestDll.resources.dll.
> (other localized resource files could be well parse and save, but English
> resource file failed.)
>
> So how could I fix the issues? If it is the limitation or bug, could we
> use another walk around method to achieve the goal?
>
> Thanks in advance,
> Yang
>
> --
> --
> --
> mono-cecil
> ---
> You received this message because you are subscribed to the Google Groups
> "mono-cecil" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
--
--
mono-cecil
---
You received this message because you are subscribed to the Google Groups
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.