Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 527277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:51:55+00:00 2026-05-13T08:51:55+00:00

When I run my script directly from the Powershell console it works. When I

  • 0

When I run my script directly from the Powershell console it works. When I run my script in PowerGUI and try instantiate an object, I get an error:

Exception calling “.ctor” with “3” argument(s): “Could not load file or assembly ‘MyLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=77f676cc8f85d94e’ or one of its dependencies. The system cannot find the file specified.”

If I put all of the needed DLLs in $PSHOME, the script will successfully run from the console but not PowerGUI. If I move the DLLs to a local directory and load the DLLs with reflection, the script will not run in PowerGUI nor the powershell console.

[reflection.assembly]::loadfile(‘c:\mylibs\mylib.dll’)

What do I need to do to get the script to run in PowerGUI? Ideally, I’d like the DLLs in a different directory than $PSHOME.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:51:55+00:00Added an answer on May 13, 2026 at 8:51 am

    You should be using [Assembly]::LoadFrom as opposed to LoadFile. LoadFile is intended for loading assemblies that cannot be loaded in the normal assembly loading context such as the case where you are trying to load two versions of the same assembly. It does not use the normal probing rules so that is why it doesn’t automatically load dependencies. Here’s an excerpt from the documentation for LoadFile.

    Use the LoadFile method to load and
    examine assemblies that have the same
    identity, but are located in different
    paths. LoadFile does not load files
    into the LoadFrom context, and does
    not resolve dependencies using the
    load path, as the LoadFrom method
    does. LoadFile is useful in this
    limited scenario because LoadFrom
    cannot be used to load assemblies that
    have the same identities but different
    paths; it will load only the first
    such assembly.

    If you are using PowerShell 2.0 you may wish to use Add-Type instead:

    Add-Type -Path c:\mylibs\mylib.dll
    

    And if all else fails, run Fuslogvw.exe to find out why binding fails.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 303k
  • Answers 303k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You're providing 6 parameters, but only 5 values in your… May 13, 2026 at 8:32 pm
  • Editorial Team
    Editorial Team added an answer The rules should be like this: RewriteRule ^print.php$ http://www.mynewsite.co.uk? [R=301,L]… May 13, 2026 at 8:32 pm
  • Editorial Team
    Editorial Team added an answer I solved this problem using canGoBack() and canGoforward(), we can… May 13, 2026 at 8:32 pm

Related Questions

When I call a Powershell script, how can I keep the called script from
I'm having some problems upgrading Python on my Mac. For my first attempt, I
On the Windows command line and cygwin bash I can execute the following without
I have a jar file named umar.jar in /root/umar/bin directory. I have a shell
I'm trying to figure out why the mail function in PHP fails when called

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.