zoukankan      html  css  js  c++  java
  • 遇到的异常处理

    • A first chance exception of type 'System.Data.Entity.Core.EntityException' occurred in EntityFramework.dll

    Additional information: The underlying provider failed on Open.

    InnerException: {"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"}

    StackTrace: at System.Data.Entity.Core.EntityClient.EntityConnection.Open()

    没有连VPN,数据库连接失败

    • The name '*** ' does not exist in the current context

    刚开始直接在if中定义var keywordfrom1=Convert.ToDateTime(keywordfrom);var keywordto1=Convert.ToDateTime(keywordto);

    不应该在if里面定义keywordfrom1和keywordto1变量,导致query中keywordfrom1和keywordto1报错

                var keywordfrom1 = new DateTime();
                var keywordto1 = new DateTime();
                if (!String.IsNullOrWhiteSpace(keywordfrom))
                {
                    keywordfrom1 = Convert.ToDateTime(keywordfrom);
                }
                else
                {
                    keywordfrom1 = Convert.ToDateTime("1753-1-1 00:00:00");
                }
    
                if (!String.IsNullOrWhiteSpace(keywordto))
                {
                    keywordto1 = Convert.ToDateTime(keywordto);
                }
                else
                {
                    keywordto1 = Convert.ToDateTime("9999-12-31 00:00:00");
                }
    
                var query = db.U_SP_AuditLog.AsQueryable();
                query = query.Where(a => a.ChangedOn >= keywordfrom1 && a.ChangedOn <= keywordto1);    
    • A first chance exception of type 'System.Data.Entity.Validation.DbEntityValidationException' occurred in EntityFramework.dll

    Additional information: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.

    但EntityValidationErrors不能提供具体的错误信息

    将((System.Data.Entity.Validation.DbEntityValidationException)$exception).EntityValidationErrors添加到Watch窗口中就行。

          It's the easiest way I've found to get instant insight into these errors.

    • CompanyName.Demo.Point.x': cannot have instance field initializers in structs
    struct Point
            {
                public int x = 0;//对于结构,不能给里面的变量赋初值
            }
    • Unable to copy file “objDebugproject.dll” to “binproject.dll”. Access to the path 'binproject.dll' is denied

    Go to “bin" folder. View the properties of the dll file and see whether it is marked as "Read Only". If read only check box checked, uncheck it.、

  • 相关阅读:
    JNI中java类型的简写
    JNI 资源释放
    【翻译自mos文章】当指定asm disk 为FRA时,11.2.0.3的dbua hang住
    Codeforces 85D Sum of Medians(线段树)
    Win8.1应用开发之异步编程
    VC++的内联汇编
    WPF实现界面动态布局
    找唯一不出现三次而出现1次的数子O(n)位运算算法
    模块管理常规功能自己定义系统的设计与实现(31--第三阶段 权限设计[1])
    Codeforces Round #FF (Div. 2):C. DZY Loves Sequences
  • 原文地址:https://www.cnblogs.com/chrisghb8812/p/5596415.html
Copyright © 2011-2022 走看看