Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly

1,126 views
Skip to first unread message

Tanakorn Leesatapornwongsa

unread,
Sep 23, 2019, 11:14:42 PM9/23/19
to mono-cecil
Hi,

I got this exception, AssemblyResolutionException when I try to write assembly back. Even with this simple code, it also fails

string path1 = "assembly1.dll";
string path2 = "copy1.dll";
AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(path1);
assembly
.Write(path2); // AssemblyResoultionException is thrown here

The problem is I don't have the assembly that Mono.Cecil wants to resolve so even if I give WriterParameters with DefaultAssemblyResolver, it doesn't help.

Is there any way to work around this? Or I am prohibited to write an assembly that using other assemblies that I don't have them with me?

Thank you,
Tanakorn L.

Tanakorn Leesatapornwongsa

unread,
Sep 26, 2019, 6:24:19 PM9/26/19
to mono-cecil
Here is the stack trace of the execution,

Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: '...'
   at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
   at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
   at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
   at Mono.Cecil.TypeReference.Resolve()
   at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
   at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)
   at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
   at Mono.Cecil.MetadataBuilder.AddParameter(UInt16 sequence, ParameterDefinition parameter, ParamTable table)
   at Mono.Cecil.MetadataBuilder.AddParameters(MethodDefinition method)
   at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
   at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
   at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
   at Mono.Cecil.MetadataBuilder.AddTypes()
   at Mono.Cecil.MetadataBuilder.BuildTypes()
   at Mono.Cecil.MetadataBuilder.BuildModule()
   at Mono.Cecil.MetadataBuilder.BuildMetadata()
   at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__2_0(MetadataBuilder builder, MetadataReader _)
   at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
   at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
   at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
   at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)

Sam McGraw

unread,
Oct 2, 2019, 11:57:50 AM10/2/19
to mono-...@googlegroups.com
Good day,

Not a 100% - I believe you are right "prohibited to write an assembly that using other assemblies that I don't have them with me"

Sam

--
--
--
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 mono-cecil+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mono-cecil/7acd1605-93b4-4875-8dd3-46c8a2f163d3%40googlegroups.com.

Sam McGraw

unread,
Oct 2, 2019, 11:57:50 AM10/2/19
to mono-...@googlegroups.com
Tanakorn,

This may-not help; as you have already stated the problem 'The problem is I don't have the assembly that Mono.Cecil wants to resolve so even if I give WriterParameters with DefaultAssemblyResolver, it doesn't' help.'

If Mono can not resolve an assembly - it will throw an error -- so this video is not the answer; however, it might create a thinking point for your about your problem and how you might resolve it: https://www.google.com/search?q=create+an+assembly+in+vs+2017&rlz=1C1GCEU_enUS844US844&oq=creat+an+asssebly+in+vs&aqs=chrome.1.69i57j33l4.10823j0j8&sourceid=chrome&ie=UTF-8

good luck;

Sam

--
--
--
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 mono-cecil+...@googlegroups.com.

Tanakorn Leesatapornwongsa

unread,
Oct 3, 2019, 1:15:28 PM10/3/19
to mono-cecil
Hi Sam,

Thank you for your reply. I will check it out.

On Wednesday, October 2, 2019 at 8:57:50 AM UTC-7, Sam McGraw wrote:
Tanakorn,

This may-not help; as you have already stated the problem 'The problem is I don't have the assembly that Mono.Cecil wants to resolve so even if I give WriterParameters with DefaultAssemblyResolver, it doesn't' help.'

If Mono can not resolve an assembly - it will throw an error -- so this video is not the answer; however, it might create a thinking point for your about your problem and how you might resolve it: https://www.google.com/search?q=create+an+assembly+in+vs+2017&rlz=1C1GCEU_enUS844US844&oq=creat+an+asssebly+in+vs&aqs=chrome.1.69i57j33l4.10823j0j8&sourceid=chrome&ie=UTF-8

good luck;

Sam

To unsubscribe from this group and stop receiving emails from it, send an email to mono-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages