Product, version and build: PowerShell Studio 2019 5.6.162
32 or 64 bit version of product: 64 bit
Operating system: Windows 10 1709 16299.1087
32 or 64 bit OS: 64 bit
I have created a PowerShell module which contains classes. I have then created a new forms project and intend to use the classes exposed in the module by adding the statement 'using module ModuleName'. This works fine when running via PowerShell Studio, however, when I package the script in to an executable and run it, I get the following error:
Line 5: At line:4 char:1
+ Using module 'ModuleName'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
A 'using' statement must appear before any other statements in a script.
I have tried placing the using statement in the Globals.ps1 file and also within the Startup.pss file without any success.
When exporting the script to the clipboard, I can see the first statement is the using one, so I guess the packager adds something else under the hood. Is it possible to get this working at all?
Consuming Module Classes in Forms Projects
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- DavidSunter
- Posts: 7
- Last visit: Tue Aug 15, 2023 3:05 am
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Consuming Module Classes in Forms Projects
It is probably caused by the new injection of code which was requested to set the $ScriptRoot variable.
Please stand by.
Please stand by.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Consuming Module Classes in Forms Projects
If you can, please you zip and upload a sample project that demonstrates the issue here:
https://sapien.com/support/upload/
Thank you,
https://sapien.com/support/upload/
Thank you,
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Consuming Module Classes in Forms Projects
Make a backup of the current PSBuild.exe in your PowerShell Studio install folder.
Replace with the file attached here and see if that helps.
Replace with the file attached here and see if that helps.
- Attachments
-
- PSBuild.zip
- (184.95 KiB) Downloaded 88 times
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.