独立可执行文件

发布于 2024-07-16 19:31:32 字数 189 浏览 4 评论 0原文

我正在 VB.NET 中编写一个相对简单的程序。 我试图使安装过程对用户来说尽可能简单。

我知道可以使用调试目录中的可执行文件作为独立的可执行文件,但是这种方法有什么缺点吗? 例如,如果用户的计算机上没有.NET,则程序将无法运行。

有没有办法发布该程序,使其独立于单个可执行文件中?

感谢帮助。

I am working on a relatively simple program in VB.NET. I am trying to make the installation process as simple as possible for the user.

I know its possible to use the executable from the debug directory as a stand alone executable, but are there any drawbacks to this approach? For example, if the user does not have .NET on their machine, the program will not run.

Is there a way to publish the program so it is self-contained in a single executable file?

Thanks for help.

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

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

发布评论

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

评论(4

盗梦空间 2024-07-23 19:31:32

我认为 ClickOnce 部署可执行文件是实现这一目标的最接近的选择。
这里有一个关于如何执行此操作的很好的教程:ClickOnce 部署

I think a ClickOnce deployment Executable is your closest bet to achieving this.
Here's a nice tutorial on how to do that: ClickOnce Deployment

坦然微笑 2024-07-23 19:31:32

正如我提到的,Microsoft 提供了 ILMerge,但如果您不想使用第三方应用程序,那么您可以自己编写代码。 您的客户端仍然需要 .Net Framework,但它允许您隐藏依赖项。 如果您还想包含 .Net dll,则必须在引用设置中将引用设置为“复制本地”。

该程序要求您将 dll 添加为资源。 每当您的程序需要该 dll 时,它都会使用程序集解析挂钩按需加载它。 如果您有多个 dll,则必须有一个 switch case 或一个列表查找,以根据 ResolveEventArgs.Name 加载正确的 dll。

Module Program
    ''//Entry Point add dependency resolver hook
    Sub Main()
        AddHandler AppDomain.CurrentDomain.AssemblyResolve, _
                   AddressOf AssemblyReslover
    End Sub

    Private Function AssemblyReslover(ByVal sender As Object, _
                                  ByVal e As ResolveEventArgs) _
                                  As Assembly
       ''//ReferenceAssembly
        Dim ra As Assembly
        ra = Assembly.Load(My.Resources.MyDLL)
        Return ra
    End Function

End Module

http://support.microsoft.com/kb/837908

As I mentioned Microsoft offers ILMerge but if you do not want to use a 3rd party application this is how you would code it yourself. Your client will still need the .Net Framework but it will allow you to hide your dependencies. If you want to include .Net dlls as well you must set your references to "copy local" in the references setting.

This program requires that you add your dll as a resource. Whenever your program requires that dll it will load it on demand by use of the assembly resolve hook. If you had multiple dlls you would have to have a switch case or a list look up that loaded the correct dll based upon ResolveEventArgs.Name.

Module Program
    ''//Entry Point add dependency resolver hook
    Sub Main()
        AddHandler AppDomain.CurrentDomain.AssemblyResolve, _
                   AddressOf AssemblyReslover
    End Sub

    Private Function AssemblyReslover(ByVal sender As Object, _
                                  ByVal e As ResolveEventArgs) _
                                  As Assembly
       ''//ReferenceAssembly
        Dim ra As Assembly
        ra = Assembly.Load(My.Resources.MyDLL)
        Return ra
    End Function

End Module

http://support.microsoft.com/kb/837908

时光匆匆的小流年 2024-07-23 19:31:32

Red Gate Smart Assembly 可以将 .NET 程序集编译为独立的可执行文件。 它可以将所有依赖项嵌入到可执行文件中。

它不是免费的,但它确实附带了其他非常有用的工具。 我们最近开始使用它,到目前为止它非常有用。

https://www.red-gate.com/products/smart assembly/index.html嗯

Red Gate Smart Assembly can compile a .NET assembly into a stand-alone executable. It can embed all dependencies into the executable.

It is not free, but it does come with other very useful tools. We have started using this recently and so far it has been pretty useful.

https://www.red-gate.com/products/smartassembly/index.htm

夏雨凉 2024-07-23 19:31:32

我不认为 .NET 程序通常可以制作成独立的程序,因为 .NET 框架被设计为与程序分离。 但是,您是否考虑过在使用可分发的安装过程中安装框架 .NET 包? 这将确保用户拥有最新版本的 .NET(如果他们还没有的话)。

(我在这里链接到 2.0 软件包,您可能需要更新的版本。)

I don't think .NET programs can normally be made into standalone programs since the .NET framework is designed to be separate from the program. However, have you considered installing the framework during your installation using the distributable .NET package? That would make sure that the users have the latest version of .NET if they don't already.

(I've linked to the 2.0 package here, you may need a newer version.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文