Question

Problem: So, my issue is that I have 3 .dll files I want to include in my software. However, whenever I transfer the .exe to another computer, it looks for my hard coded absolute path in my computer. I want the dlls to be included or embedded such that I can distribute it to others.

Setup:

I have done so by going to the solution explorer and doing Add->Exisiting Item, and add the three dlls into the solution explorer.

Then I went to each .dll's properties and changed them so that they are considered embedded resources. Like so:

Woo for visuals

Then I went to the references tab of the project property, and added a reference to the three dlls in my code. I originally had them in my /bin/ folder of my project, but I still had this problem. so I added them here in the same folder as my project.

enter image description here

Great, so I compile, copy to another computer, and get an exception (I threw it to a message box for ease) saying it can't find the dll and/or its dependencies. I even put a copy of the dll in the same .exe folder on the separate computer, but the same problem.

What I've Tried: So I tried messing around with the project file. But it looked ok to me. Here's a snippet:

 <ItemGroup>
<Reference Include="PcapDotNet.Base, Version=0.10.0.20588, Culture=neutral, PublicKeyToken=4b6f3e583145a652, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>.\PcapDotNet.Base.dll</HintPath>
</Reference>
<Reference Include="PcapDotNet.Core, Version=0.10.0.20632, Culture=neutral, PublicKeyToken=4b6f3e583145a652, processorArchitecture=x86">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>.\PcapDotNet.Core.dll</HintPath>
</Reference>
<Reference Include="PcapDotNet.Packets, Version=0.10.0.20603, Culture=neutral, PublicKeyToken=4b6f3e583145a652, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>.\PcapDotNet.Packets.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />

and later ...

 <ItemGroup>
<EmbeddedResource Include="PcapDotNet.Base.dll" />
<EmbeddedResource Include="PcapDotNet.Core.dll" />
<EmbeddedResource Include="PcapDotNet.Packets.dll" />
 </ItemGroup>

Question: So, why is it saying it can't find the dll? Where could it still be looking for it in the wrong place?

Thanks everyone!

Était-ce utile?

La solution

Thanks for the help guys! I found the solution was a problem with Pcap dot net (pcap.net). The issue was that the supporting computer didn't have the Microsoft Redistributable C++ package. It says that is needed on their website. I thought that was for development only, but turns out it is needed for running as well. I might try to include those dll's in the embedded resources as well to clean it up for the user.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top