Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在C中获取installerclass中的msi路径#_C#_Windows Installer_Managedinstallerclass - Fatal编程技术网

C# 如何在C中获取installerclass中的msi路径#

C# 如何在C中获取installerclass中的msi路径#,c#,windows-installer,managedinstallerclass,C#,Windows Installer,Managedinstallerclass,我想知道msi在InstallerClass中的路径,我在安装程序中将其用作自定义操作 我尝试在上下文中使用路径、SrcDir等属性。参数,但这些值不存在(抛出NullReferenceException)。是否有其他方法获取该路径,或者这些值为空的原因 谢谢您需要通过VS: /sourceDir="[SourceDir]\" 然后,使用上下文检索它: string path = Context.Parameters["SourceDir"]; Installer类有很多限制,并且在失败时表

我想知道
msi
InstallerClass
中的路径,我在安装程序中将其用作自定义操作

我尝试在
上下文中使用
路径
SrcDir
等属性。参数
,但这些值不存在(抛出
NullReferenceException
)。是否有其他方法获取该路径,或者这些值为空的原因


谢谢

您需要通过VS:

/sourceDir="[SourceDir]\"
然后,使用上下文检索它:

string path = Context.Parameters["SourceDir"];

Installer类有很多限制,并且在失败时表现非常糟糕(脆弱)。我建议您在Windows安装程序XML(WIX)中使用部署工具基金会(DTF)查看C托管的自定义操作。这个项目类型的输出是C++的,并且可以被VisualStudio安装和部署项目(我也不会使用)所消耗。MSI实际存在的位置或执行代码的位置???@Sumit:我想知道MSI实际存在的位置…它可以工作,但对于vs2010,您将在安装程序类代码中获得和额外的“\”,您必须删除这些“\”。有谁能告诉我可以在哪里设置“/sourceDir=“[sourceDir]\“?@Roshil,可能已经晚了4年,但以下是你问题的答案:你必须创建一个类库并向其中添加一个安装程序类。在这种情况下,您可以覆盖Install来执行您想要的操作。然后在安装和部署项目中,右键单击并转到“查看->自定义操作”。在安装下添加“MyInstallerClassLibrary的主输出(活动)”。单击该按钮时,可以将CustomActionData参数设置为/SrcDir=“[SourceDir]\”。然后在类库中,您可以使用以下.Context.Parameters[“SrcDir”]访问该目录。