Azure / Azure/azure-iot-protocol-gateway

Error: "System.IO.FileLoadException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe"

Open
#129 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
227
Forks
156
PR merge metrics
No merged PRs in 30d

Description

### Hi All,

I have an issue when trying to run a `EndToEndTests`.
Program builds with some warnings: e.g. `Found conflicts between different versions of "System.Runtime.CompilerServices.Unsafe" that
could not be resolved.`

### Logs after running a test:
```
Test Name: Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.BasicFunctionalityTest
Test FullName: Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.BasicFunctionalityTest
Test Source: C:\Users\Adam\projects\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\EndToEndTests.cs : line 181
Test Outcome: Failed
Test Duration: 0:00:06.538

Result StackTrace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.ClientScenarios.d__9.MoveNext() in C:\Users\Adam\projects\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\EndToEndTests.cs:line 521
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.ClientScenarios.d__4.MoveNext() in C:\Users\Adam\projects\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\EndToEndTests.cs:line 426
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.Azure.Devices.ProtocolGateway.Tests.Extensions.TaskExtensions.d__1.MoveNext() in C:\Users\Adam\projects\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\Extensions\TaskExtensions.cs:line 29
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.Azure.Devices.ProtocolGateway.Tests.EndToEndTests.d__26.MoveNext() in C:\Users\Adam\projects\azure-iot-protocol-gateway\test\ProtocolGateway.Tests\EndToEndTests.cs:line 276
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
----- Inner Stack Trace -----
at DotNetty.Common.Internal.PlatformDependent.CopyMemory(Byte[] src, Int32 srcIndex, Byte[] dst, Int32 dstIndex, Int32 length)
at DotNetty.Buffers.PooledHeapByteBuffer.SetBytes(Int32 index, Byte[] src, Int32 srcIndex, Int32 length)
at DotNetty.Buffers.AbstractByteBuffer.WriteBytes(Byte[] src, Int32 srcIndex, Int32 length)
at DotNetty.Buffers.AbstractByteBuffer.WriteBytes(Byte[] src)
at DotNetty.Codecs.Mqtt.MqttEncoder.EncodeConnectMessage(IByteBufferAllocator bufferAllocator, ConnectPacket packet, List`1 output)
at DotNetty.Codecs.Mqtt.MqttEncoder.DoEncode(IByteBufferAllocator bufferAllocator, Packet packet, List`1 output)
at DotNetty.Codecs.Mqtt.MqttEncoder.Encode(IChannelHandlerContext context, Packet message, List`1 output)
at DotNetty.Codecs.MessageToMessageEncoder`1.WriteAsync(IChannelHandlerContext ctx, Object msg)
Result Message:
DotNetty.Codecs.EncoderException : Exception of type 'DotNetty.Codecs.EncoderException' was thrown.
---- System.IO.FileLoadException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Result StandardOutput:
EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.Internal.Logging.InternalLoggerFactory] [message : Using EventSource as the default logging framework] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.8957245Z, ProcessId : 16088, ThreadId : 9748

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.Internal.Logging.InternalLoggerFactory] [message : Using EventSource as the default logging framework] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.8977193Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Transport.Channels.DefaultChannelId] [message : -Dio.netty.processId: 2054165 (auto-detected)] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9615476Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Transport.Channels.DefaultChannelId] [message : -Dio.netty.machineId: 4C:CC:6A:FF:FE:F4:1C:40 (auto-detected)] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9745134Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.Internal.PlatformDependent] [message : -Dio.netty.noPreferDirect: True] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9755104Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.numHeapArenas: 8] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9785031Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.numDirectArenas: 8] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9785031Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.pageSize: 8192] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9785031Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.maxOrder: 11] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9785031Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.chunkSize: 16777216] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9785031Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.tinyCacheSize: 512] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9785031Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.smallCacheSize: 256] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9785031Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.normalCacheSize: 64] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9785031Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.maxCachedBufferCapacity: 32768] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9785031Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.PooledByteBufferAllocator] [message : -Dio.netty.allocator.cacheTrimInterval: 8192] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9785031Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.ByteBufferUtil] [message : -Dio.netty.allocator.type: pooled] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9834887Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.ResourceLeakDetector] [message : -Dio.netty.leakDetection.level: simple] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9894732Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Common.ResourceLeakDetector] [message : -Dio.netty.leakDetection.targetRecords: 4] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:30.9894732Z, ProcessId : 16088, ThreadId : 17404

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34] HANDLER_ADDED] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.1167683Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34] REGISTERED] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.1187379Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34] CONNECT: 127.0.0.1:8883] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.1197355Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34, [::ffff:127.0.0.1]:57022 => [::ffff:127.0.0.1]:8883] ACTIVE] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.1257193Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : DotNetty.Buffers.AbstractByteBuffer] [message : -Dio.netty.buffer.bytebuf.checkAccessible: True] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.1307062Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34, [::ffff:127.0.0.1]:57022 => [::ffff:127.0.0.1]:8883] READ] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.1426970Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34, [::ffff:127.0.0.1]:57022 => [::ffff:127.0.0.1]:8883] WRITE: ConnectPacket[Type=CONNECT, QualityOfService=AtMostOnce, Duplicate=False, Retain=False]] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.1805732Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34, [::ffff:127.0.0.1]:57022 => [::ffff:127.0.0.1]:8883] FLUSH] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.2214640Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34, [::ffff:127.0.0.1]:57022 => [::ffff:127.0.0.1]:8883] RECEIVED_COMPLETE] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.2434055Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34, [::ffff:127.0.0.1]:57022 => [::ffff:127.0.0.1]:8883] READ] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.2434055Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34, [::ffff:127.0.0.1]:57022 => [::ffff:127.0.0.1]:8883] EXCEPTION: DotNetty.Codecs.DecoderException: Exception of type 'DotNetty.Codecs.DecoderException' was thrown. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at DotNetty.Common.Internal.PlatformDependent.CopyMemory(Byte[] src, Int32 srcIndex, Byte[] dst, Int32 dstIndex, Int32 length)
at DotNetty.Buffers.HeapArena.MemoryCopy(Byte[] src, Int32 srcOffset, Byte[] dst, Int32 dstOffset, Int32 length)
at DotNetty.Buffers.PoolArena`1.Reallocate(PooledByteBuffer`1 buf, Int32 newCapacity, Boolean freeOldMemory)
at DotNetty.Buffers.PooledByteBuffer`1.AdjustCapacity(Int32 newCapacity)
at DotNetty.Buffers.AbstractByteBuffer.EnsureWritable(Int32 minWritableBytes)
at DotNetty.Buffers.AbstractByteBuffer.WriteBytes(IByteBuffer src, Int32 srcIndex, Int32 length)
at DotNetty.Buffers.AbstractByteBuffer.WriteBytes(IByteBuffer src, Int32 length)
at DotNetty.Buffers.AbstractByteBuffer.WriteBytes(IByteBuffer src)
at DotNetty.Codecs.ByteToMessageDecoder.<>c.<.cctor>b__27_0(IByteBufferAllocator allocator, IByteBuffer cumulation, IByteBuffer input)
at DotNetty.Codecs.ByteToMessageDecoder.ChannelRead(IChannelHandlerContext context, Object message)
--- End of inner exception stack trace ---
at DotNetty.Codecs.ByteToMessageDecoder.ChannelRead(IChannelHandlerContext context, Object message)
at DotNetty.Transport.Channels.AbstractChannelHandlerContext.InvokeChannelRead(Object msg)] [info : DotNetty.Codecs.DecoderException: Exception of type 'DotNetty.Codecs.DecoderException' was thrown. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at DotNetty.Common.Internal.PlatformDependent.CopyMemory(Byte[] src, Int32 srcIndex, Byte[] dst, Int32 dstIndex, Int32 length)
at DotNetty.Buffers.HeapArena.MemoryCopy(Byte[] src, Int32 srcOffset, Byte[] dst, Int32 dstOffset, Int32 length)
at DotNetty.Buffers.PoolArena`1.Reallocate(PooledByteBuffer`1 buf, Int32 newCapacity, Boolean freeOldMemory)
at DotNetty.Buffers.PooledByteBuffer`1.AdjustCapacity(Int32 newCapacity)
at DotNetty.Buffers.AbstractByteBuffer.EnsureWritable(Int32 minWritableBytes)
at DotNetty.Buffers.AbstractByteBuffer.WriteBytes(IByteBuffer src, Int32 srcIndex, Int32 length)
at DotNetty.Buffers.AbstractByteBuffer.WriteBytes(IByteBuffer src, Int32 length)
at DotNetty.Buffers.AbstractByteBuffer.WriteBytes(IByteBuffer src)
at DotNetty.Codecs.ByteToMessageDecoder.<>c.<.cctor>b__27_0(IByteBufferAllocator allocator, IByteBuffer cumulation, IByteBuffer input)
at DotNetty.Codecs.ByteToMessageDecoder.ChannelRead(IChannelHandlerContext context, Object message)
--- End of inner exception stack trace ---
at DotNetty.Codecs.ByteToMessageDecoder.ChannelRead(IChannelHandlerContext context, Object message)
at DotNetty.Transport.Channels.AbstractChannelHandlerContext.InvokeChannelRead(Object msg)] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.2533775Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34, [::ffff:127.0.0.1]:57022 => [::ffff:127.0.0.1]:8883] RECEIVED_COMPLETE] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.2543753Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34, [::ffff:127.0.0.1]:57022 => [::ffff:127.0.0.1]:8883] READ] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.2543753Z, ProcessId : 16088, ThreadId : 14516

EventId : 2, Level : Verbose, Message : , Payload : [source : CLIENT] [message : [id: 0x79b8db34, [::ffff:127.0.0.1]:57022 => [::ffff:127.0.0.1]:8883] CLOSE] [info : ] , EventName : DebugInfo, Timestamp : 2019-01-15T15:46:31.2543753Z, ProcessId : 16088, ThreadId : 14516

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with test/ProtocolGateway.Tests/EndToEndTests.cs, especially BasicFunctionalityTest and the ConnectAsync stack locations, then inspect the project dependencies that produce the System.Runtime.CompilerServices.Unsafe version conflict. Done means the EndToEndTests run without the FileLoadException and the referenced assembly versions resolve consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.