1

I'm trying to debug a DLL loading issue with my application, and part of my process involves verifying the runtime dependencies for my assemblies. I wanted to check the bitness of my DLLs as well, just to make sure nothing is mismatched.

Anyhow, I am trying to use PowerShell to do this, but it's never able to find the DLL that I have specified. As a sanity check, I decided to try a .NET 4 assembly, and it still fails.

Please see the following image -- what am I doing wrong here?

enter image description here

I've seen suggestions elsewhere, like running PowerShell as admin and also using Set-ExecutionPolicy unrestricted. I've done those, without any success.

1
  • 1
    Don't use relative paths. Commented Oct 31, 2017 at 3:56

1 Answer 1

1

Before passing relative paths to .NET methods, execute the following, to ensure that .NET uses the same working directory as PowerShell (which is not the case by default, unfortunately):

[Environment]::CurrentDirectory = $PWD

Alternatively, prefix relative paths with $PWD to convert them to absolute ones; in your example:

[System.Reflection.Assembly]::GetAssemblyName("$PWD\System.Net.dll")
Sign up to request clarification or add additional context in comments.

2 Comments

As a note, some things don't like when dynamic variables are passed to them (modules in particular, not sure about .net static methods). I'd suggest $Path = "$PWD\System.Net.dll"; [type]::method($Path)
@TheIncorrigible1: The interpolating string is expanded before the .NET method ever sees it, so I don't think there's a problem here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.