使用Framework 4.0编译MakeSfxCA.exe和DLL

时间:2010-10-08 05:37:36

标签: .net dll wix dtf

我有一个用Microsoft .NET Framework 4.0编译的dll文件

当我使用MakeSfxCA.exe文件并将dll作为参数之一传递给命令行时,它会给出以下错误消息:

D:\SetupManager\test>D:\SetupManager\SetupBuilding\Wix\bin\sdk\makesfxca.exe Fil
e2.dll D:\SetupManager\SetupBuilding\Wix\bin\sdk\x86\sfxCA.dll File1.dll CustomA
ction.config
Searching for custom action entry points in File1.dll
Error: System.BadImageFormatException: Could not load file or assembly 'file:///
D:\SetupManager\test\File1.dll' or one of its dependencies. **This assembly is bui
lt by a runtime newer than the currently loaded runtime and cannot be loaded.**
File name: 'file:///D:\SetupManager\test\File1.dll'
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase,
Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boo
lean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, E
vidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Bool
ean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence
 assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence
securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean
 forIntrospection, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)
   at Microsoft.Deployment.Tools.MakeSfxCA.MakeSfxCA.FindEntryPoints(String modu
le)
   at Microsoft.Deployment.Tools.MakeSfxCA.MakeSfxCA.Build(String output, String
 sfxdll, IList`1 inputs, TextWriter log)
   at Microsoft.Deployment.Tools.MakeSfxCA.MakeSfxCA.Main(String[] args)

=== Pre-bind state information ===
LOG: User = DSDMAIN\Rajesh
LOG: Where-ref bind. Location = D:\SetupManager\test\File1.dll
LOG: Appbase = file:///D:/SetupManager/SetupBuilding/Wix/bin/sdk/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This is an inspection only bind.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2
.0.50727\config\machine.config.
LOG: Attempting download of new URL file:///D:/SetupManager/test/File1.dll.
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.

感谢任何帮助。

提前致谢。

2 个答案:

答案 0 :(得分:2)

通过将以下代码添加到CustomActions.config文件并在MakeSfxCA.exe旁边创建MakeSfxCA.exe.config文件,我遇到了类似的问题

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" />
    </startup>
</configuration>

答案 1 :(得分:2)

我的问题略有不同,但对其他人可能有用。 .config文件必须在项目中具有名称“CustomAction.config”。它不能具有名称<YourCAProject>.config,因为重命名项目时会给dll一个唯一的名称。似乎MakeSfxCA构建工具和SfxCA存根目前依赖于此文件名。