简体   繁体   English

运行 C# clickonce 控制台应用程序

[英]Running C# clickonce console app

I have a Command line console app that references a dll 'VMware.Vim.dll', but this has other referenced dll's like VimService41.dll, VimService20.dll etc saved off in the GAC on my local machine. I have a Command line console app that references a dll 'VMware.Vim.dll', but this has other referenced dll's like VimService41.dll, VimService20.dll etc saved off in the GAC on my local machine. I want to deploy this exe to any computer and be able to run it by passing arguments.我想将此 exe 部署到任何计算机上,并能够通过传递 arguments 来运行它。 When I copy over the exe and VMware.Vim.dll, it complains about the other missing dll's although they are not part of the release folder.当我复制 exe 和 VMware.Vim.dll 时,它抱怨其他缺少的 dll,尽管它们不是发布文件夹的一部分。

I tried the Publish option and created a ClickOnce Application to deploy it to the machine I want to execute the exe from.我尝试了发布选项并创建了一个 ClickOnce 应用程序以将其部署到我要从中执行 exe 的机器上。 This created a setup.exe and a manifest file.这创建了一个 setup.exe 和一个清单文件。 When I run it, it complains that the external dlls have not been added to the GAC.当我运行它时,它抱怨外部 dll 尚未添加到 GAC。

How do I run this clickonce console app by passing arguments?如何通过传递 arguments 来运行这个 clickonce 控制台应用程序?

First, you don't run a ClickOnce application by running the EXE.首先,您不会通过运行 EXE 来运行 ClickOnce 应用程序。 If you're going to do that, just xcopy the bin folder from your build over to the machine.如果您要这样做,只需将 bin 文件夹从您的构建复制到机器上。 You're wasting your life using ClickOnce if you don't need to do automatic updates.如果您不需要进行自动更新,那么使用 ClickOnce 就是在浪费生命。

Second, you can try tracking down all of the dll's that you need and including them in the project.其次,您可以尝试跟踪您需要的所有 dll 并将它们包含在项目中。 This includes all of the secondary or tertiary dependencies.这包括所有二级或三级依赖项。 Add them to your project, set the build action to "content", and set "copy to output directory" to "copy always".将它们添加到您的项目中,将构建操作设置为“内容”,并将“复制到 output 目录”设置为“始终复制”。 Then they will be included in the output directory when you build.然后它们将在您构建时包含在 output 目录中。

Some applications' dll's will work when deployed locally (like DirectX) and some won't (SQLServer Express).一些应用程序的 dll 在本地部署时可以工作(如 DirectX),而有些则不能(SQLServer Express)。 You'll just have to try it and see if these do.你只需要尝试一下,看看这些是否有效。

I would say, however, that using VMWare assemblies probably is against the EULA.但是,我会说,使用 VMWare 程序集可能违反 EULA。 That's like trying to include Office assemblies in order to run Excel on a machine w/o it installed.这就像试图包含 Office 程序集以便在没有安装它的机器上运行 Excel。

As for passing arguments, if you really DO want to use it as a ClickOnce application, here is a blog entry explaining how to pass arguments to an offline (or online) ClickOnce application:至于传递 arguments,如果您真的想将其用作 ClickOnce 应用程序,这里有一篇博客文章解释了如何将 arguments 传递给离线(或在线)ClickOnce 应用程序:

http://robindotnet.wordpress.com/2010/03/21/how-to-pass-arguments-to-an-offline-clickonce-application/ http://robindotnet.wordpress.com/2010/03/21/how-to-pass-arguments-to-an-offline-clickonce-application/

If you want to use ClickOnce, what you need is to add a custom pre-requisite so that the application installs it's dependencies in the GAC.如果您想使用 ClickOnce,您需要添加一个自定义先决条件,以便应用程序在 GAC 中安装它的依赖项。

Look at: http://msdn.microsoft.com/en-us/library/ms165429(v=VS.100).aspx看: http://msdn.microsoft.com/en-us/library/ms165429(v=VS.100).aspx

I don't think this scenario is an appropriate for click once.我认为这种情况不适合单击一次。 If you need to install things which modifying the gac is then you need to use an installer.如果您需要安装修改 gac 的东西,那么您需要使用安装程序。

If you can find all the dependencies you can include them (by setting them to copy local in VS) with the release and then you shouldn't have a problem.如果您可以找到所有依赖项,则可以将它们包含在发行版中(通过将它们设置为在 VS 中复制本地),那么您应该没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在C#控制台应用程序中运行C ++控制台应用程序 - Running a c++ console app inside a C# console app c# ClickOnce,通知应用程序更新 - c# ClickOnce , notify app of the updates 当从Visual Studio(而不是ClickOnce发布版本)运行C#WPF应用程序时,PowerPoint文件打开 - PowerPoint file opens when C# WPF app is running from Visual Studio, but not from ClickOnce published version 如何将控制台应用程序作为Windows服务运行? 我对MS默认提供的“ ClickOnce”文件感到困惑(VS 2008,C#) - How to run a console app as a windows service? I'm getting confused by the “ClickOnce” files MS gives by default (VS 2008, C#) 使用来自C#的参数运行控制台应用程序 - GUI Hookup建议 - Running a console app with arguments from C# - GUI Hookup Advice 在 C# 控制台应用程序中快速运行 ADB Shell 命令 - Running ADB Shell commands rapidly in C# console app 运行内置于记事本++中的c#console app - Running c# console app built in notepad++ StreamWrite(交互)到在C#控制台应用程序中运行的另一个应用程序 - StreamWrite (Interact) to another Application running within a C# Console App 运行控制台应用程序作为集成测试 c# 的一部分 - Running console app as a part of integration test c# 我的 C# 控制台应用程序没有运行正确的计算 - My C# console app is not running the correct calculations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM