Using AvroConvert from a .Net Framework application
Discussed in https://github.com/AdrianStrugala/AvroConvert/discussions/99
Originally posted by ombedko March 2, 2023 Im trying to use AvroConvert from inside a .Net Framework applicaiton (tried 4.6.1, 4.7.1, 4.7.2 4.8 v, + others). I buildt my AvroConvert dependant classes into a .Net Standard 2.0 class library, which I then tried to link to a simple console app. It works fine if the Console app is compiled for .net core 3.1 but not for .Net Framework. The first time I try to access any Avro functionality I get an exception bc "SolTechnology.Avro" is not found:
System.TypeInitializationException HResult=0x80131534 Message=The type initializer for 'LoggingNodeLib.Data.Signals.SignalExtensions' threw an exception. Source=NPAServer StackTrace: at NamedPipeAvroServer.NPAServer.Connect() in D:\BitBucket\kk-logging-node\NPAServer\NPAServer.cs:line 46 at NPAServerSandbox.Program.Main(String[] args) in D:\BitBucket\kk-logging-node\NPAServerSandbox\Program.cs:line 13
This exception was originally thrown at this call stack:
Inner Exception 1: FileNotFoundException: Could not load file or assembly 'SolTechnology.Avro, Version=3.3.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
The assembly is located where it should be, so I guess this is a version/compaitbility issue. Is it perhaps not posisble to do what Im trying to do?
PS: The reason Im stuck using .Net framework us bc of LabView compaitbility, which seems to only support .net framework and not core/standard/.net6/7 yet.
I can confirm, that there is some problem with running the .NET Framework host. For me, I am getting an exception:
HResult=0x80131534
Message=The type initializer for 'SolTechnology.Avro.AvroObjectServices.BuildSchema.ReflectionSchemaBuilder' threw an exception.
Source=SolTechnology.Avro
StackTrace:
at SolTechnology.Avro.AvroObjectServices.BuildSchema.ReflectionSchemaBuilder..ctor(AvroSerializerSettings settings) in E:\workspace\AvroConvert\src\AvroConvert\AvroObjectServices\BuildSchema\ReflectionSchemaBuilder.cs:line 87
at SolTechnology.Avro.AvroConvert.GenerateSchema(Type type) in E:\workspace\AvroConvert\src\AvroConvert\AvroConvert.GenerateSchema.cs:line 30
at ConsoleApp1.Program.Main(String[] args) in E:\workspace\AvroConvert\ConsoleApp1\Program.cs:line 14
This exception was originally thrown at this call stack:
Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'Portable.System.DateTimeOnly, Version=6.0.3.3, Culture=neutral, PublicKeyToken=16fb7a27ac3b9689' or one of its dependencies. The system cannot find the file specified.
Might be connected to nuget source, not sure though.
If I reference Portable.System.DateTimeOnly nuget package directly from the host .NET Framework app, the AvroConvert is working. It seems like the way how the package is configured does not enforce the installation of dependent nuget packages.
I am really not sure how to resolve this problem, if you have any suggestions, I am open to them.