Lokad / ILPack

Serialize .NET Core assemblies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fail to serialize: Referenced assembly cannot be found

dmiller opened this issue · comments

The failure of Assembly.GetReferencedAssemblies is hinted at here:

https://github.com/Lokad/ILPack/blob/master/src/Metadata/AssemblyMetadata.cs#L67-L74

In my case, the call to CreateType throws from

https://github.com/Lokad/ILPack/blob/master/src/AssemblyGenerator.Types.cs#L111-114 the error

Referenced assembly cannot be found: System.Linq.Expressions, [...]

In this case, the type is a class A derived from an abstract class B that implements System.Dynamic.IDynamicMetaObjectProvider, which is indeed in System.Linq.Expressions. Assembly.GetReferencedAssemblies does not see this reference, leading ultimately to an exception being thrown from AssemblyMetadata.GetReferencedAssemblyForType(Type type).

@dmiller Thanks a lot for taking the time to report this problem. We don't resources to push to this project at the moment, but don't hesitate to submit if PR if you can.

I was able to work around the problem in my application by having class A explicitly implement the interface that was causing the problem. Rewriting Assembly.GetReferencesAssemblies seems like a tall order, but a quick scan of types to pick up some missed assemblies might be possible.

Two more error reports coming -- Understood that you don't have time to deal with them. Just for the record and in case I can create fixes.

@vermorel In fact, this problem was fixed in the scope of PR #123 and covered by tests in the scope of PR #124 so we can close it safely.