小编Con*_*per的帖子

Application.exe is not a valid Win32 application error

I have written a Console application that client is trying to run it on their Windows Server 2003 R2 machine machine and they get that error message.

If I go to Build -> Configuration Manager all my projects are set to Platform of "Any CPU" and Configuration of

"Release"
Run Code Online (Sandbox Code Playgroud)

What else I might have missed? They don't want to actually run the console application by double clicking on it, they want to give it to the Windows schedules tasks so …

c# windows-console visual-studio-2012

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

查找字典的不同值

我有一个GroupSummary class像这样的属性:

public class GroupsSummary
{
    public bool FooMethod()
    {
      ////
    }
    public bool UsedRow { get; set; }

    public string GroupTin   { get; set; }
    public string PayToZip_4 { get; set; }
    public string PayToName  { get; set; }

    public string PayToStr1     { get; set; }
    public string PayToStr2     { get; set; }
    public string PayToCity     { get; set; }
    public string PayToState    { get; set; }
    public bool   UrgentCare_YN { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

然后我有一个Dictionary …

c# linq

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

如何使用 EPPlus 将新工作表添加到现有 Excel 文件中?

使用 EPPlus 我想向 Excel 文件添加一个新工作表,但我不想删除文件中的现有工作表(如果有),我想将其作为文件中的第一张工作表插入。这是我为快速测试而编写的内容,但它会删除所有现有工作表:

using (ExcelPackage p = new ExcelPackage())
{
    p.Workbook.Worksheets.Add("HubaHuba");
    p.Workbook.Worksheets.MoveToStart("HubaHuba");
    ExcelWorksheet ws = p.Workbook.Worksheets[1];
    ws.Name = "HubaHuba";

    var cell = ws.Cells[1, 1];
    cell.Value = "dfsdfsdfsd";
    cell = ws.Cells[1, 2];
    cell.Value = "347895y5 Oh";

    Byte[] bin = p.GetAsByteArray();
    File.WriteAllBytes(path,bin);
}
Run Code Online (Sandbox Code Playgroud)

c# epplus

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

检查Int32.TryParse的方法更简单

我在代码中的方法中看到了很多这些:

int num1 = 0;
if (Char.IsDigit(myStr[2]) && Int32.TryParse(myStr[2].ToString(), out num1) == false)
{
    valid = false;
}
Run Code Online (Sandbox Code Playgroud)

那么他们只是确保第三个字符为数字吗?

c#

4
推荐指数
2
解决办法
580
查看次数

首先按大写字母排序

目前在我的查询中我说orderby t.Description,我得到:

1st street
2 burritos
Allergy
Ameripath
Application
APK THD
Run Code Online (Sandbox Code Playgroud)

如何更改排序以获取此信息:

1st street
2 burritos
APK THD
Allergy
Ameripath
Application
Run Code Online (Sandbox Code Playgroud)

所以现在仍然是描述,但大写字母首先出现

c# linq linq-to-entities

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

展平字符串字典

我有这行代码:

Dictionary<string,string> alreadyThere = GetItFromFooMethod();
List<string> flatList = alreadyThere.Values.SelectMany(a => a).ToList();
Run Code Online (Sandbox Code Playgroud)

但我得到这个编译错误:

Cannot implicitly convert type 'System.Collections.Generic.List<char>' to 'System.Collections.Generic.List<string>'
Run Code Online (Sandbox Code Playgroud)

为什么它认为我需要char?我该如何解决?

c# linq

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

LINQ中的GroupBy如何工作?

我原本有一本<string, List<ProviderSummary>>叫做的字典rowsDictionary

现在,对于该字典的每个键,我按照以下标准对其值列表进行分组:

    Dictionary<string, List<ProviderSummary>> providerGroups = rowsDictionary.ToDictionary(
            x => x.Key,
            v => v.Value.GroupBy(x => new { x.GroupID, x.GroupFin, x.ZipCode })
                      .Select(x => x.First())
                      .ToList());
Run Code Online (Sandbox Code Playgroud)

例如,如果key["1234"]最初在其值列表中有6个项目,那么现在它可能有两个基于该分组的项目.我的问题和困惑是其他价值观会发生什么?(这四个)以及将为这组返回的这两个列表的值是什么?

c# linq linq-group

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

使用#if DEBUG和Main参数

我在我的控制台应用程序中编写了这段代码:

#if DEBUG
            args = new[] {"4478676e34432432434"};
#endif

            if (args == null)
            {
                Console.WriteLine("Please enter IP for single testing for now.");
            }
Run Code Online (Sandbox Code Playgroud)

当测试人员想要测试我的应用程序并忘记输入参数来运行应用程序时,我仍然希望他看到该消息.但现在它不会这样做.这是否意味着我是否应该将构建也放在" Release"?这是否"DEBUG"意味着如果我们在VS IDE或者它是否意味着如果我们在调试/发布版本中?

c#

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

是否通过Ascii代码在LINQ中进行排序?

在我的LINQ to Entities查询中,我有一个.orderby f.Description.Trim()命令原因.Trim()是来自DB的一些数据在它们的开头有一堆空格,所以我想修剪那些它们不会影响排序.

现在它正确排序但我在结果中看到这样的东西:

[Queries - Blah]
Action
Adhere
Azalia
Run Code Online (Sandbox Code Playgroud)

然后我查了ASCII代码,"["它是91,而"A"是65那么为什么一个首先出现?也许在代码中有一些其他的东西导致这种情况并且排序很好?

c# linq

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

在 SQL Server Management Studio 中更改默认数据库

当我打开 SQL Server Management Studio 时,我在那里列出了许多数据库,如果我打开一个数据库并打开它的表列表并右键单击一个表并说它Select Top 1000 rows正确查询该数据库的该表,但它也会自动选择TempDb作为工具栏中可用数据库组合框中的数据库,如下图所示。

在此处输入图片说明

所以现在如果我想通过单击“新查询”来编写查询,它将查看“tempDB”,这很烦人。有没有办法改变这种行为?

sql-server

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

如何将 PDF 读入内存流?

如何将PDF文件读入memory stream以便我可以将其保存到"Text"列中的数据库中?

c#

-7
推荐指数
1
解决办法
7915
查看次数