我在家里的Windows 7电脑上使用VS 2008和.NET Framework 2.0创建了一个C#项目。我的应用程序使用"Irklang"音频库。我使用InnoSetup 5为我的应用程序创建了安装程序。安装程序包含所有需要的文件,它们被成功地安装,但是当我将我的应用程序安装到其他计算机上时,我遇到了一些令人困惑的错误。第一个错误看起来像这样:
当我在安装脚本中标记"irklang.dll"并使用"regserver"(在安装期间注册)时,在安装程序期间我收到了这个错误消息:"无法注册DLL/OCX:RegSrv32失败,退出代码为0x4"。消息有标准的"中止、忽略、重试"按钮,但是,如常,"重试"并不能解决问题。
我该怎么办?如何修复这个错误,这个错误甚至不应该困扰普通程序员?
这是我的Inno Setup安装文件:
当我在安装脚本中标记"irklang.dll"并使用"regserver"(在安装期间注册)时,在安装程序期间我收到了这个错误消息:"无法注册DLL/OCX:RegSrv32失败,退出代码为0x4"。消息有标准的"中止、忽略、重试"按钮,但是,如常,"重试"并不能解决问题。
我该怎么办?如何修复这个错误,这个错误甚至不应该困扰普通程序员?
这是我的Inno Setup安装文件:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[CustomMessages]
dotnetmissing=This setup requires the .NET Framework v2.0. Please download and install the .NET Framework v.2 and run this setup again. Do you want to download the framework now?
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{10087152-8A1D-4C0B-9BFC-E463C2F8E3C0}
AppName=Kucni rad
AppVersion=1.5
;AppVerName=Kucni rad 1.5
DefaultDirName={pf}\Kucni rad
DefaultGroupName=Kucni rad
OutputDir=C:\Users\Boza\Desktop
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Code]
function InitializeSetup(): Boolean;
var
ErrorCode: Integer;
NetFrameWorkInstalled : Boolean;
Result1 : Boolean;
begin
NetFrameWorkInstalled := RegKeyExists(HKLM,'SOFTWARE\Microsoft\.NETFramework\policy\v2.0');
if NetFrameWorkInstalled =true then
begin
Result := true;
end;
if NetFrameWorkInstalled = false then
begin
NetFrameWorkInstalled := RegKeyExists(HKLM,'SOFTWARE\Microsoft\.NETFramework\policy\v2.0');
if NetFrameWorkInstalled =true then
begin
Result := true;
end;
if NetFrameWorkInstalled =false then
begin
//Result1 := (ExpandConstant('{cm:dotnetmissing}'), mbConfirmation, MB_YESNO) = idYes;
Result1 := MsgBox(ExpandConstant('{cm:dotnetmissing}'),
mbConfirmation, MB_YESNO) = idYes;
if Result1 =false then
begin
Result:=false;
end
else
begin
Result:=false;
ShellExec('open',
'http://download.microsoft.com/download/5/6/7/567758a3-759e-473e-bf8f-52154438565a/dotnetfx.exe',
'','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
end;
end;
end;
end;
[Dirs]
Name: "{app}\Sounds"
[Files]
Source: "C:\Users\Boza\Desktop\Novi kucnirad\kucnirad\bin\Debug\kucnirad.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Boza\Desktop\Novi kucnirad\kucnirad\bin\Debug\Sounds\*"; DestDir: "{app}\Sounds"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\Boza\Desktop\Novi kucnirad\kucnirad\bin\Debug\ikpMP3.dll"; DestDir: "{app}"; Flags: ignoreversion regserver
Source: "C:\Users\Boza\Desktop\Novi kucnirad\kucnirad\bin\Debug\irrKlang.NET2.0.dll"; DestDir: "{app}"; Flags: ignoreversion regserver
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\Kucni rad"; Filename: "{app}\kucnirad.exe"
Name: "{group}\{cm:UninstallProgram,Kucni rad}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\Kucni rad"; Filename: "{app}\kucnirad.exe"; Tasks: desktopicon
[Run]
Filename: "{app}\kucnirad.exe"; Description: "{cm:LaunchProgram,Kucni rad}"; Flags: nowait postinstall skipifsilent
编辑: 我明白了!问题不在我的应用程序上,而在于下载的DLL本身!似乎IrrKlang.dll版本1.3(我使用的最新版本)引起了问题!版本1.1工作得很好!