Costura: An Unhandled Exception Occurred: Failed To Execute Weaver

This error occurs consistently in a medium-sized, multi-project VB.NET 4.5.2 VS 2017 solution. I have Costura (2.0.1 with Fody 3.0.3) working fine in a smaller C# project (with Obfusca obfuscation as well).

I installed Costura (using VS NuGet) into the two target projects. (And tried a reinstall after the two expected FodyWeavers.xml files failed to appear in the projects. I ended up creating them manually.)

Fody: An unhandled exception occurred:
Exception:
Failed to execute weaver E:\VS\Projects\ProjectName\ProjectName\packages\Costura.Fody.2.0.1\netclassicweaver\Costura.Fody.dll
Type:
System.Exception
StackTrace:
   at InnerWeaver.ExecuteWeavers()
   at InnerWeaver.Execute()
Source:
FodyIsolated
TargetSite:
Void ExecuteWeavers()
Could not find 'System.Void'.
Type:
Fody.WeavingException
StackTrace:
   at TypeCache.FindType(String typeName)
   at ModuleWeaver.FindMsCoreReferences()
   at ModuleWeaver.Execute()
   at InnerWeaver.ExecuteWeavers()
Source:
FodyHelpers
TargetSite:
Mono.Cecil.TypeDefinition FindType(System.String)

The two main projects are of different types and are in the solution together only because they share some common code; one is a class library/plug-in while the other is a Windows desktop app with similar functionality. The error is identical for each target project.

After the automatic/default “Copy Local” functionality failed, I tried setting individual assemblies for inclusion (which I’ve done in another project successfully, and prefer):

  <Costura>
    <IncludeAssemblies>
      Newtonsoft.Json
      ...
    </IncludeAssemblies>
  </Costura>

Same error. NOTE: I’m artificially just embedding a single assembly here; normally there would be several, including project assemblies such as Common, Api, etc.

I’ve hunted around the forums and Issues here to no avail.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 16 (5 by maintainers)

Most upvoted comments

To chime in - I just had this same issue and I think long file names was the problem for me as well. Had my repo many folders deep (copied from a backup of another computer) and copied it up many levels. Problem solved.

Quick fyi: Had same issue. Resolved by shortening the project name just a tad. The issue is from generated files (inside obj/debug/costura) having super long file names.

Example of one filename: DBE8B2FE9557110981412629C0D23C346A42A563.costura.system.runtime.interopservices.runtimeinformation.dll.compressed

PS. Great extension!