Quantcast
Channel: SAPIEN Forums
Viewing all articles
Browse latest Browse all 546

PowerShell Studio • Add-Type error in powershell core v7 package

$
0
0
Product: PowerShell Studio 2024 (64 Bit)
Build: v5.8.237
OS: Windows 10.0.14393
PS Version: 5.1.14393.0, 7.4.1

Hello,

I have an simple windows form project that contains following lines in global.ps1

$c1 = '[DllImport("aasupport.dll")] public static extern long CreateItheonEventWrapper(long DebugLevel,string CEParams,ref IntPtr pErrMsg,ref long ErrLen)'
Add-Type -MemberDefInition "$c1;" -name NativeMethods -namespace aasupport

Using powershell core 7.4.1, when I run the app via Run button app works fine, powershell-core windows logs records this event:

CommandInvocation(Add-Type): "Add-Type"
ParameterBinding(Add-Type): name="MemberDefinition"; value="[DllImport("aasupport.dll")] public static extern long CreateItheonEventWrapper(long DebugLevel,string CEParams,ref IntPtr pErrMsg,ref long ErrLen);"
ParameterBinding(Add-Type): name="Name"; value="NativeMethods"
ParameterBinding(Add-Type): name="Namespace"; value="aasupport"

Context:
Severity = Informational
Host Name = PrimalScriptHostImplementation
Host Version = 4.0.0.0
Host ID = 02bc4779-f92c-4412-a647-5a884e6133ef
Host Application = C:\Program Files\SAPIEN Technologies, Inc\PowerShell Studio 2024\Debugger64\scriptdriver64.exe -noprofile -V7 -p 59693 -d C:\Users\mikec\Documents\SAPIEN\PowerShell Studio\Projects\AATestForm -e PoshHostSTA -s C:\Users\mikec\Documents\SAPIEN\PowerShell Studio\Projects\AATestForm\AATestForm.Run.ps1
Engine Version = 7.4.1
Runspace ID = 6aa3d376-afcd-4cda-94c5-62b47b3ec669
Pipeline ID = 3
Command Name = Add-Type
Command Type = Cmdlet
Script Name = C:\Users\mikec\Documents\SAPIEN\PowerShell Studio\Projects\AATestForm\AATestForm.Run.ps1
Command Path =
Sequence Number = 11
User = LAB\mikec
Connected User =
Shell ID = Microsoft.PowerShell


Using powershell core 7.4.1, when I convert into an exe I get the following error in the Windows powershell-core event log and app does not run, I get "Could not find a part of the path" error.

CommandInvocation(Add-Type): "Add-Type"
ParameterBinding(Add-Type): name="MemberDefinition"; value="[DllImport("aasupport.dll")] public static extern long CreateItheonEventWrapper(long DebugLevel,string CEParams,ref IntPtr pErrMsg,ref long ErrLen);"
ParameterBinding(Add-Type): name="Name"; value="NativeMethods"
ParameterBinding(Add-Type): name="Namespace"; value="aasupport"
TerminatingError(Add-Type): "Could not find a part of the path 'C:\Users\mikec\Documents\SAPIEN\PowerShell Studio\Projects\AATestForm\bin\x64\AATestForm\ref'."

Context:
Severity = Informational
Host Name = PrimalScriptHostImplementation
Host Version = 5.0.0.0
Host ID = 3007647f-5007-499b-9b36-92862805c85b
Host Application = C:\Users\mikec\Documents\SAPIEN\PowerShell Studio\Projects\AATestForm\bin\x64\AATestForm\SAPIEN.PoshCoreHostWin.dll
Engine Version = 7.4.1
Runspace ID = de877feb-215a-4d29-8b6e-6c4d043b9d13
Pipeline ID = 2
Command Name = Add-Type
Command Type = Cmdlet
Script Name =
Command Path =
Sequence Number = 11
User = LAB\mikec
Connected User =
Shell ID = Microsoft.PowerShell


Changing back from Powershell7 to Powershell5 exe works fine.

Please advise. Happy to send you a test project to reproduce error.

thanks
Mike

Statistics: Posted by mike_cuff — Wed Feb 14, 2024 5:14 am



Viewing all articles
Browse latest Browse all 546

Trending Articles