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.


Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
1,947 questions
C#
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.
10,995 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,963 questions
Microsoft 365 Publishing
Microsoft 365 Publishing
Microsoft 365: Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line. Publishing: The process of preparing, producing, and releasing content for distribution or sale.
622 questions
0 comments No comments
{count} vote

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.

    0 comments No comments

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.