小编Sco*_*ain的帖子

ClickOnce setup.exe失败,但使用Windows共享进行部署时.application文件正常工作

我收到的错误是System.Deployment.Application.DeploymentDownloadException当我尝试为ClickOnce应用程序运行setup.exe时.如果通过网络从原始位置运行它可以正常工作,但如果我setup.exe从服务器上的路径复制,我会收到错误

无法下载应用程序.应用程序缺少必需的文件.

我需要安装程序,因为它安装了最终用户可能没有的一些先决条件(.NET 4).

单击错误窗口中的详细信息按钮可提供以下信息:

PLATFORM VERSION INFO
    Windows             : 6.1.7601.65536 (Win32NT)
    Common Language Runtime     : 4.0.30319.237
    System.Deployment.dll       : 4.0.30319.1 (RTMRel.030319-0100)
    clr.dll             : 4.0.30319.237 (RTMGDR.030319-2300)
    dfdll.dll           : 4.0.30319.1 (RTMRel.030319-0100)
    dfshim.dll          : 4.0.31106.0 (Main.031106-0000)

SOURCES
    Deployment url          : file:///C:/Users/srchamberlain/Downloads/ContractFlowTool.application

ERROR SUMMARY
    Below is a summary of the errors, details of these errors are listed later in the log.
    * Activation of C:\Users\srchamberlain\Downloads\ContractFlowTool.application resulted in exception. Following failure messages were detected:
        + Downloading file:///C:/Users/srchamberlain/Downloads/ContractFlowTool.application did not succeed. …
Run Code Online (Sandbox Code Playgroud)

.net clickonce .net-4.0

22
推荐指数
1
解决办法
3万
查看次数

如果设置了PipeSecurity,则在创建第二个实例时,命名管道服务器会抛出UnauthorizedAccessException

我正在尝试编写一个(提升权限)服务,该服务将与非特权winforms应用程序进行通信.我能够有两个控制台应用程序(一个没有升级)应答来回没问题,但我在服务和winforms应用程序时遇到问题.

管道的第一个实例完美无缺.然而,在我的客户端连接后,我尝试创建一个新实例,以便在第二个客户端连接时准备就绪,但NamedPipeServerStream的构造函数会引发异常

