Closed sbrl closed 5 years ago
Hi @sbrl. You'll want to put a sharppcap.dll.config file in place to map from wpcap to libpcap. Btw, are you using mono or dotnet on this platform? Dotnet doesn't have a way to do dll mapping at the moment so I've been considering adding runtime dll mapping but haven't had a need to use SharpPcap myself in a while so it hasn't gotten on the todo list yet.
Ah, I see. I copied across the sharppcap.dll.config
file from my old project and set it to Copy if Newer - and that seemed to fix it. I'm using Mono - I'm still very unsure about dotnet
and how it's different to (or better than?) Mono.
Dotnet is the Microsoft official cross-platform runtime vs. mono which was an unofficial one. Mono improvements are being folded into dotnet. Once dotnet can properly provide an api to map dlls I'll be adopting that for sharppcap to resolve this issue, although that may then become incompatible with mono...
I see. I'm not sure that Mono is past-tense yet though, as I'm still getting frequent updates and 73 pull requests were merged into Mono in the last week.
If the plan is to make this incompatible with Mono, perhaps a major version number at least would be appropriate? If not a separate package :thinking:
@sbrl I appreciate that feedback. Whatever solution is arrived at for dotnet we'll want to maintain mono compatibility. I'm not sure what that looks like at the moment though. If you have any ideas I'd be interested in knowing what you think.
I'm not entirely sure how dll mapping works, actually. I'm guessing that the .dll.config
file is the one that does the job, though. I find it hard to believe that dotnet
would cook up a solution to the issue that's incompatible with mono.
Does bundling that .dll.config
file I've got on Linux cause issues on Windows? I guess I'll have to do some testing. If not, then perhaps it can be included in the NuGet package? Again, I'm not sure how that works either.
@sbrl I’d accept a pr to add the .config file to the nuget package. I work with nuget so infrequently that it’s a few hours for what someone more familiar with nuget might take just a few minutes.
Not sure if this is the correct thread to add too, or if a new one should be created, so I apologize in advance. I'm getting the same error as above and I have included the .dll.config file mapping. I am actually using Unity 2018.2.15 which uses Mono and everything works fine in Windows. When I run for OSX though, I get the error above and have been stuck on this for a couple of days now. Any suggestions? I'm just trying to get a list of devices when the application loads.
<configuration>
<dllmap dll="wpcap" target="libpcap.dylib" os="osx" />
</configuration>
public static List<string> GetDevices()
{
var sNames = new List<string>();
foreach (var device in CaptureDeviceList.Instance)
{
var live = device as LibPcapLiveDevice;
sNames.Add(live.Interface.FriendlyName);
}
return sNames;
}
ERROR: wpcap at (wrapper managed-to-native) SharpPcap.LibPcap.LibPcapSafeNativeMethods.pcap_findalldevs(intptr&,System.Text.StringBuilder) at SharpPcap.LibPcap.LibPcapLiveDeviceList.GetDevices () [0x00017] in <505310bf735b4607871626bd2750b6a1>:0 at SharpPcap.LibPcap.LibPcapLiveDeviceList.Refresh () [0x00008] in <505310bf735b4607871626bd2750b6a1>:0 at SharpPcap.LibPcap.LibPcapLiveDeviceList..ctor () [0x0000b] in <505310bf735b4607871626bd2750b6a1>:0 at SharpPcap.LibPcap.LibPcapLiveDeviceList.get_Instance () [0x0000a] in <505310bf735b4607871626bd2750b6a1>:0 at SharpPcap.CaptureDeviceList..ctor () [0x0003b] in <505310bf735b4607871626bd2750b6a1>:0 at SharpPcap.CaptureDeviceList.get_Instance () [0x0000a] in <505310bf735b4607871626bd2750b6a1>:0 at Prism.Controllers.UIApplicationSettings.Initialize (Prism.Models.ApplicationConfiguration AppConfig) [0x00077] in <552486821c434d5cacd210e1a7c48db2>:0 at Prism.Scenes.SharedScene.Start () [0x000a2] in <552486821c434d5cacd210e1a7c48db2>:0
@brianjkennedy Did you ensure that it is copying said .dll.config
file to the output directory?
@sbrl It is not doing it by default so I manually have to copy it there but yes, I am placing it in the directory where the .dll resides.
@brianjkennedy Is the SharpPcap.dll
referenced correctly in your application?
You can configure it to do so by selecting it in your IDE, and changing the build action from "none" to "copy if newer".
@Fox4148 I would assume so since everything works correctly on Windows.
@sbrl I'm using Unity as my IDE which opens either mono develop or visual studio as the code IDE. I am using visual studio and have that set, but that doesn't seem to fix the issue.
try manually deleting bin/obj folder, maybe a dependency was broken with the importation, then rebuild
Looks like dotnet
is the implementation of .NET Core - which is mainly for ASP.NET web applications. Mono is still alive and well as your regular .NET Framework and runtime for cross-platform purposes. I've been experimenting with dotnet
for my University course this semester, and ironically it looks like Mono is more cross-platform and easier to sue that dotnet
........
@sbrl, that may be the case. I'd imagine mono would pull in as much of dotnet as possible and increase that going forward to converge the two implementation.
There is a pull request open now that supports windows and linux/Mac and shouldn't need sharppcap.dll.config for mono even. Would you mind trying it out to see how it works for you on mono?
Absolutely!
I've just cloned the repository and opened the solution file I found in the repository root in Monodevelop. After building, I ran it with the start button. I got this error:
Erm never mind! I just needed to run it with sudo
.
@sbrl where is that parameter 's'? I don't see it there, is that hidden under the popup? Maybe Console.ReadLine() returned null??
Nevermind - it looks like I was silly. I needed to run it with sudo
, and now it works fine:
Hi @sbrl. closing this out as you seem to have found the solution here. We've made some big library improvements for cross platform support thanks to another developer contribution. Please try newer nuget packages if you get a chance.
Hello again! I've found another issue.
In a different project to the one in my last issue (#33), I've just installed _SharpPcap - and I've hit upon an error - I'm attaching the stack trace to the bottom of this issue.
Looking around, I can't find a
sharppcap.dll.config
file anywhere.I would have thought that on Linux I wouldn't need
wpcap
?Stack Trace
System Details
uname -a
:Linux some_pc_name 4.14.69-1-lts #1 SMP Mon Sep 10 16:35:35 UTC 2018 x86_64 GNU/Linux