Skip to content

add-type A namespace cannot directly contain members such as fields or methods #14

@yoke88

Description

@yoke88

when using powershell core to add-type like this:

$modulepath= Resolve-Path -path "$PSScriptRoot\lib\netstandard1.3\Rijndael256.dll"

add-type $modulepath

function Encrypt-Rijndael256{
    param(
        $key,
        $plaintext
    )

    return [Rijndael256.Rijndael]::Encrypt($plaintext,$key,256)
}

function Decrypt-Rijndael256{
    param(
        $key,
        $encryptText
        
    )
    return [Rijndael256.Rijndael]::Decrypt($encryptText,$key,256)
}

### i always got error like this.
add-type : (1) : Type or namespace definition, or end-of-file expected
(1) : >>> /home/yoke/Documents/PSPHPIPAM/functions/lib/netstandard1.3/Rijndael256.dll
At /home/yoke/Documents/PSPHPIPAM/functions/Rijndael256.core.ps1:3 char:1
+ add-type $modulepath
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand

maybe the below link can show what's wrong there
here

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions