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

发布于 2024-11-01 15:14:17 字数 3910 浏览 1 评论 0原文

我在我的家用计算机上使用 Windows 7、VS 2008 并使用 .net Framework 2.0 创建了一个 C# 项目。我的应用程序正在使用“Irklang”声音库。使用 InnoSetup 5 我已经为我的应用程序创建了设置。安装程序包括所有需要的文件,它安装得很好,但是当我在其他计算机上安装我的应用程序时,我遇到了一些令人困惑的错误。第一个看起来像这样:

在此处输入图像描述

当我创建标记为“irklang.dll”和“regserver”的安装脚本时(在安装过程中注册),我在安装程序期间遇到此错误:“无法注册 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}'),
                        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 版本运行得很好!

I have created a C# project on my home computer with Windows 7, VS 2008 and using .net framework 2.0. My app is using "Irklang" sound library. Using InnoSetup 5 i have created setup for my app. Setup includes all needed files, it installs them well but when i install my app on some other computer i got some confusing errors. First one looks like this:

enter image description here

When i create install script flaging "irklang.dll" with "regserver" (to be registered during setup), i got this error during installation of my program: "Unable to register DLL/OCX: RegSrv32 failed with exit code 0x4". Message got standard "Abort, Ignore, Retry" buttons, but, as always, "Retry" won't fix it.

What should i do? How to fix this error which shouldn't even bother average programmer?

This is my Inno setup instalation file:

; 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

EDIT:
I GOT IT! IT'S NOT PROBLEM WITH MY APP, IT'S PROBLEM WITH DOWNLOADED DLL ITSELF! It seems that IrrKlang.dll version 1.3 (the newest version, i used) is causeing the problems! Version 1.1 is working just fine!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

白色秋天 2024-11-08 15:14:17

RegSrv32 用于 COM dll,从它的外观来看,irklang.dll 是一个 .NET dll。

如果 .NET DLL 需要可用于 COM,则可以使用 RegAsm.exe 进行注册。

RegSrv32 is for COM dll's and from the looks of it the irklang.dll is a .NET dll.

.NET DLLs can be registered using RegAsm.exe if they need to be available for COM.

九厘米的零° 2024-11-08 15:14:17

我假设这是在 Windows Vista 或 7 上?将用户是管理员的要求添加到您的 InnoSetup 文件中。

即,在脚本的 [Setup] 部分添加“PrivilegesRequired=admin”。

I am assuming that this is on Windows Vista or 7? Add to your InnoSetup file the requirement that the user be an Administrator.

Namely, add "PrivilegesRequired=admin" in the script's [Setup] section.

迷雾森÷林ヴ 2024-11-08 15:14:17

该错误消息确实表明它无法加载 IrrKlang.NET2.0 或其依赖项之一,因此您可能会发现它需要其他 dll 才能工作,而这些 dll 恰好是您的计算机。

最好返回到您获取此 dll 的位置,该 dll 应该对此进行记录。

更新。

显然它需要 MSVCR80.DLL 和 MSVCM80.DLL 参见此处

The error message does say that it can not load IrrKlang.NET2.0 or one of its dependencies , so you will probably find that it needs other dlls to work, which happen to be one your machine.

Best to go back to where you got this dll which should have this documented.

Update.

Apparently it needs MSVCR80.DLL and MSVCM80.DLL see here

墨落画卷 2024-11-08 15:14:17

我在 Google 上查找时发现了此论坛帖子。看来,根据您使用的库版本,.NET 2.0 可能存在一个已知问题。他们建议将其添加到您的 app.config 中:

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

I was looking through Google and came across this forum post. It seems that, depending on which version of the library you're using, there may be a known issue with .NET 2.0. They suggested adding this to your app.config:

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文