Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid program with specific method #88

Open
Ralf1108 opened this issue Oct 1, 2021 · 2 comments
Open

Invalid program with specific method #88

Ralf1108 opened this issue Oct 1, 2021 · 2 comments

Comments

@Ralf1108
Copy link
Collaborator

Ralf1108 commented Oct 1, 2021

This method lead to an "Invalid program" exception during runtime. Removing "DisplayWaitCursor" attribute fixes the problem
This should be tried to reproduce.

[DisplayWaitCursor]
        private async Task Add(InvoiceContactViewModel contactViewModel)
        {
            if (contactViewModel == null)
                return;            if (ChosenContactViewModels.Contains(contactViewModel))
                return;            if (ShowOnlyContactsWithoutIncidents)
            {
                var hasContactIncident = await HasContactIncident(contactViewModel);                if (hasContactIncident)
                {
                    _show.Error(
                        MultipleContactSelectionDialogResources.AssignContactToCorporationHint,
                        contactViewModel.Contact.AdvancedEntityText);                    return;
                }
            }            var removeItem = AvailableContactViewModels
                .SingleOrDefault(x => x.Contact.ID == contactViewModel.Contact.ID);            ChosenContactViewModels.Add(contactViewModel);            if (removeItem != null)
                AvailableContactViewModels.Remove(removeItem);
        }
@psaxton
Copy link

psaxton commented Sep 16, 2022

Without the additional code, it is impossible to reproduce the error from your example.

That said, this looks like it matches the pattern of a method ending in a code block (if (removeItem != null) { AvailableContactViewModels.Remove(removeItem); }) related to issue #66. A simple work around is to simply add another line of code after the block. (for example, end the method with await Task.CompletedTask;)

I'm currently researching a better solution.

@psaxton
Copy link

psaxton commented Oct 4, 2022

I believe this issue to be resolved in PR #100.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants