working with self made dlls in assembly

This topic contains 5 replies, has 2 voices, and was last updated by  wantto wantto 4 years, 7 months ago.

  • Author
  • #11468

    wantto wantto

    i created dll called myTools.dll, put it in the GAC (assembly), and i see it there.
    i want to load this dll and access it's static methods.
    i tried to do
    Add-Type -AssemblyName myTools;
    and get error that

    Add-Type : Cannot add type. The assembly 'myTools' could not be found.

    any idea?what do i miss?

  • #11473

    Dave Wyatt

    How did you add your assembly to the GAC? If Add-Type is failing, odds are that wasn't done properly. See this link.

  • #11478

    wantto wantto

    drag and drop to the assembly
    i accees it with no problem from web pages.

  • #11479

    wantto wantto

    when i do


    this works.
    can i some how access like this the static methods?

  • #11480

    Dave Wyatt

    I'm pretty sure you're not adding the assembly to the GAC properly if you just dragged and dropped a DLL into that location, but I'm not certain. Anyhow, if that call to Assembly.LoadFile works, then you should be able to load it this way with the Path parameter instead of AssemblyName:

    Add-Type -Path 'C:\Windows\assembly\GAC_MSIL\meTools\\myTools.dll'
  • #11534

    wantto wantto

    this way worked
    Get-ChildItem -recurse "C:\Windows\assembly\GAC_MSIL\myTools\\"|Where-Object {($_.Extension -EQ ".dll") -or ($_.Extension -eq ".exe")} | ForEach-Object { $AssemblyName=$_.FullName; Try {[Reflection.Assembly]::LoadFile($AssemblyName)} Catch{ "***ERROR*** Not .NET assembly: " + $AssemblyName}}

You must be logged in to reply to this topic.