Allan Wells
Allan Wells

Reputation: 81

Error when installing ClickOnce application

Today I started getting an error everytime a user tries to install the aplication, I dunno why im getting this after months of 0 problems with the deployment, I havent change anything related to the project properties, all the modifications has been code related.

Here is the error log

PLATFORM VERSION INFO Windows : 10.0.15063.0 (Win32NT) Common Language Runtime : 4.0.30319.42000 System.Deployment.dll : 4.7.2046.0 built by: NET47REL1 clr.dll : 4.7.2101.1 built by: NET47REL1LAST dfdll.dll : 4.7.2046.0 built by: NET47REL1 dfshim.dll : 10.0.15063.0 (WinBuild.160101.0800)

SOURCES Deployment url : file:///Y:/RE/RentaEquipos.application Deployment Provider url : file://svrre/Repository/RE/RentaEquipos.application Application url : file://svrre/Repository/RE/Application%20Files/RentaEquipos_2017_07_10_8/RentaEquipos.exe.manifest

IDENTITIES Deployment Identity : RentaEquipos.application, Version=2017.7.10.8, Culture=es-CR, PublicKeyToken=0000000000000000, processorArchitecture=x86

APPLICATION SUMMARY * Installable application.

ERROR SUMMARY Below is a summary of the errors, details of these errors are listed later in the log. * Activation of Y:\RE\RentaEquipos.application resulted in exception. Following failure messages were detected: + Specified cast is not valid.

COMPONENT STORE TRANSACTION FAILURE SUMMARY No transaction error was detected.

WARNINGS * The manifest for this application does not have a signature. Signature validation will be ignored. * The manifest for this application does not have a signature. Signature validation will be ignored. * The manifest for this application does not have a signature. Signature validation will be ignored.

OPERATION PROGRESS STATUS * [26/7/2017 11:23:16] : Activation of Y:\RE\RentaEquipos.application has started. * [26/7/2017 11:23:16] : Processing of deployment manifest has successfully completed. * [26/7/2017 11:23:16] : Installation of the application has started.

ERROR DETAILS Following errors were detected during this operation. * [26/7/2017 11:23:16] System.InvalidCastException - Specified cast is not valid. - Source: System.Deployment - Stack trace: at System.Deployment.Application.DownloadManager.VerifyRequestedPrivilegesSupport(String requestedExecutionLevel) at System.Deployment.Application.DownloadManager.DownloadApplicationManifest(AssemblyManifest deploymentManifest, String targetDir, Uri deploymentUri, > IDownloadNotification notification, DownloadOptions options, Uri& appSourceUri, String& appManifestPath) 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)

COMPONENT STORE TRANSACTION DETAILS No transaction information is available.

Upvotes: 4

Views: 2580

Answers (1)

Steven Doggart
Steven Doggart

Reputation: 43743

The DownloadManager.VerifyRequestedPrivilegesSupport method is throwing an InvalidCastException. Unfortunately, the code for that class is not available on ReferenceSource, but when System.Deployment.dll is decompiled, the culprit is clear. The decompiled method looks like this:

private static void VerifyRequestedPrivilegesSupport(string requestedExecutionLevel)
{
  Logger.AddMethodCall("VerifyRequestedPrivilegesSupport(" + requestedExecutionLevel + ") called.");
  if (!PlatformSpecific.OnVistaOrAbove)
    return;
  bool flag = false;
  RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");
  if (registryKey != null && registryKey.GetValue("EnableLUA") != null)
  {
    Logger.AddInternalState("LUA policy key = " + registryKey.Name);
    if ((int) registryKey.GetValue("EnableLUA") != 0)
    {
      flag = true;
      Logger.AddInternalState("LUA is enabled.");
    }
  }
  if (flag && (string.Compare(requestedExecutionLevel, "requireAdministrator", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(requestedExecutionLevel, "highestAvailable", StringComparison.OrdinalIgnoreCase) == 0))
    throw new InvalidDeploymentException(ExceptionTypes.UnsupportedElevetaionRequest, string.Format((IFormatProvider) CultureInfo.CurrentUICulture, Resources.GetString("Ex_ManifestExecutionLevelNotSupported"), new object[0]));
}

The line that throws the exception would be this one:

if ((int) registryKey.GetValue("EnableLUA") != 0)

The code reads registry key \HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersio‌​n\Policies\System from the windows registry. For it to throw that exception, the key must exist and it must have an EnableLUA value, but the value must be typed as something other than an integer. You need to run RegEdit.exe on the machine that's getting the error, navigate to that key in the registry, and inspect that value to see what it is. It should show REG_DWORD in the Type column for that value. If not, delete it and re-add it with the right type.

Upvotes: 7

Related Questions