小编Ed *_*pel的帖子

在安装过程中检测并需要Windows QFE /补丁

我们的WiX安装程序将.NET 4.0 WinForms应用程序部署到Windows Vista和7台桌面.该应用程序包括一个需要.NET补丁可移植类库(KB2468871).我们需要安装补丁作为先决条件.有多种方法可以应用补丁:

  1. 下载KB2468871补丁并安装它
  2. 安装可移植库工具
  3. 作为使用ClickOnce的先决条件(可能是#1的变体)

使用类似问题的建议,我创建了一个CustomAction检查QFE(#1),我发现它在找到时返回true.

private static bool IsPatchAlreadyInstalled()
{
    // If the patch is installed, we can find it using WMI
    var query = new SelectQuery("SELECT HotFixID FROM Win32_QuickFixEngineering WHERE HotFixID = 'Q2468871' OR HotFixID = 'KB2468871'");
    var results = new ManagementObjectSearcher(query).Get();
    return results.Count > 0;
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,由于补丁是作为工具(#2)的一部分安装的,因此在我的开发机器上失败了.我还没有目睹情况#3.

检测补丁是否已应用的更好方法是什么?

.net c# windows windows-installer wix

15
推荐指数
3
解决办法
5081
查看次数

SlickGrid选择编辑器

我想为选择的单元格进行动态填充的html选择.我从数据库中提取一些信息,这些信息对于每个行项都是不同的.问题是编辑器丢失了初始数据,我不知道如何为特定单元格保留一些数据.有人曾经这样做过吗?

function StandardSelectCellEditor($container, columnDef, value, dataContext) {
var $input;
var $select;
var defaultValue = value;
var scope = this;

this.init = function() {
    $input = $("<INPUT type=hidden />");
    $input.val(value); 
    }

    $input.appendTo($container);

    $select = $("<SELECT tabIndex='0' class='editor-yesno'>");
    jQuery.each(value, function() {
      $select.append("<OPTION value='" + this + "'>" + this + "</OPTION></SELECT>");
    });
    $select.append("</SELECT>");

    $select.appendTo($container);

    $select.focus();
};


this.destroy = function() {
    //$input.remove();
    $select.remove();
};


this.focus = function() {
    $select.focus();
};

this.setValue = function(value) {
    $select.val(value);
    defaultValue = value;
};

this.getValue = function() { …
Run Code Online (Sandbox Code Playgroud)

javascript jquery slickgrid

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

AutoMapper.AutoMapperMappingException:类型'System.String'没有默认构造函数

在最短的一两周内,我们的代码中出现了一个奇怪的错误.我试图找出映射失败的根本原因.最内在的异常本身令人费解:Type 'System.String' does not have a default constructor

我不明白异常告诉我的是什么.你能解释一下发生了什么,也许我可以解决这个错误吗?

映射器在通用方法中使用:

public TEntity UpdateWithHistory<TEntity>(TEntity entity, int? entityID, int? interviewID)
where TEntity : class
{
    var snapshot = _interviewContext.Find<TEntity>(entityID);

    // This is call that fails
    var history = Mapper.Map<TEntity, TEntity>(snapshot);

    _interviewHistory.Set<TEntity>().Add(history);
    MarkModified(entity);
    return Mapper.Map(entity, snapshot);
}
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,快照不是null.完整的例外情况:

AutoMapper.AutoMapperMappingException:
Trying to map Recog.Web.Models.InterviewComment to Recog.Web.Models.InterviewComment.
Using mapping configuration for Recog.Web.Models.InterviewComment to Recog.Web.Models.InterviewComment
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
  ---> AutoMapper.AutoMapperMappingException: Trying to map System.String to System.String.
       Using mapping configuration for System.String to …
Run Code Online (Sandbox Code Playgroud)

c# automapper

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

触发与存储过程

我有一个更新表中标志的存储过程和一个删除更新行的触发器并将其插入新表中.因此,可以在存储过程中添加触发器的相同功能.所以我只想知道:

哪个更好用:存储过程或触发器?在什么情况下?换句话说,你能告诉我每个人的优点和缺点吗?

请注意,我正在使用SQL Server 2008,我正在将VB.NET连接到我的数据库.

vb.net sql-server triggers stored-procedures sql-server-2008

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

在非UI线程上运行RIA服务

我试图从非UI线程进行RIA服务调用.
我通过打开新线程和后台工作程序进行了调用,但是对于这两种情况,回调都在UI线程上运行.
是否可以在调用者线程上执行回调,而不是UI?
谢谢

silverlight multithreading backgroundworker wcf-ria-services

4
推荐指数
1
解决办法
622
查看次数

ASP.NET MVC 4 ApiController和常规控制器路由

我有一个仅用于向我们的应用程序发出API请求的项目,而我们正在使用ASP.NET MVC 4项目。我们有一些从ApiController派生的控制器,而另一些从普通Controller类派生的控制器。问题是我不希望ApiControllers的默认路由api/XXXXX/。我希望ApiController与非Api控制器使用相同的路由{controller}/{action}/{id}。我尝试添加以下路线

routes.MapHttpRoute(
    name: "Api",
    routeTemplate: "{controller}/{action}/{id}",
    defaults: new { id = RouteParameter.Optional }
);

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)

这样就可以使用常规{controller}/{action}路由访问我的ApiController,但是不再可以访问“常规”控制器。如果我摆脱MapHttpRoute了相反的情况。

是否可以通过相同的url路由访问ApiControllers和“普通”控制器?

asp.net-mvc asp.net-mvc-4 asp.net-apicontroller

4
推荐指数
1
解决办法
3113
查看次数

实体框架:如何在Entity Framework中将模型设置为Serializable

using System;
using System.Collections.Generic;
[Serializable]
public partial class user
{
    public int UserId { get; set; }
    public string Name { get; set; }
    public string Surname { get; set; }
    public string UserName { get; set; }
    public string Email { get; set; }
    public string Password { get; set; }
    public System.DateTime Creation { get; set; }
    public bool Status { get; set; }
    public int UserTypeId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

正如您在我的代码中看到的那样,我的类被设置为可序列化.但在我更新我的.edmx文件后,此设置被删除.更新edmx文件后如何保留Serializable?

c# asp.net entity-framework entity-framework-5

2
推荐指数
1
解决办法
5991
查看次数

WPF动画的DataGridRow背景颜色从透明变为“当前”(通过“触发器”设置当前值)

DataGridRow BackgroundColor根据触发LogError值设置为绿色或红色。

我想为新添加的行设置透明度。

这很好用:

From="Transparent" To="Red"
Run Code Online (Sandbox Code Playgroud)

但是我想要的颜色是使用Style设置的当前颜色。它并不总是红色,也可能是绿色。

这不起作用:

From="Transparent" To="{TemplateBinding DataGridRow.Background}"
Run Code Online (Sandbox Code Playgroud)

要么

From="Transparent" To="{Binding RelativeSource={RelativeSource Self}, Path=Backgound}"
Run Code Online (Sandbox Code Playgroud)

码:

<DataGrid.Resources>
  <Style TargetType="{x:Type DataGridRow}">
    <Setter Property = "Background" Value="LimeGreen"/>
    <Style.Triggers>
      <DataTrigger Binding="{Binding LogMessage}" Value="Exception has occured">
        <Setter Property = "Background" Value="Red"/>
      </DataTrigger>
    </Style.Triggers>
  </Style>
</DataGrid.Resources>          
<DataGrid.RowStyle>
  <Style TargetType="DataGridRow">
    <Style.Triggers>
      <EventTrigger RoutedEvent="Loaded">
        <BeginStoryboard>
          <Storyboard>
            <ColorAnimation
                Storyboard.TargetProperty="(DataGridRow.Background).(SolidColorBrush.Color)" 
                Duration="00:00:03" 
                From="Transparent"
                To="{TemplateBinding DataGridRow.Background}"/>
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger>
    </Style.Triggers>
  </Style>
</DataGrid.RowStyle>
Run Code Online (Sandbox Code Playgroud)

错误信息: Cannot freeze this Storyboard timeline tree for use across threads.

wpf

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

如何对字符串数组进行包含?

我正在使用谓词构建器类,我需要在字符串数组上调用contains方法,因此在下面的代码而不是radio中我会传入一个字符串数组:

wherePredicate = wherePredicate.Or(m => m.MediaType.Contains("Radio"));
Run Code Online (Sandbox Code Playgroud)

完整的代码部分:

if (param.iMediaGroupID > 0)
{
    var wherePredicate = PredicateBuilder.False<MediaChannelModel>();

    var ss = new NeptuneRepository<Lookup_MediaTypes>();
    var mediagroups = ss.FindWhere(m => m.MediaGroupID == param.iMediaGroupID).Select(m => m.Name);
    //problem area
    wherePredicate = wherePredicate.Or(m => mediagroups.Contains(m.MediaType));
    predicate = predicate.And(wherePredicate);
}
Run Code Online (Sandbox Code Playgroud)

mediaGroups 是: ["Radio","Tv","Magazine"]

如果m.MediaType是这些值中的任何一个,则谓词为真.

有没有办法在C#中做到这一点?

c# linq predicatebuilder

0
推荐指数
1
解决办法
806
查看次数

ConsoleApplication中的公共静态void

我做第一次控制台应用程序.我有WinformApp,我将代码复制到ConsoleApp.我有问题,我不知道怎么能从静态虚空主跳到公共静态无效发送.这是我的代码的样本......

class Program
{
    static void Main(string[] args)
    {
        int counter; //Counter pro export
        int counterchyba;
        string strediska = "0003,0005";                                   
    }

    public static void Sending(int counter, int counterchyba, string strediska)
    {
        var c = (counter).ToString().PadLeft(5, '0');
        SqlCommand cmd = new SqlCommand();
        .........
    }
}
Run Code Online (Sandbox Code Playgroud)

你知道怎么回事吗?

c# console-application

0
推荐指数
1
解决办法
155
查看次数

使用c#将多个参数传递给外部exe程序时出现问题

我有一个exe文件,我试图通过c#传递参数.代码如下

class Class1
{
    static void Main()
    {
        string[] arg;
        arg = new string[3];
        Process p = new Process();

        p.StartInfo.FileName = @"D:\xxx.exe";
        for (int i = 0; i < 3; i++)
        {
            arg[i]  = Console.ReadLine();
        }

        p.StartInfo.Arguments = arg[0] + " " + arg[1] + " " + arg[2];
        p.Start();
    }
}
Run Code Online (Sandbox Code Playgroud)

我打开一个控制台,然后在那里写出参数.只要我打完3个参数,我做一个串出的3个参数,然后调用Process.Start()与在参数p.StartInfo.Arguments字符串.exe文件加载但不生成任何输出.奇怪的是,如果我从我的电脑打开exe文件然后写

Arg1.txt Arg2.txt Arg3.txt

并按下输入exe文件生成输出.但是,相同样式的相同参数当前正在通过C#代码传递,并且它不会生成任何输出.我不明白我做错了什么.关于这一点,StackOverflow有很多问题,我知道,但是他们都提出了与我在这里所做的相同的程序.我也试过给出论点

p.StartInfo.Arguments = "\"arg[0]\"\"arg[1]\"\"arg[2]\"";
Run Code Online (Sandbox Code Playgroud)

但这也没有奏效.

c#

0
推荐指数
1
解决办法
1273
查看次数