Matching the dependencies graph of SharpPcap and PacketDotNet
SharpPcap and PacketDotNet share System.Runtime.CompilerServices.Unsafe as a common dependency. But on Nugget.org, you can find they don't use the same version of this assembly. A solution is to do a binding redirect like explain here : https://nickcraver.com/blog/2020/02/11/binding-redirects/ But it would be great to avoid that by natively matching the dependencies versions.
What error are you getting?
Hi, This one (sorry it's partially in french). When trying to use a PacketDotNet method, it wants a 6.0.0.0 version, which is a newer version compared to the one that SharpPcap wants. Using the 6.0.0.0 and a binding redirect (.config file) fix it but it's not clean. I'm using the .NET Standard versions of the assemblies on Nugget.org. Thanks
Basically it means that System.Runtime.CompilerServices.Unsafe needs to be at version 6.0.0.0 for SharpPcap and for PacketDotNet. which is not the case by default without a binding redirect.
.NET 6 is out of support so it can't be the version being set, and System.Runtime.CompilerServices.Unsafe is not a dependency of SharpPcap to begin with in https://github.com/dotpcap/sharppcap/blob/master/SharpPcap/SharpPcap.csproj
6 is the version of the assembly not the version of the framework. System.Runtime.CompilerServices.Unsafe is a dependency of System.Memory, which itself is a dependency of SharpPcap. That's why I talked about the dependency graph in the title of the issue.
Seeing how the example projects compile just fine, I would need a sample project to reproduce the problem.
I guess Visual Studio manages the biding redirect by itself ? LabVIEW can't do that, so I have a .config file to force it, which is a burden.
<?xml version ="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="SharpPcap Assemblies" />
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Ok, if this is a LabVIEW specific problem, I don't see what I can change code wise to fix it.
You are free to open a PR with a fix.
Would it be possible to publish a version of SharpPcap on nugets.org which rely on the version of system.memory which rely on the same version of System.Runtime.CompilerServices.Unsafe used by PacketDotNet ?
Open PRs to upgrade all dependencies of sharppcap + packetnet to latest version.
Downgrading is no go.
Hi @kayoub5, is everything ok for this PR or you need something from me ?
After another round of thinking, I think this issue can be closed, because depedencies change all the time : it would be impossible for SharpPcap to have a new version each time a depedency changes beetween SharpPcap and PacketDotNet. However, it would be good to have SharpPcap available for .Net8 in the future (that's already the case for PacketDotNet).