2

コマンド ライン (バッチ) アプリケーションと完全/部分的な信頼に問題があります。

以前のリリース (バージョン番号 7.13.0.63) は正常に動作しますが、新しいバージョン (7.13.0.249) をインストールすると、「そのアセンブリでは、部分的に信頼された呼び出し元が許可されていません」というメッセージが表示されます。

例外:

Stack Trace (edited):
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
   at System.Activator.CreateInstance[T]()
   at <Company>.Service.<Product>.Proxy.Factories.ControllerProxyFactory.Create[T]()
   <Stack Trace that leads to creation of a WCF client> ...

Inner Exception:
An error occurred creating the configuration section handler for system.serviceModel/behaviors: That assembly does not allow partially trusted callers. (C:\Program Files (x86)\InsuranceLine\ListLoader\InsuranceLine.ListLoader.Launcher.exe.Config line 53)
Stack Trace:
   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecordsectionRecord, Object parentResult)
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.ServiceModel.Activation.AspNetEnvironment.UnsafeGetSectionFromConfigurationManager(String sectionPath)
   at System.ServiceModel.Activation.AspNetEnvironment.UnsafeGetConfigurationSection(String sectionPath)
   at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetAssociatedSection(ContextInformation evalContext, String sectionPath)
   at System.ServiceModel.Description.ConfigLoader.LookupChannel(ContextInformation configurationContext, String configurationName, ContractDescription contract, EndpointAddress address, Boolean wildcard, Boolean useChannelElementKind, ServiceEndpoint& serviceEndpoint)
   at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
   at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
   <Stack Trace that determines the correct WCF factory to create>

Inner Exception:
That assembly does not allow partially trusted callers.
Stack Trace:
   at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed)
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.ServiceModel.Configuration.ServiceModelExtensionCollectionElement`1.CreateNewSection(String name)
   at System.ServiceModel.Configuration.ServiceModelExtensionCollectionElement`1.DeserializeElementCore(XmlReader reader)
   at System.ServiceModel.Configuration.ServiceModelExtensionCollectionElement`1.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey)
   at System.Configuration.ConfigurationElementCollection.OnDeserializeUnrecognizedElement(String elementName, XmlReader reader)
   at System.Configuration.ConfigurationElement.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey)
   at System.Configuration.ConfigurationElement.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey)
   at System.Configuration.ConfigurationSection.DeserializeSection(XmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)

製品の展開に使用するプロセスに関しては、WiX を通じて作成された MSI を使用します。次の手順を実行します。

  • 製品の以前のバージョンをアンインストールする
  • ネットワーク共有から msi をコピーします (両方のバージョンで同じ共有、バージョンに基づいて異なるサブディレクトリ)
  • 管理者として msi をインストールする
    • これは C:\Program Files (x86) にインストールされます

2 つのバージョン間の変更点は次のとおりです。

  • トランザクションのタイムアウトを指定するために、app.config ファイル (myapp.exe.config) に追加の AppSettings 項目を含める
  • 「using new TransactionScope()」を「using New TransactionScope(TransactionScopeOption.Required, timeoutValueReadFromAppSettingsAndStoredInLocalVariable)」に変更
    • WCF クライアントの作成は、このトランザクション スコープの範囲外です。

追加情報:

  • この例外は、dev/staging/qa/pre production 環境のいずれでも発生しません。これは、本番アプリケーション サーバーでのみ発生します。
  • Windows 7 を組織に導入する過程にあるため、企業のポリシーが変更された可能性があります。
  • アプリケーションは .Net Framework 4.0 を対象としています
  • 新しいバージョンをアンインストールし、古いバージョン (ネットワーク共有からのコピーを含む) を再インストールすると、古いバージョンは引き続き正常に動作します。
  • インストール先のマシンは Windows Server 2008 R2 です
  • マシンは、VMWare 環境でホストされている仮想マシンです

理想的には、いくつかのことを知りたいです:

  1. 完全信頼モードで実行できるようにアセンブリを変更する (またはインストール後にアクセス許可を設定する) 方法
  2. 開発/ステージング/QA 環境で問題を再現する方法
    • アセンブリが明示的に「信頼できない」と再現する可能性がありますが、インストール時に信頼できないと識別されるように、本番と同じ方法で再現したいのですが、これを行う方法は何か関係があるようですMSI のコピー元のネットワーク共有を「信頼しない」か、MSI/アセンブリ内の発行元情報を「信頼しない」可能性があります。
  3. 将来のインストールが完全に信頼されるように、運用アプリケーション サーバー/セキュリティ ポリシーを構成する方法 (項目 2 に回答すると、これに回答する可能性が高くなります)

ありがとう

4

1 に答える 1

1

.NET 4.0 CLR が既定で CAS セキュリティ ポリシーを適用しないことを考えると、これは非常に奇妙です。そのため、ローカルにインストールされたコマンド ライン アプリケーションを部分的に信頼するには、何らかの (できれば) 意図的な変更を実際に行う必要があります。

考えられる原因を深く掘り下げる前に、次の点を確認していただけますか。

  1. app.configファイルにNetFx40_LegacySecurityPolicy要素が含まれていますか?
  2. あなたのアプリケーションは実際に問題のあるマシンで 4.0 CLR の下で実行されていますか? (例外がスローされる前に Environment.Version の値を出力するようにソースを変更できない場合は、プロセス エクスプローラーを使用して、プロセスで実行されている CLR バージョンを特定できます。)
于 2011-12-02T15:05:26.880 に答える