ch-robinson / dotnet-avro

An Avro implementation for .NET
https://engineering.chrobinson.com/dotnet-avro/
MIT License
134 stars 49 forks source link

Could not load file or assembly System.ServiceModel.Primitives.dll #227

Closed JohnLeyva closed 2 years ago

JohnLeyva commented 2 years ago

When using

dotnet avro create --type $type --assembly $dll

For a type like the following

    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.0.2")]
    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    [System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
    public partial class Request
    {  
       ...
    }

I get

Could not load file or assembly

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.9.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

This happens even if I copy the assembly System.ServiceModel.Primitives.dll next to $dll

dotnet avro create works with other types that do not use MessageContractAttribute.

dstelljes commented 2 years ago

dotnet avro create doesn’t attempt to load any assemblies that aren’t specified with --assembly. To get this to work, you should be able to explicitly pull in System.ServiceModel.Primitives with another --assembly:

dotnet avro create --type $type --assembly $dll --assembly System.ServiceModel.Primitives.dll