小编Rom*_*ory的帖子

pvk2pfx.exe - 找不到

可以告诉我在哪里可以找到文件pvk2pfx.exe吗?它应该位于<programfile>/Visual Studio 8/Common7/Tools/bin/pvk2pfx.exe我的机器上,但不在我的机器上.我似乎也无法在网上找到它.我尝试安装SDK,但它没有用.谢谢.

pfx visual-studio

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

变体和开放式泛型IReadOnlyList

我试图理解为什么c#中有关变体和泛型的特定行为无法编译.

class Matrix<TLine> where TLine : ILine
{
    TLine[] _lines;

    IReadOnlyList<ILine> Lines { get { return _lines; } } //does not compile
    IReadOnlyList<TLine> Lines { get { return _lines; } } //compile
}
Run Code Online (Sandbox Code Playgroud)

我不明白为什么这不起作用:

  • _lines属于类型TLine[],实现IReadOnlyList<TLine>
  • IReadOnlyList<out T>是一个变体通用接口,据我所知,这意味着任何实现IReadOnlyList<TLine>都可以用作IReadOnlyList<ILine>

我觉得必须是因为不考虑类型约束,但我对此表示怀疑.

c# generics

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

在meteor.js中使用继承

我一直希望在Meteor中使用继承,但我在文档或Stack Overflow上找不到任何关于它的内容.

是否可以让模板从另一个抽象模板或类继承属性和方法?

javascript model-view-controller inheritance meteor

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

控制台应用程序中的.NET Core Global异常处理程序

我正在移植一个控制台应用程序.NET Core,我正在尝试替换此行:

AppDomain.CurrentDomain.UnhandledException += UnhandledException;
Run Code Online (Sandbox Code Playgroud)

看完这个,似乎没有内置的方式做到这一点.

所以我的问题是:用一个替换围绕我的整个代码的这一行的唯一方法是try/catch

通过阅读本文,似乎还有另一种方式,即继续使用System.AppDomain,但我似乎无法找到这个类/方法.我唯一的猜测是这个库,但它清楚地表明如果可能的话不应该使用它,所以我不愿意.

.net c# exception-handling console-application .net-core

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

不区分大小写的模型绑定 MVC 4

我希望我的模型绑定不区分大小写。

我尝试操作从 继承的自定义模型绑定器System.web.Mvc.DefaultModelBinder,但我不知道在哪里添加不区分大小写的内容。

我也看了看IValueProvider,但我不想重新发明轮子并自己找到值。

任何的想法 ?

asp.net-mvc model-binding custom-model-binder value-provider asp.net-mvc-4

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

EF和TPT:在SET子句中多次指定列名

我正在使用EF 6并使用TPT策略来模拟我的问题. Rule是一个抽象类.OvertimeRule是一个具体的类,继承自Rule.

Rule 看起来像这样:

public abstract class Rule
{   
    public int Id { get; set; }
    public PeriodType PeriodType { get; set; }
    public int SortOrder { get; set; }
    public int StatuteId { get; set; }
    public bool IsActive { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

OvertimeRule 看起来像这样:

public partial class OvertimeRule : Rule
{
    public decimal? ThresholdCoefficient { get; set; }
    public decimal? LimitCoefficient { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

当我创建一个新的OvertimeRule并尝试保存它时,EF首先生成此查询:

INSERT [dbo].[Rules]([PeriodType], …
Run Code Online (Sandbox Code Playgroud)

c# sql-server inheritance entity-framework

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

在简单注入器中注册部分开放的泛型

我正在尝试注册一个开放的通用接口IService<T1>并使用以下部分开放的实现类来解决它Service<T0, T1>。在这种情况下,T0是固定的,并且T1fromServiceIService是相同的。

理想情况下,它看起来像这样:

container.Register<IService<>, Service<ExplicitType,>>(Lifestyle.Singleton);

但这是不正确的c#。

我的问题是:

  • 那有意义吗 ?或者,还有更好的方法。Service<ExplicitType,>如果可能的话,我想避免上课。
  • 有可能吗?

我发现优秀的文档对这个问题没有帮助。

c# generics dependency-injection simple-injector

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

可为空的引用类型和任何模式

我正在尝试使用C#8.0中的新Nullable引用类型,并且遇到了这个问题。给定这个结构

public readonly struct Either<TReturn, TError>
    where TReturn : struct
    where TError : struct
{
    public TError? Error { get; }
    public TReturn? Response { get; }

    public Either(TError? error, TReturn? response)
    {
        if (error == null && response == null)
        {
            throw new ArgumentException("One argument needs not to be null.");
        }
        if (error != null && response != null)
        {
            throw new ArgumentException("One argument must be null.");
        }
        Error = error;
        Response = response;
    } …
Run Code Online (Sandbox Code Playgroud)

c# nullable c#-8.0

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