Share via

System.ArgumentException: Value does not fall within the expected range.

Joshua S 5 Reputation points
2023-12-05T03:02:02.8933333+00:00

I am making an Excel Addin in C# in Visual Studio. I have already made another simpler Addin and installed it with no problem. But on this one I am getting the following error: “Name: ExcelAddin_RSMeansV.2 From: file:///C:/Users/jstebbins/Desktop/Excel Addin Deploy/ExcelAddin_RSMeans-Deploy.vsto

************** Exception Text ************** System.ArgumentException: Value does not fall within the expected range. at System.Deployment.Internal.Isolation.IActContext.ApplicationBasePath(UInt32 Flags, String& ApplicationPath) at System.ActivationContext.get_ApplicationDirectory() at System.AppDomainSetup..ctor(ActivationArguments activationArguments) at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.CreateAppDomainSetup(ActivationContext context, Uri deploymentManifestUri, AddInInstallationStatus installStatus) at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()” I am able to run the code for this addin successfully in Visual Studio... It even appears in Excel. And can be run on its own. Yet, when the installer goes to install it has this problem. The Addin is still being drawn on from the repos/debug file path, not the new install folder in its current state. In other words the install package with ClickOnce install will not work.

I feel like I have tried most everything, and this is what I know:

Most likely possibility is that there is something wrong with my references in visual studio. I had to convert this project from a console application to an Excel addin and the API I am trying to call would not work unless I put in certain references 1 at a time. Also certain Nuget packages had to stay in a previous version or the API won't work like RestSharp 7.0 cannot be upgraded to 8.0 or it breaks the code.

I don't know how to fix it at this point, any help on solving this error would be much appreciated.


Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Development | Microsoft 365 Publishing
Microsoft 365 and Office | Excel | For business | Windows
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Waqar Kabir 1 Reputation point
    2024-07-16T17:24:06.3666667+00:00

    Ensure all the files needed for your Excel Add-in are included when you deploy it using ClickOnce. Sometimes, the files your project uses might not get included properly in the deployment package. Double-check this to ensure everything needed is there.

    Was this answer helpful?

    0 comments No comments

Your answer

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