まず第一に、私は非常に長い質問には、事前に謝罪しましょう!ConfigurationManager.OpenMappedExeConfiguration.GetSection()が失敗したが(つい最近起こっ始まっ)
は、私はクラスライブラリは、アドイン別のプログラム(ArcMap.exe)にあるため、GACにインストールされていないのC#/。NET 3.5クラスライブラリを持っています。プログラムは実際に起動時のアーカイブからユーザーのローカル設定\ Application Dataフォルダの下にあるフォルダに.dllを抽出しますが、実行時にその場所をthis.GetType().Assembly.Location
で取得できます。ライブラリで
私は.configファイルで参照されるCustomConfigSection
というクラスを持っています。
ライブラリには、ConfigurationManager.OpenMappedExeConfiguration()
を使用して.configファイル(ユーザーのApplication Dataフォルダに格納されている)から読み取り、CustomConfigSection
を返すメソッドのクラスがあります。何が起こるのですかGetSection()
はConfigurationErrorsException
が私のCustomConfigSection
を含むアセンブリを見つけることができないと言っています。
迷惑なことは、これが2日前に動作していたことです。私はWindows Updateがこれを破ったと思う。私は戻ってきて、私のコードの以前のバージョンをうまく動作させて、無駄にしてみました。私のコードではなく、環境の中で何か変わったのですが、それが他のマシンでも起こっていたので、私だけではありません!
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="customConfigSection" type="TestExeConfigurationFileMapAddin.CustomConfigSection, TestExeConfigurationFileMapAddin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</configSections>
<customConfigSection>
<customConfigCollection>
<customConfig name="asdf" />
<customConfig name="1234" />
<customConfig name="jlkjjkljj" />
</customConfigCollection>
</customConfigSection>
</configuration>
そして、私は(私が述べたように完全に2日前に働いている)、それを読むために使用していますコード:
private CustomConfigSection LoadConfigSection()
{
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = m_userConfigFilePath;
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
CustomConfigSection configSection = config.GetSection("customConfigSection") as CustomConfigSection;
return configSection;
}
m_userConfigFilePath
がある。ここ
Configuration
オブジェクトの
HasFile
プロパティはtrueです。ここで
はFusionアセンブリバインディングログ有効にした後、私は取得エラーです:
System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for customConfigSection: Could not load file or assembly 'TestExeConfigurationFileMapAddin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. (C:\Documents and Settings\...\Application Data\TestExeConfigurationFileMapAddin\test.config line 4) ---> System.IO.FileNotFoundException: Could not load file or assembly 'TestExeConfigurationFileMapAddin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'TestExeConfigurationFileMapAddin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at System.Configuration.TypeUtil.GetTypeWithReflectionPermission(IInternalConfigHost host, String typeString, Boolean throwOnError)
at System.Configuration.MgmtConfigurationRecord.CreateSectionFactory(FactoryRecord factoryRecord)
at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable C:\Program Files\ArcGIS\Desktop10.0\Bin\ArcMap.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = ...
LOG: DisplayName = TestExeConfigurationFileMapAddin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/ArcGIS/Desktop10.0/Bin/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files\ArcGIS\Desktop10.0\Bin\ArcMap.exe.Config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files/ArcGIS/Desktop10.0/Bin/TestExeConfigurationFileMapAddin.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/ArcGIS/Desktop10.0/Bin/TestExeConfigurationFileMapAddin/TestExeConfigurationFileMapAddin.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/ArcGIS/Desktop10.0/Bin/TestExeConfigurationFileMapAddin.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/ArcGIS/Desktop10.0/Bin/TestExeConfigurationFileMapAddin/TestExeConfigurationFileMapAddin.EXE.
--- End of inner exception stack trace ---
at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)
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, Boolean getLkg, Boolean checkPermission)
at System.Configuration.Configuration.GetSection(String sectionName)
at TestExeConfigurationFileMapAddin.Form1.LoadConfigSection() in C:\CSProjects\TestExeConfigurationFileMapAddin\TestExeConfigurationFileMapAddin\Form1.cs:line 46
at TestExeConfigurationFileMapAddin.Form1.LoadConfig() in C:\CSProjects\TestExeConfigurationFileMapAddin\TestExeConfigurationFileMapAddin\Form1.cs:line 28
を融合は、ログ自体をバインドできませんでした:
*** Assembly Binder Log Entry (7/29/2011 @ 12:46:02 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable C:\Program Files\ArcGIS\Desktop10.0\Bin\ArcMap.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = ...
LOG: DisplayName = TestExeConfigurationFileMapAddin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/ArcGIS/Desktop10.0/Bin/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files\ArcGIS\Desktop10.0\Bin\ArcMap.exe.Config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files/ArcGIS/Desktop10.0/Bin/TestExeConfigurationFileMapAddin.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/ArcGIS/Desktop10.0/Bin/TestExeConfigurationFileMapAddin/TestExeConfigurationFileMapAddin.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/ArcGIS/Desktop10.0/Bin/TestExeConfigurationFileMapAddin.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/ArcGIS/Desktop10.0/Bin/TestExeConfigurationFileMapAddin/TestExeConfigurationFileMapAddin.EXE.
LOG: All probing URLs attempted and failed.
明らかにConfigurationManager
は私を含むアセンブリを探していますCustomConfigSection
が間違った場所から来たのはなぜですか?これは最近起こったのですが、最近私は考えていませんが、2〜3日前にWindows Updatesをインストールしました。私はWindows XP Pro SP3 32ビットを実行しています。完全にこれらの用語の全てが何を意味するか理解せず
は、フュージョンログは、私が正しい場所からアセンブリをロードするにそれを強制するために、負荷状況やポリシーを変更することができるかもしれないことを願っています。それは本当ですか、もしそうなら、どうですか?
最近あなたのWindowsアカウントのアクセス権が変更されましたか?DLLがドキュメント&設定領域にあるので、ダムの質問のように聞こえるかもしれませんが、私は最近私のドキュメントと設定の所有者ではないことを発見しました(Win7) – tomfumb
私の知る限り、いいえ、私はそれでもマシン上の管理者。 – blah238
私はWin7 x64マシンで同じことをしていますが、フル管理者権限を持っていることを知っています。[this post](http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration)によると、 aspx?msg = 3307466#xx3307466xx)Jon Ristaの2009年からは、これがうまくいくはずです.Netのセキュリティ制限のため、アセンブリはホスティングアプリケーションのプライベートbin検索パスにある必要があります。なぜ以前のように動作していたのか、誰も推測されていないのですが、もしそうなら、私はWindowsのアップデートがそのセキュリティを強化していると推測しています。アドインと同じものを見つけたら教えてください。 – blah238