小编Jer*_*eer的帖子

处理不同appdomains中的关键异常

让我们假设下面的代码,它允许您在不同的AppDomain中调用一个类并处理几乎所有异常:

using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace MyAppDomain
{
  class Program
  {
    static void Main(string[] args)
    {
      AppDomain myDomain = null;
      try
      {
        myDomain = AppDomain.CreateDomain("Remote Domain");
        myDomain.UnhandledException += new UnhandledExceptionEventHandler(myDomain_UnhandledException);
        Worker remoteWorker = (Worker)myDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(Worker).FullName);
        remoteWorker.VeryBadMethod();
      }
      catch(Exception ex)
      {
        myDomain_UnhandledException(myDomain, new UnhandledExceptionEventArgs(ex, false));
      }
      finally
      {
        if (myDomain != null)
          AppDomain.Unload(myDomain);
      }

      Console.ReadLine();
    }

    static void myDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
    {
      Exception ex = e.ExceptionObject as Exception;
      if (ex != null)
        Console.WriteLine(ex.Message);
      else
        Console.WriteLine("A unknown …
Run Code Online (Sandbox Code Playgroud)

c#

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

如何告诉ASP.Net MVC从JSon反序列化的所有传入日期应该是UTC?

我以UTC格式从我的网络应用程序发送日期,但是当我在服务器端接收它们时,JSon序列化程序(可能通过设置模型使用)使用DateTimeKind.Local相对于本地日期和时间到服务器的时区.

当我做DateTime.ToUniversalTime()时,我得到了正确的UTC日期,所以这不是问题.转换工作正常,日期按照应该的方式发送......但是...... 我不喜欢在模型中的每个日期都调用'ToUniversalTime()',然后将其存储到数据库中...当你有一个大应用程序时,这容易出错并且容易忘记.

所以这里有一个问题:有没有办法告诉MVC传入日期应该始终以UTC格式表示?

c# ajax asp.net-mvc json

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

有没有人在Windows 7上使用Visual Studio 2008?

有没有人已经尝试过这个,我需要注意哪些特殊情况?

visual-studio windows-7

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

标签 统计

c# ×2

ajax ×1

asp.net-mvc ×1

json ×1

visual-studio ×1

windows-7 ×1