{"title":"AppSourceCop Error AS0077","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/appsourcecop-as0077/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/appsourcecop-as0077, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/appsourcecop-as0077","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Adding a var modifier in events is not allowed as it might break the runtime behavior of extensions subscribing to it.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"AppSourceCop Error AS0077","slug":"appsourcecop-error-as0077","at":0,"chars":1154},{"level":2,"title":"Description","slug":"description","at":75,"chars":134},{"level":2,"title":"Remarks","slug":"remarks","at":209,"chars":559},{"level":2,"title":"How to fix this diagnostic?","slug":"how-to-fix-this-diagnostic","at":768,"chars":239},{"level":2,"title":"Related information","slug":"related-information","at":1007,"chars":147}],"text":"# AppSourceCop Error AS0077\nAdding a var modifier in events is not allowed\n## Description\nAdding a var modifier in events is not allowed as it might break the runtime behavior of extensions subscribing to it.\n## Remarks\nThis error ensures that the behavior of events remains consistent and predictable. Adding a var modifier to an event parameter can alter how the parameter is handled, potentially causing issues for extensions that subscribe to the event. These extensions might not be designed to handle parameters passed by reference, leading to compatibility issues and runtime errors. Maintaining the original parameter passing mechanism (by value) ensures that the event's behavior remains stable and that dependent extensions continue to function as expected.\n## How to fix this diagnostic?\nTo resolve this error, follow these steps:\n1. Locate the event in your code where the var modifier has been added to a parameter.\n2. Modify the event definition to remove the var modifier from the parameter.\n## Related information\nAppSourceCop Analyzer<appsourcecop>\nGet Started with AL<../devenv-get-started>\nDeveloping Extensions<../devenv-dev-overview>"}