0

I have made a C# Class Library that has some NuGet packages installed in it, like Azure.Core.

When the library has been compiled, I get my library as a MyLibrary.dll which is all fine. The only files that are in the output folder is the MyLibrary.dll, MyLibaby.deps.json and MyLibrary.pdb - nothing else.

Now I need to load this in Powershell by using:

Add-Type -Path "C:\Temp\MyLibrary.dll"

And this adds it fine and I can see my methods by using the Get-Member.

When the code then starts running, I get an error saying:

'Azure.Core, Version=1.37.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'. The system cannot find the file specified.

Have I done something wrong with the way I have done my class library or am I doing the Powershell bit wrong? As I mentioned, I don't have any more .dll files other than MyLibrary.dll

The Class Library was made in .NET Core 7.0, if that info is needed

11
  • "When the library has been compiled" how did you do that? Just compile from the CLI or Visual Studio? Did you publish it?
    – gunr2171
    Commented Mar 26 at 13:14
  • I complied it via Visual Studio. I have not published it, as it is only going to be used for internal tools
    – wads
    Commented Mar 26 at 13:16
  • 4
    If you publish it, the output directory should have all the dependent DLL files needed for the application to run.
    – gunr2171
    Commented Mar 26 at 13:17
  • Ahh, thank you! That did the trick! Was not aware of this :) Thank you!
    – wads
    Commented Mar 26 at 13:22
  • @wads you can also avoid this headache altogether by enabling "Produce single file" in your publish settings so that the dependents get bundled alongside your DLL
    – TP95
    Commented Mar 26 at 13:42

0

Browse other questions tagged or ask your own question.