Code no longer works when packaged as an exe (but did used to, and hasn't changed)

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 1 year and 1 month 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.
rbutterworth
Posts: 6
Last visit: Thu Oct 05, 2023 8:13 am

Code no longer works when packaged as an exe (but did used to, and hasn't changed)

Post by rbutterworth »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build:5.8.217.0
Operating system: Windows 11
PowerShell version(s):Powershell 5.0

*** Please add details and screenshots as needed below. ***

I have code that logs into a Dynamics CRM instance and then presents a form to make changes to CRM data.

The make the XRM tooling work, I had to move the login process to before the form initiation, and it worked fine, but in the IDE and when packaged as an EXE - I've deployed it to the users and it works for them with no issues.

I came back to the code this week to make some changes and to fix a bug, and it still works in the IDE, but it no longer works when packaged as an EXE - the prompt to login comes up, but the form is never initialised and I have to kill the process.

So, I tried the original version, the one I have a working EXE for, and packaging that no longer produces a working app either.

Has something changed in recent updates to the development environment? As that's all that has changed since this worked.


DO NOT POST LICENSES, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Code no longer works when packaged as an exe (but did used to, and hasn't changed)

Post by Alexander Riedel »

Please go to your Windows Update history and list the updates you have installed within the last two months.
Is the .NET framework 3.5 and 4.8 update included?
https://support.microsoft.com/en-us/top ... ef08428e50
Alexander Riedel
SAPIEN Technologies, Inc.
rbutterworth
Posts: 6
Last visit: Thu Oct 05, 2023 8:13 am

Re: Code no longer works when packaged as an exe (but did used to, and hasn't changed)

Post by rbutterworth »

Alexander - I assume you mean this update:

January 26, 2023-KB5022404 Cumulative Update Preview for .NET Framework 3.5 and 4.8.1 for Windows 11, version 22H2

In which case, yes I have that installed (we stay very current on all systems, so it is on all the machines I am trying this on)
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Code no longer works when packaged as an exe (but did used to, and hasn't changed)

Post by Alexander Riedel »

Yes, that's the one I meant. That did break a few .NET things.
Can you please create a code snippet that illustrates the problem, without any real user IDs and post
that here with the exact same settings you have in the original project?
If you do not want to post it here, you can use this link for a private upload: https://www.sapien.com/support/upload
That way we can examine what happens in what order and also evaluate your packager settings.
Alexander Riedel
SAPIEN Technologies, Inc.
rbutterworth
Posts: 6
Last visit: Thu Oct 05, 2023 8:13 am

Re: Code no longer works when packaged as an exe (but did used to, and hasn't changed)

Post by rbutterworth »

Sure, here is an extract that exhibits the behaviour mentioned - run this directly and it works, run it as a packaged EXE and it never makes it to the form. This used to work fine.

Import-Module Microsoft.Xrm.Data.Powershell
$stop = $false
while (!$conn -and !$stop)
{
$cred = Get-Credential -Message 'Please enter your email address and Allvue password'
if ($cred)
{
$conn = Get-CrmConnection -serverurl <url> -OrganizationName AmadeusCapital -Credential $cred
}
else
{
$stop = $true
}

}

if ($stop) { exit (0); }

$form1_Load={
#TODO: Initialize Form Controls here

}

You need a valid Dynamics CRM URL to test this. If I comment out the get-crmconnection, BTW, this code works (though obv. is of no use as I no longer have a connection to the CRM system) so that's the line that is hanging.

This is with default package config. My real project has various package settings, but neither work. The EXE I created originally still works, so something about how the package is created has changed.
rbutterworth
Posts: 6
Last visit: Thu Oct 05, 2023 8:13 am

Re: Code no longer works when packaged as an exe (but did used to, and hasn't changed)

Post by rbutterworth »

I have resolved this - it wasn't an update version related issue, but a code version related one. Moving the CRM login into the Globals section of the project resolves this issue (no idea why).
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Code no longer works when packaged as an exe (but did used to, and hasn't changed)

Post by Alexander Riedel »

Glad to hear it worked out.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 1 year and 1 month 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.