4
votes

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.

1
Since it's System.Deployment.Application.DownloadManager.VerifyRequestedPrivilegesSupport(String requestedExecutionLevel) that's throwing the InvalidCastException, I'd say it's a good guess to say that the requestedExecutionLevel being used for the download is invalid. Perhaps there's something wrong in your config?Steven Doggart
Tested a second aplication im installing with clickonce and it gives me the same error, also this second aplications was updated months ago and also it olny gives the error to me in windows 10, tested other computer with windows 7 and both aplications install without problems, but theres a second problem, if I deploy an update for the app the installer gets the problems in any operating system, dunno what could be happening with thisAllan Wells
Aha! Nice. So, it looks like the culprit is the if ((int) registryKey.GetValue("EnableLUA") != 0) statement. So, that registryKey was read from \HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System in the windows registry. For it to throw that exception, that key must exist and it must have an EnableLUA value, but it must be typed as something other than an integer. Try running RegEdit.exe on that machine, navigate to that key, and inspect that value to see what it is.Steven Doggart
It should say REG_DWORD in the Type column for that valueSteven Doggart
OMFG! got there and the key was a REG_SZ, deleted it and created like DWORD, it's working now, but why did it changed its type? checked in another computer and it was DWORD how you said, checked if deploying another update would reverse this, and it didnt, so by now everything seems to be working. Thanks a lot! 15/10 Would be in trouble again!!!Allan Wells

1 Answers

6
votes

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.