小编Rob*_*aap的帖子

必须在方法'Skip'Exception之前调用'OrderBy'方法

我试图实现jQgrid使用MvcjQgrid,我得到了这个例外.

System.NotSupportedException was unhandled by user code
  Message=The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.
Run Code Online (Sandbox Code Playgroud)

虽然在Skip方法之前使用OrdeyBy为什么它会产生异常?怎么解决?

我在控制器中遇到异常:

public ActionResult GridDataBasic(GridSettings gridSettings)
        {          
            var jobdescription = sm.GetJobDescription(gridSettings);
            var totalJobDescription = sm.CountJobDescription(gridSettings);

            var jsonData = new
            {
                total = totalJobDescription / gridSettings.PageSize + 1,
                page = gridSettings.PageIndex,
                records = totalJobDescription,
                rows = (
                    from j in jobdescription
                    select new
                    {
                        id = j.JobDescriptionID, …
Run Code Online (Sandbox Code Playgroud)

linq-to-entities entity-framework asp.net-mvc-3 mvcjqgrid

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

如何在不重新启动应用程序的情况下重新配置Serilog?

在长时间运行的进程(例如Windows服务或ASP.NET应用程序)中,有时需要暂时提高日志级别而不停止应用程序.NLog可以监视日志记录配置文件,并在每次修改时重新读取它们.

https://github.com/nlog/NLog/wiki/Configuration-file#automatic-reconfiguration

Serilog也可以吗?

logging serilog

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

将不加载包含文件名的文件名中的嵌入式资源

我正在尝试在类库中嵌入一些电子邮件模板.这很好用,直到我使用包含带有以下表示法的文化名称的文件名:templatename.nl-NL.cshtml资源似乎不可用.

示例代码:

namespace ManifestResources
 {
    class Program
    {
        static void Main(string[] args)
        {
            var assembly = Assembly.GetExecutingAssembly();

            // Works fine
            var mailTemplate = assembly.GetManifestResourceStream("ManifestResources.mailtemplate.cshtml");

            // Not ok, localized mail template is null
            var localizedMailTemplate = assembly.GetManifestResourceStream("ManifestResources.mailtemplate.nl-NL.cshtml");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

模板都将构建操作设置为"EmbeddedResource".

明显的解决方案是使用不同的表示法,但我喜欢这种表示法.任何人都有解决这个问题的方法吗?

c# localization embedded-resource

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

消息队列循环

我在c#中有一个控制台应用程序,我试图从消息队列接收消息,直到消息队列为空.所以,像,

MessageQueue queue = new MessageQueue();
While(queue.notempty)
{
    queue.receive(...)
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

谢谢.

c# msmq

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

如何检测异步方法体中的源代码更改

我试图在运行时检测类方法的源代码是否已更改。基本上,我检索方法主体 (IL),使用 md5 对其进行哈希处理并将其存储在数据库中。下次检查该方法时,我可以比较哈希值。

public class Changed
{
    public string SomeValue { get; set; }

    public string GetSomeValue()
    {
        return SomeValue + "add something";
    }

    public async Task<string> GetSomeValueAsync()
    {
        return await Task.FromResult(SomeValue + "add something");
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用 Mono.Cecil 来检索方法体:

var module = ModuleDefinition.ReadModule("MethodBodyChangeDetector.exe");

var typeDefinition = module.Types.First(t => t.FullName == typeof(Changed).FullName);

// Retrieve all method bodies (IL instructions as string)
var methodInstructions = typeDefinition.Methods
    .Where(m => m.HasBody)
    .SelectMany(x => x.Body.Instructions)
    .Select(i => i.ToString());

var hash = Md5(string.Join("", methodInstructions)); …
Run Code Online (Sandbox Code Playgroud)

c# il mono.cecil async-await

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