I have a console application that uses EasyOpcClassic version 2018.2 5.53.405.1 for fetching OPC Alarms. I also use Avro Ipc version 1.8.3 (0.9.0.0) to perform some RPC calls to another server. When used together, this exception is thrown:
{"Could not load file or assembly 'OpcNetApi, Version=5.53.405.1, Culture=neutral, PublicKeyToken=6faddca41dacb409' or one of its dependencies. The system cannot find the file specified.":"OpcNetApi, Version=5.53.405.1, Culture=neutral, PublicKeyToken=6faddca41dacb409"}
{"Could not load file or assembly 'OpcNetApi, Version=5.53.405.1, Culture=neutral, PublicKeyToken=6faddca41dacb409' or one of its dependencies. The system cannot find the file specified.":"OpcNetApi, Version=5.53.405.1, Culture=neutral, PublicKeyToken=6faddca41dacb409"}
{"Could not load file or assembly 'OpcNetApi, Version=5.53.405.1, Culture=neutral, PublicKeyToken=6faddca41dacb409' or one of its dependencies. The system cannot find the file specified.":"OpcNetApi, Version=5.53.405.1, Culture=neutral, PublicKeyToken=6faddca41dacb409"}
The stacktrace is:
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Avro.Specific.ObjectCreator.FindType(String name, Boolean throwError)
at Avro.Specific.ObjectCreator.GetType(String name, Type schemaType)
at Avro.Specific.ObjectCreator.New(String name, Type schemaType)
at Avro.Specific.SpecificDefaultReader.ReadRecord(Object reuse, RecordSchema writerSchema, Schema readerSchema, Decoder dec)
at Avro.Generic.DefaultReader.Read(Object reuse, Schema writerSchema, Schema readerSchema, Decoder d)
at Avro.Generic.DefaultReader.Read[T](T reuse, Decoder decoder)
at Avro.ipc.Requestor.ReadHandshake(BinaryDecoder input)
at Avro.ipc.Requestor.TransceiverCallback`1.HandleResult(IList`1 result)
at Avro.ipc.Transceiver.Transceive(IList`1 request, ICallback`1 callback)
at Avro.ipc.Requestor.Request[T](RpcRequest request, ICallback`1 callback)
at Avro.ipc.Requestor.Request(String messageName, Object request)
at Avro.ipc.Specific.SpecificRequestor.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.AvroProtocolCallbackProxy.getData()
at MyApp.Core.Licensing.AvroManager.<>c__DisplayClass19_0.<.ctor>b__0(Object s)
at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.TimerQueueTimer.CallCallback()
at System.Threading.TimerQueueTimer.Fire()
at System.Threading.TimerQueue.FireNextTimers()
at System.Threading.TimerQueue.AppDomainTimerCallback()
More specifically, it happens when I call `Castle.Proxies.AvroProtocolCallbackProxy.getData()`.
Also, the code runs perfectly fine if I do not perform the above call. The call is an RPC request from an Avro client to an Avro Server.
The project uses .NET framework 4.6.1.
The strange bit is that Avro Ipc is unrelated to OPC, and I don't think QuickOpc packs OpcNetApi with itself.
Under the hood I can see that the assembly.GetTypes() call is being done on the assembly:
{OpcLabs.EasyOpcClassic, Version=5.53.405.1, Culture=neutral, PublicKeyToken=6faddca41dacb409}
And this is throwing the TypeLoadException