System.UnauthorizedAccessException was unhandled
  Message=Access to the path is denied.
  Source=System.Core
  StackTrace:
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.Pipes.NamedPipeServerStream.Create(String fullPipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, PipeAccessRights rights, SECURITY_ATTRIBUTES secAttrs)
       at System.IO.Pipes.NamedPipeServerStream..ctor(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, PipeSecurity pipeSecurity, HandleInheritability inheritability, PipeAccessRights additionalAccessRights)
       at System.IO.Pipes.NamedPipeServerStream..ctor(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, PipeSecurity pipeSecurity)
       at PipeServer.Server.Client..ctor(String pipeName, List`1 container) …
Run Code Online (Sandbox Code Playgroud)

c# named-pipes .net-3.5

21
推荐指数
2
解决办法
2万
查看次数

是否可以使FolderBrowserDialog的默认路径显示在库中而不是实际的磁盘中?

我知道如果我SelectedPath在显示对话框之前设置,我可以在对话框打开时默认打开文件夹.但是,我想要使用的文件夹按字母顺序排在列表的下方.我有一个与Windows中的一个库相同的文件夹,它显示在列表中,是否有任何方法可以将其默认为文件夹的库版本而不是文件夹的硬盘版本?

另一个可能的解决方案是,如果它仍然使用驱动器版本,但它会自动将窗口向下滚动到选定的位置.有没有办法做这些解决方案?


目前如何显示

在此输入图像描述

我多么希望它出现

在此输入图像描述

.net c# winforms

21
推荐指数
2
解决办法
2万
查看次数

对传递给Task.WhenAll()的任务使用ConfigureAwait(false)失败

我正在尝试决定如何等待所有异步任务完成.

这是我目前的代码

[HttpGet]
public async Task<JsonResult> doAsyncStuff()
{
  var t1 = this.service1.task1();
  var t2 = this.service2.task2();
  var t3 = this.service3.task3();
  var t4 = this.service4.task4();

  await Task.WhenAll(t1,t2,t3,t4);
  return this.Json(new {redirect = true, href = Url.Action("Blah")}, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)

我很确定同步上下文不相关,所以我尝试了这个.

[HttpGet]
public async Task<JsonResult> doAsyncStuff()
{
  var t1 = this.service1.task1().ConfigureAwait(false);
  var t2 = this.service2.task2().ConfigureAwait(false);
  var t3 = this.service3.task3().ConfigureAwait(false);
  var t4 = this.service4.task4().ConfigureAwait(false);

  await Task.WhenAll(t1,t2,t3,t4);
  return this.Json(new {redirect = true, href = Url.Action("Blah")}, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)

问题是现在Task.WhenAll具有无效参数,因为它不接受Configured Task Awaiatables.

所以Task.WhenAll需要替换为此

await t1; await t2; await …
Run Code Online (Sandbox Code Playgroud)

c# asynchronous async-await

20
推荐指数
1
解决办法
5095
查看次数

阵列的所有可能组合

我有一个字符串数组

{"ted", "williams", "golden", "voice", "radio"}
Run Code Online (Sandbox Code Playgroud)

我想要以下形式的所有这些关键字的组合:

{"ted",
 "williams",
 "golden", 
 "voice", 
 "radio",
 "ted williams", 
 "ted golden", 
 "ted voice", 
 "ted radio", 
 "williams golden",
 "williams voice", 
 "williams radio", 
 "golden voice", 
 "golden radio", 
 "voice radio",
 "ted williams golden", 
 "ted williams voice", 
 "ted williams radio", 
 .... }
Run Code Online (Sandbox Code Playgroud)

我已经好几个小时没有有效的结果(高级编程的副作用??).

我知道解决方案应该是显而易见的,但老实说!Java/C#中的解决方案被接受.

编辑:

  1. 这不是一个功课
  2. "泰德威廉姆斯"和"威廉姆斯特德"被认为是一样的,所以我只想要"泰德威廉姆斯"

编辑2:在回答答案中的链接之后,发现Guava用户可以在com.google.common.collect.Sets中使用powerset方法.

java arrays algorithm

17
推荐指数
2
解决办法
3万
查看次数

查询代码速度极慢但SSMS速度快

我有一个相当简单的查询,我不断获得超时(它需要超过三分钟完成,我提前停止,所以我可以发布这个问题)在代码运行时,但是当我从同一台计算机运行相同的查询时在Sql Server Management Studio中,只有2532 ms在服务器上没有缓存数据和524 ms重复查询时,查询才会进行第一次查询.

这是我的c#代码

using (var conn = new SqlConnection("Data Source=backend.example.com;Connect Timeout=5;Initial Catalog=Logs;Persist Security Info=True;User ID=backendAPI;Password=Redacted"))
                using (var ada = new SqlDataAdapter(String.Format(@"
SELECT [PK_JOB],[CLIENT_ID],[STATUS],[LOG_NAME],dt 
FROM [ES_HISTORY] 
inner join [es_history_dt] on [PK_JOB] = [es_historyid] 
Where client_id = @clientID and dt > @dt and (job_type > 4 {0}) {1}
Order by dt desc"
     , where.ToString(), (cbShowOnlyFailed.Checked ? "and Status = 1" : "")), conn))
{
    ada.SelectCommand.Parameters.AddWithValue("@clientID", ClientID);
    ada.SelectCommand.Parameters.AddWithValue("@dt", dtpFilter.Value);
    //ada.SelectCommand.CommandTimeout = 60;
    conn.Open();
    Logs.Clear();
    ada.Fill(Logs); …
Run Code Online (Sandbox Code Playgroud)

c# sql sql-server sql-server-2000 .net-4.0

17
推荐指数
1
解决办法
6102
查看次数

Powershell相当于LINQ的Select命令?

我正在尝试运行以下Powershell脚本.

import-module ActiveDirectory

$computers = Get-ADComputer -filter * -SearchBase "OU=myOU,DC=vw,DC=local" | select-object name

Invoke-Command -ComputerName $computers -ScriptBlock {gpupdate /target:Computer}
Run Code Online (Sandbox Code Playgroud)

这个问题是$computers不是string[]-ComputerName预期.它实际上是一个ADComputer带有一个名为name的参数的数组.

# Get-ADComputer -filter * -SearchBase "OU=myOU,DC=vw,DC=local" | select-object name | Format-Custom

class ADComputer
{
  name = PC1
}

class ADComputer
{
  name = PC2
}

class ADComputer
{
  name = PC3
}
Run Code Online (Sandbox Code Playgroud)

获取名称字符串数组的正确方法是什么?如果我在C#,我知道它会

string[] computerNames = computers.Select(computer => computer.name).ToArray();
Run Code Online (Sandbox Code Playgroud)

但我想学习如何正确地在Powershell中做到这一点.

.net c# linq powershell

16
推荐指数
1
解决办法
8880
查看次数

我可以在.NET 2.0或3.0中使用扩展方法和LINQ吗?

当我尝试使用.NET 2.0或3.0运行时添加扩展方法时,我收到错误:

无法定义新的扩展方法,因为无法找到编译器所需的类型"System.Runtime.CompilerServices.ExtensionAttribute".您是否缺少对System.Core.dll的引用?

但是当我尝试将它添加到项目中时,我无法在可用引用列表中找到System.Core.我需要做什么才能在我的项目中使用扩展方法和LINQ on?

.net c# extension-methods .net-3.0 .net-2.0

13
推荐指数
1
解决办法
3164
查看次数

强制绑定到DataSource的复选框在尚未查看时进行更新

这是一个测试框架,用于显示我在做什么:

  1. 创建一个新项目
  2. 添加选项卡式控件
  3. 在标签1上放一个按钮
  4. 在选项卡2上放置一个复选框
  5. 将此代码粘贴到其代码中

(使用控件的默认名称)

public partial class Form1 : Form
{
    private List<bool> boolList = new List<bool>();
    BindingSource bs = new BindingSource();
    public Form1()
    {
        InitializeComponent();
        boolList.Add(false);
        bs.DataSource = boolList;
        checkBox1.DataBindings.Add("Checked", bs, "");
        this.button1.Click += new System.EventHandler(this.button1_Click);
        this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);

    }
    bool updating = false;
    private void button1_Click(object sender, EventArgs e)
    {
        updating = true;
        boolList[0] = true;
        bs.ResetBindings(false);
        Application.DoEvents();
        updating = false;
    }

    private void checkBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (!updating)
            MessageBox.Show("CheckChanged fired outside …
Run Code Online (Sandbox Code Playgroud)

c# controls deferred-loading winforms

12
推荐指数
1
解决办法
3044
查看次数

如何保护用户反编译项目的OAuth密钥?

我正在编写第一个使用OAuth的应用程序.这适用于桌面应用程序,而不是访问二进制文件的网站或移动设备,因此我担心如何保护我的应用程序密钥和密钥.我觉得查看编译文件并找到存储密钥的字符串是微不足道的.

我是否过度反应或者这是桌面应用程序的真正问题(使用已知解决方案)?

这个项目是用Java编写的,但我也是一个C#开发人员,所以任何.NET解决方案都会受到赞赏.

编辑:我知道没有完美的解决方案,我只是在寻找缓解解决方案.

编辑2:我知道只有解决方案是使用某种形式的混淆.是否有任何免费的.NET和Java提供程序可以进行字符串混淆?

.net c# java security oauth

12
推荐指数
1
解决办法
2510
查看次数