Imported Module not working in *.exe file

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
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.
This topic is 6 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
GHIsolierung
Posts: 62
Last visit: Tue Nov 02, 2021 12:46 am

Imported Module not working in *.exe file

Post by GHIsolierung »

Version PS Studion 2017 v 5.4.141 on Windows 10 x64 latest

Hello
I have similar problems as in this topic
viewtopic.php?f=21&t=8876&start=10

The module Bits-Transfer starts without problem when I start my application from Powershell Studio, even if I export it to a * .ps1 file.

If I create an * .exe file from it, the module is not loaded.

* Loading the module in the 'global section' did not work

Error message from the console is:
'Import module could not load file or assembly. Microsoft.BackgroundintelligentTransfer ......, dll or one of its dependencies. A dynamic link library initialization routine failed .... '

The settings are: V5 - 64bit
Compiled (or how to call it in PS Studio), converting to an exe file has the setting:
'Script Engine: V3 host (Windows Forms), no config.file'

*.exe file tested on Windows 10, Server 2012R2

Best regards
User avatar
Alexander Riedel
Posts: 8489
Last visit: Thu Apr 18, 2024 1:15 pm
Answers: 20
Been upvoted: 37 times

Re: Imported Module not working in *.exe file

Post by Alexander Riedel »

Please do not post technical questions in the "Customer Service" section. Always post in the relevant forum section and provide the details requested. Please note that "latest" for Windows is not a valid version number as it can change between posting and reading this and it might be different for different geographic locations.

As the other solutions for this problem point out, the issue stems from mixing runtime versions. Microsoft does not always update binary modules to the latest runtime version.
This is where you need to use the config file the build process normally generates for you. By what you posted, you turned that off. Is there any specific reason for doing so?
Try turning this back on and see if that solves your problem.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
GHIsolierung
Posts: 62
Last visit: Tue Nov 02, 2021 12:46 am

Re: Imported Module not working in *.exe file

Post by GHIsolierung »

This has solved the problem.
The reason was that I did not want another file to be generated. I just want to have a single * .exe file.

Is it not possible to embed into the * .exe file?
User avatar
Alexander Riedel
Posts: 8489
Last visit: Thu Apr 18, 2024 1:15 pm
Answers: 20
Been upvoted: 37 times

Re: Imported Module not working in *.exe file

Post by Alexander Riedel »

As far as I know, .config files which contain startup information to support different .NET runtime versions must be outside.
Microsoft arranged for it this way. Any particular reason why this is a problem? Most .NET applications have these files.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
GHIsolierung
Posts: 62
Last visit: Tue Nov 02, 2021 12:46 am

Re: Imported Module not working in *.exe file

Post by GHIsolierung »

Honestly, it just bothers me.
I am writing only mini-applications, for example an extended Active Directory search or a Hyper-V configuration program. I just want to have an exe in a corresponding directory.
It's more of an optical thing.

Can I influence this within my code, that this file is not necessary? So far, I have never created this file. Only in this application where I had to load a commandlet do these problems occur

Many thanks for your help
User avatar
Alexander Riedel
Posts: 8489
Last visit: Thu Apr 18, 2024 1:15 pm
Answers: 20
Been upvoted: 37 times

Re: Imported Module not working in *.exe file

Post by Alexander Riedel »

So OCD :D ? Jokes aside, the .config files are necessary if you mix assemblies compiled against different runtimes. You can go to the vendor of the module or assembly and ask them to update their stuff, but then you will have to distribute those along with your app.
Put all you executables in a single \bin folder and have single shortcuts to them in your folder structure.
Then you only have a single file and you don't see the "mess" :D

But in all honesty, as your apps get more complex your will get multiple files. config files. settings files. additional sub tools. etc.
So get used to it :D
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
GHIsolierung
Posts: 62
Last visit: Tue Nov 02, 2021 12:46 am

[solved]Imported Module not working in *.exe file

Post by GHIsolierung »

ok and alright then.

Thank you for your help and for explaining it to me.
This topic is 6 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.