net中的Clickonce问题

net中的Clickonce问题

本文介绍了点击.net中的Clickonce问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我在.net中创建了一个应用程序,该应用程序将从该应用程序调用一个第三方.exe。所以我将.exe与我的应用程序一起包含并将属性设置为复制到输出dirctory =复制始终和构建操作=内容

i创建了一次此应用程序的单击,并且单击一次工作正常。



同一个应用程序给出了签名并创建了一次点击,但是clickonce不是工作文件,它显示错误

那个.exe已经存在在临时路径中





如何解决这个问题



在此先感谢

Here i created an application in .net and that application will call one third party .exe from that application. So i include that .exe along with my application and made property as Copy to out put dirctory=Copy always and Build Action=Content
i created a click once of this application, and the click once is working fine.

The same application a gave signing and create click once , but the clickonce is not working file , it shows an error that
"That .exe is already exists" in the temp path


How can i solve this issue

Thanks in advance

推荐答案

string exeName = "test.exe";
string dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (!System.IO.Directory.Exists(dirName)) System.IO.Directory.CreateDirectory(dirName);
string dllPath = System.IO.Path.Combine(dirName, exeName);
if (!File.Exists(dllPath))
{
    using (System.IO.Stream stm = Assembly.GetExecutingAssembly().GetManifestResourceStream("Assembly name where we save that exe" + "." + exeName))
    {
        // Copy the assembly to the temporary file
        try
        {
            using (System.IO.Stream outFile = System.IO.File.Create(dllPath))
            {
                const int sz = 4096;
                byte[] buf = new byte[sz];
                while (true)
                {
                    int nRead = stm.Read(buf, 0, sz);
                    if (nRead < 1)
                        break;
                    outFile.Write(buf, 0, nRead);
                }
            }
        }
        catch
        {
        }
    }
}





这里的dllPath是.exe,所以我们可以从代码中调用这个exe作为







Here in "dllPath" , is the .exe , so we can call this exe from code as


Process p = new Process();
p.StartInfo.Arguments = "coma separated arguments"
p.StartInfo.CreateNoWindow = false;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName = dllPath ;
p.Start();


这篇关于点击.net中的Clickonce问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 23:50