ClickOnce and configuration for a C# application

白昼怎懂夜的黑 提交于 2019-12-23 03:22:42

问题


What and how should I put into an app.config file.

The scenario is this, I have created a C# Windows Forms application (.NET 4.0), and it runs fine on the development computer. When I deploy it using ClickOnce on other computers I get a permission error for the machine.config file. This is a corporate domain so I do not have rights to change the permissions in the machine.config file on the target computers. From what I have been reading, I believe that whatever is being accessed in the machine.config file can alternately be placed into the app.config file. The problem is I do understand what would need to be placed into the app.config file, and I do not understand some of the aspects of the configuration such as 'keys', etc.

How can I avoid the use of the machine.config file altogether, and what exactly needs to be configured to do so?

Complete error details:

Platform version information

Windows                  : 5.1.2600.196608 (Win32NT)
Common Language Runtime  : 4.0.30319.296
System.Deployment.dll    : 4.0.30319.1 (RTMRel.030319-0100)
clr.dll                  : 4.0.30319.296 (RTMGDR.030319-2900)
dfdll.dll                : 4.0.30319.1 (RTMRel.030319-0100)
dfshim.dll               : 4.0.31106.0 (Main.031106-0000)


SOURCES

Deployment URL: file:///P:/Eastops/Region%20C/Conie/HHC/HHC.application


ERROR SUMMARY

Below is a summary of the errors, details of these errors are listed later in the log.

* Activation of P:\Eastops\Region C\Conie\HHC\HHC.application resulted in an exception. The following
  failure messages were detected:

    + Configuration system failed to initialize

    + An error occurred loading a configuration file: Access to the
      path 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Config\machine.config' is
      denied. (C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Config\machine.config)

    + Access to the path 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Config\machine.config'
      is denied.


COMPONENT STORE TRANSACTION FAILURE SUMMARY

No transaction error was detected.


WARNINGS

There were no warnings during this operation.


OPERATION PROGRESS STATUS

* [4/17/2013 8:29:25 AM] : Activation of P:\Eastops\Region C\Conie\HHC\HHC.application has started.


ERROR DETAILS

Following errors were detected during this operation.

* [4/17/2013 8:29:27 AM] System.Configuration.ConfigurationErrorsException

- Configuration system failed to initialize
- Source: System.Configuration
- Stack trace:
          at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
          at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
          at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
          at System.Configuration.ConfigurationManager.GetSection(String sectionName)
          at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
          at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()
          at System.Diagnostics.DiagnosticsConfiguration.Initialize()
          at System.Diagnostics.DiagnosticsConfiguration.get_Sources()
          at System.Diagnostics.TraceSource.Initialize()
          at System.Net.Logging.InitializeLogging()
          at System.Net.Logging.get_On()
          at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
          at System.Net.WebRequest.Create(Uri requestUri)
          at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
          at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
          at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
          at System.Deployment.Application.DownloadManager.DownloadManifestAsRawFile(Uri& sourceUri, String targetPath, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
          at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
          at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options)
          at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
          at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)

--- Inner Exception ---

System.Configuration.ConfigurationErrorsException

- An error occurred loading a configuration file: Access to the
  path 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Config\machine.config' is
  denied. (C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Config\machine.config)

- Source: System.Configuration

- Stack trace:
          at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
          at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
          at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
          at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)

--- Inner Exception ---

System.UnauthorizedAccessException

- Access to the path 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Config\machine.config' is denied.
- Source: mscorlib
- Stack trace:

          at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
          at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
          at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
          at System.Configuration.Internal.InternalConfigHost.StaticOpenStreamForRead(String streamName)
          at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForRead(String streamName, Boolean assertPermissions)
          at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForRead(String streamName)
          at System.Configuration.ClientConfigurationHost.OpenStreamForRead(String streamName)
          at System.Configuration.BaseConfigurationRecord.InitConfigFromFile()


COMPONENT STORE TRANSACTION DETAILS

No transaction information is available.

来源:https://stackoverflow.com/questions/16018075/clickonce-and-configuration-for-a-c-sharp-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!