publish error value does not fall within the expected range

Jay O'Brien 71 Reputation points
2022-10-07T19:49:12.373+00:00

I am updating existing applications. The publishing files work on all but one computer. Programs are written in C# VS 2022. On that one computer, I logged in as a different user and could publish, but not as main user.

Error detail is
* [10/7/2022 1:29:15 PM] System.ArgumentException
- Value does not fall within the expected range.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Internal.Isolation.IStore.LockApplicationPath(UInt32 Flags, IDefinitionAppId ApId, IntPtr& Cookie)
at System.Deployment.Application.ComponentStore.LockApplicationPath(DefinitionAppId definitionAppId)
at System.Deployment.Application.SubscriptionStore.LockApplicationPath(DefinitionAppId definitionAppId)
at System.Deployment.Application.FileDownloader.PatchFiles(SubscriptionState subState)
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState, X509Certificate2 clientCertificate)
at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.ApplicationActivator.DownloadApplication(SubscriptionState subState, ActivationDescription actDesc, Int64 transactionId, TempDirectory& downloadTemp)
at System.Deployment.Application.ApplicationActivator.InstallApplication(SubscriptionState& subState, ActivationDescription actDesc)
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl, Uri& deploymentUri)
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivationWithRetry(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivationWithRetry(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)

Developer technologies | Windows Forms
Community Center | Not monitored
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 60,326 Reputation points
    2022-10-07T20:44:48.417+00:00

    Googling for this issue there appears to be an issue if you're building your app as Any CPU. This was done in the early days of .NET but that introduced a lot of issues so MS reset the default to be x86 IIRC. Check your build settings. If your EXE is compiling for Any CPU then you're going to run into issues if it relies on any native binaries outside the OS and framework binaries. This could include COM objects, third party DLLs and native dependencies.

    Most people found that by targeting x86 (or probably x64 in your case) then the problem went away. Additionally you should confirm that the dependencies you have are properly detected by the publisher. There were reports that this was hit or miss in some cases.

    Another reported cause of this issue is if you already have an app installed and then install an "update" but don't actually change the version number. In that case the deployment gets confused.

    Here's a really old post about things that people did to resolve the issue.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.