C#应用程序和汇编地狱!

问题描述

| 我已经在装有Windows 7,VS 2008并使用.net framework 2.0的家用计算机上创建了一个C#项目。我的应用程序正在使用\“ Irklang \”声音库。我使用InnoSetup 5为我的应用程序创建了安装程序。安装程序包括所有需要的文件,它可以很好地安装它们,但是当我在其他计算机上安装应用程序时,出现一些令人困惑的错误。第一个看起来像这样: 当我用\“ regserver \”创建安装脚本标记\“ irklang.dll \”(要在安装过程中注册)时,在安装程序时出现此错误:\“无法注册DLL / OCX:RegSrv32失败,退出代码0x4 \”。邮件具有标准的“中止,忽略,重试”按钮,但与往常一样,“重试”将无法修复它。 我该怎么办?如何解决这个错误,即使普通程序员也不会打扰呢? 这是我的Inno安装程序安装文件:
; 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}\'),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版可以正常工作!     

解决方法

RegSrv32用于COM dll,从外观上看,irklang.dll是.NET dll。 如果需要对COM使用.NET DLL,可以使用RegAsm.exe注册。     ,我假设这是在Windows Vista或7上?将用户必须是管理员的要求添加到您的InnoSetup文件中。 即,在脚本的[设置]部分中添加\“ PrivilegesRequired = admin \”。     ,该错误消息确实表明它无法加载IrrKlang.NET2.0或其依赖项之一,因此您可能会发现它需要其他dll才能工作,而这些dll恰好是您的计算机。 最好回到您拥有该文件的dll的地方。 更新。 显然,它需要MSVCR80.DLL和MSVCM80.DLL参见此处     ,我在浏览Google时发现了该论坛帖子。似乎取决于您使用的是哪个版本的库,.NET 2.0可能存在一个已知问题。他们建议将其添加到您的app.config中:
<startup useLegacyV2RuntimeActivationPolicy=\"true\">
  <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.0\"/>
</startup> 
    

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...