2011-04-12 61 views
3

我在家用電腦上用Windows 7,VS 2008和.net framework 2.0創建了一個C#項目。我的應用程序正在使用「Irklang」聲音庫。使用InnoSetup 5我爲我的應用程序創建了設置。安裝程序包括所有需要的文件,它安裝得很好,但是當我在其他計算機上安裝我的應用程序時,我遇到了一些令人困惑的錯誤。第一個是這樣的:C#應用程序和組裝地獄!

enter image description here

當我創建安裝腳本flaging「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工作正常!

+4

當安裝程序運行時,Regsvr32需要管理員權限。你能得到該對象的.net版本嗎? – 2011-04-12 21:21:11

+0

您可以從融合日誌中獲得更多信息。如果異常詳細信息不包含融合日誌信息,則可以通過其他方式獲得它,例如以下描述的方法:http://blogs.msdn.com/b/suzcook/archive/2003/05/29/57120。 aspx – Cirdec 2011-04-12 21:47:09

+0

如果您嘗試在32位計算機上安裝64位DLL,或者反過來(使用64位工具的32位DLL),也會發生此類事情。 – 2011-04-12 22:13:52

回答

0

RegSrv32是爲COM DLL和從它的外觀irklang.dll是一個.NET DLL。

.NET DLL可以使用RegAsm.exe註冊,如果它們需要可用於COM。

+0

請再來? :)真的,我不知道註冊dll-s,大多數情況下,一切正常工作時安裝它是工作... – Nemo 2011-04-12 21:40:42

0

我假設這是在Windows Vista或7上?添加到您的InnoSetup文件中,要求用戶成爲管理員。

即在腳本的[Setup]部分添加「PrivilegesRequired = admin」。

+0

它適用於Windows 7,因爲它是在Win7上創建,編譯和編譯的。它不能在WinXP上運行! – Nemo 2011-04-12 21:39:43

+0

@Nemo在這裏發表你的劇本。 – AngryHacker 2011-04-12 21:43:02

+0

@Nemo另外它在你的機器上工作的原因是因爲DLL已經在你的機器上註冊了。 – AngryHacker 2011-04-12 21:44:03

0

錯誤消息確實表示無法加載IrrKlang.NET2.0 或其某個依賴關係,因此您可能會發現它需要其他dll才能工作,而這恰好是您的計算機之一。

最好回到你得到這個DLL應該有這種記錄。

更新。

顯然,這需要MSVCR80.DLL和MSVCM80.DLL see here

+0

我知道!我已經安裝了「vcredist_x86」,我的測試計算機上也有VS2008 - 沒有運氣! :\ – Nemo 2011-04-12 22:27:11

+0

您可以嘗試從sysinternals下載並運行Process Monitor。這將向您顯示您的應用程序正在嘗試加載的任何文件,並可能指向其他要求。 – sgmoore 2011-04-12 22:43:28

0

我一直在尋找通過谷歌和整個this forum post來了。看來,根據你使用的是哪個版本的庫,.NET 2.0可能存在一個已知的問題。他們建議將此添加到您的app.config中:

<startup useLegacyV2RuntimeActivationPolicy="true"> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
</startup> 
相關問題