8

ILMerge を使用して、1 つの exe と 2 つのリソース dll を含むプロジェクトから単一のアセンブリ アプリケーションを作成しています。

  • \bin\Debug\test.exe
  • \bin\Debug\nl-BE\test.resources.dll
  • \bin\Debug\fr-FR\test.resources.dll

これは 1 つのフォーム (Form1.cs) を持つ単純なテスト プロジェクトなので、特別なことは何もありません。私の目標は、機能するリソース マネージャーを使用して単一のアセンブリ アプリを作成することです ( ILMerge とローカライズされたリソース アセンブリ単一アセンブリの多言語 Windows フォーム展開 (ILMerge とサテライト アセンブリ/ローカリゼーション) を読みました - 可能ですか?方法については、これ)。

プロジェクトをコンパイルした後、次のコマンド ライン パラメーターを指定して ILMerge を実行します。

ilmerge /log:test.txt /target:winexe /copyattrs /allowdup /out:test_merged.exe 
"C:\projectdir\bin\Debug\test.exe" "C:\projectdir\bin\Debug\fr-FR\test.resources.dll" 
"C:\projectdir\bin\Debug\nl-BE\test.resources.dll"

Reflector を使用してマージされたアセンブリの内容を確認すると、リソース ツリー ノードの下に次のように表示されます。

  • test.Form1.fr-FR.resources
  • test.Form1.fr-FR.resources
  • test.Form1.resources
  • test.Properties.Resources.resources

fr-FR および nl-BE リソースの代わりに、fr-FR リソースの 2 倍があります。これは、リソース dll の名前が同じであるためですか? その結果、実行時に fr-FR リソースしか取得できません。

何か案は ?

更新 (ログ ファイルの内容): (注: バイナリには "loc_" というプレフィックスが付いています。わかりやすくするために、以前の投稿ではそれらを省略しました)

ILMerge version 2.10.526.0
Copyright (C) Microsoft Corporation 2004-2006. All rights reserved.
ILMerge /log:loc_test.txt /target:winexe /copyattrs /allowdup /out:loc_test_merged.exe c:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\loc_test.exe C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\fr-FR\loc_test.resources.dll C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\nl-BE\loc_test.resources.dll 
Set platform to 'v2', using directory 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\..\v2.0.50727' for mscorlib.dll
Running on Microsoft (R) .NET Framework v2.0.50727
mscorlib.dll version = 2.0.0.0
The list of input assemblies is:
    c:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\loc_test.exe
    C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\fr-FR\loc_test.resources.dll
    C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\nl-BE\loc_test.resources.dll
Trying to read assembly from the file 'c:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\loc_test.exe'.
    Successfully read in assembly.
    There were no errors reported in loc_test's metadata.
Trying to read assembly from the file 'C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\fr-FR\loc_test.resources.dll'.
Can not find PDB file. Debug info will not be available for assembly 'C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\fr-FR\loc_test.resources.dll'.
    Successfully read in assembly.
    There were no errors reported in loc_test.resources's metadata.
Trying to read assembly from the file 'C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\nl-BE\loc_test.resources.dll'.
Can not find PDB file. Debug info will not be available for assembly 'C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\nl-BE\loc_test.resources.dll'.
    Successfully read in assembly.
    There were no errors reported in loc_test.resources's metadata.
Checking to see that all of the input assemblies have a compatible PeKind.
    loc_test.PeKind = ILonly
    loc_test.resources.PeKind = ILonly
    loc_test.resources.PeKind = ILonly
All input assemblies have a compatible PeKind value.
Merging assembly 'loc_test' into target assembly.
Merging assembly 'loc_test.resources' into target assembly.
Merging assembly 'loc_test.resources' into target assembly.
Merging assembly-level attributes from assembly 'loc_test' into target assembly.
Copying 2 Win32 Resources from assembly 'loc_test' into target assembly.
Transferring entry point 'loc_test.Program.Main' from assembly 'loc_test' to assembly 'loc_test_merged'.
    There were no errors reported in the target assembly's metadata.
ILMerge: Writing target assembly 'loc_test_merged.exe'.
AssemblyResolver: Assembly 'System' is referencing assembly 'System.Configuration'.
    AssemblyResolver: Attempting referencing assembly's directory.
Can not find PDB file. Debug info will not be available for assembly 'System.Configuration'.
Resolved assembly reference 'System.Configuration' to 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll'. (Used referencing Module's directory.)
Location for referenced assembly 'System.Windows.Forms' is 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll'
    There were no errors reported in  System.Windows.Forms's metadata.
Location for referenced assembly 'System' is 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll'
    There were no errors reported in  System's metadata.
Location for referenced assembly 'mscorlib' is 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll'
    There were no errors reported in  mscorlib's metadata.
Location for referenced assembly 'System.Drawing' is 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll'
    There were no errors reported in  System.Drawing's metadata.
ILMerge: Done.

更新: プロジェクト コードを含む zip ファイルは、http://www.filedropper.com/loctestで入手できます。

更新: 信じられないかもしれませんが、ILMerge を 2 ステップで実行すると、うまくいきます!

ilmerge /log:loc_test.txt /target:winexe /copyattrs /allowdup /out:loc_test_merged.exe "c:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\loc_test.exe" "C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\fr-FR\loc_test.resources.dll"

ilmerge /log:loc_test.txt /target:winexe /copyattrs /allowdup /out:loc_test_merged_2.exe loc_test_merged.exe "C:\Users\<user>\Documents\Visual Studio 2008\Projects\loc_test\loc_test\bin\Debug\nl-BE\loc_test.resources.dll"

この理由は何ですか?

Thx、ジャニエク

4

1 に答える 1

4

ILMerge がアセンブリを 2 ステップで正しく統合する理由の詳細はわかりませんが、現時点ではこれが唯一の解決策のようです。質問の最後の編集を確認して、これをどのように行ったかを確認してください。

なぜ1ステップで失敗するのか、まだ興味があります...

于 2010-12-09T13:15:51.877 に答える