小编JRB*_*JRB的帖子

2017年Visual Studio社区无法启动.例外:无法加载文件或程序集'Microsoft.VisualStudio.TelemetryForPPT

在Visual Studio 2017中打开解决方案时,我得到一个弹出窗口说:

An exception has been encountered. This may be caused by an extension.
You can get more information by examining the file '[...]\AppData\Roaming\Microsoft\VisualStudio\15.0_ce1eea42\ActivityLog.xml'.
Run Code Online (Sandbox Code Playgroud)

指定的文件报告与程序集Microsoft.VisualStudio.TelemetryForPPT相关的几个错误:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TelemetryForPPT, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.VisualStudio.TelemetryForPPT, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at GoToDef.GoToDefMouseHandlerProvider.GetAssociatedProcessor(IWpfTextView view) at Microsoft.VisualStudio.Text.Editor.Implementation.InputController.<UpdateMouseHandlers>b__7_0(IMouseProcessorProvider p) at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension,TMetadata,TExtensionInstance](Object errorSource, Lazy`2 provider, Func`2 getter) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure …
Run Code Online (Sandbox Code Playgroud)

startup productivity-power-tools visual-studio-2017

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

从.NET Standard 2.0库中读取app.config

我正在创建一个.NET Framework 2.0库,供.NET Framework 4.6.1应用程序使用.
这个库需要EF Core,但我无法弄清楚如何阅读app.config.

在.NET Framework库中,我会像这样初始化我的DBContext:

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["MyDatabase"].ConnectionString);
}
Run Code Online (Sandbox Code Playgroud)

但我不能这样做,因为在.NET Standard 2.0中找不到ConfigurationManager.
如何从.NET Standard 2.0库中读取配置文件?

.net c# app-config entity-framework-core .net-standard-2.0

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

将ToShortDateString格式化为dd/MM/yyyy

我有这样的日历:

视图

 <td>
     <asp:Calendar ID="Calendar1" runat="server" 
      OnSelectionChanged="DateChange">
     </asp:Calendar>
     <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
 </td>
Run Code Online (Sandbox Code Playgroud)

.Cs文件

protected void Page_Load(object sender, EventArgs e)
    {
        TextBox2.Text = DateTime.Today.ToShortDateString()+'.';
    }

    protected void DateChange(object sender, EventArgs e)
    {
        TextBox2.Text = Calendar1.SelectedDate.ToShortDateString() + '.';
    }
Run Code Online (Sandbox Code Playgroud)

它显示日期为"MM/dd/yyyy",但我想将其显示为"dd/MM/yyyy",我尝试将其更改DateTime.Today.ToShortDateString()+'.';DateTime.Today.ToShortDateString("dd/MM/yyyy");

但我明白了

错误3方法'ToShortDateString'没有重载需要1个参数

我该怎么做才能解决这个问题?

c# asp.net datetime date

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

Linq 的总小时数 (HH:MM)

我的数据库表中有 HH.mm 格式的“TimeClocked”,我想使用 LINQ 对所有“TimeClocked”求和。

我试过这个聚合函数。

var data = _projectDbContext
    .Tasks
    .Where(x => x.Project.CompanyId == companyId && x.Status == true)
    .Select(e => TimeSpan.Parse(e.TimeClocked))
    .Aggregate(TimeSpan.FromMinutes(0), (total, next) => total + next)
    .ToString();
Run Code Online (Sandbox Code Playgroud)

我正在使用EF Core 3.0.0。它显示这样的错误。

Processing of the LINQ expression 'Aggregate<TimeSpan, TimeSpan>(
    source: Select<TaskEntity, TimeSpan>(
        source: Where<TaskEntity>(
            source: DbSet<TaskEntity>, 
            predicate: (x) => x.Project.CompanyId == (Unhandled parameter: __companyId_0) && x.Status == True), 
        selector: (e) => Parse(e.TimeClocked)), 
    seed: (Unhandled parameter: __p_1), 
    func: (total, next) => total + next)' by 'NavigationExpandingExpressionVisitor' failed. …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc entity-framework-core asp.net-core ef-core-3.0

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

实体框架核心错误:没有为此对象定义无参数构造函数

在创建新的 MVC 控制器时:

在此输入图像描述

单击“添加”按钮后,出现以下错误:

在此输入图像描述

这是我的简单 Context 类:

  public class MainDbContext : DbContext
  {
    public MainDbContext(DbContextOptions<MainDbContext> options) : base(options)
    {
    }

    public DbSet<Todo> Todo { get; set; }

  }
Run Code Online (Sandbox Code Playgroud)

和我的简单模型:

public partial class Todo
{
    public int Id { get; set; }
    public string TaskName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我对此问题进行了一些搜索,大多数帖子都指向使用 MVC 的下拉列表或 SelectList 方法,但就我而言,这是控制器创建失败,因此这似乎是Entity Framework Core 问题

有什么帮助吗?

asp.net-mvc entity-framework-core asp.net-core visual-studio-2017

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

C#如何按具有相同属性值的对象对List进行分组

假设我有以下对象

 public class DepartmentSchema
{
    public int Parent { get; set; }
    public int Child { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我有List<DepartmentSchema>以下结果:

Parent | Child
---------------
  4    |   1
  8    |   4
  5    |   7
  4    |   2
  8    |   4
  4    |   1
Run Code Online (Sandbox Code Playgroud)

我想对所有具有相同父值和子值的对象进行分组 分组后我想要的结果是以下列表

 Parent | Child
---------------
  4    |   1
  8    |   4
  5    |   7
  4    |   2
Run Code Online (Sandbox Code Playgroud)

我成功使用 IGrouping =>

departmentSchema.GroupBy(x => new { x.Parent, x.Child }).ToList();

但结果List<IGrouping<'a,DepartmentSchema>>不是List<DepartmentSchema>

我知道我可以创建一个新的 foreach 循环并 …

c# linq

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