none
C#App connection to DB throws A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F) RRS feed

  • Question

  • Since I upgrade my 32bit c# app from .net 3.5 to .net 4, the following code fragment generates the 0x8007001F error from time to time. The command is a simple stored proc that validates the existence of a customer in a table in Sql server 2008. The program runs Windows server 2008 on VM 32bit or 64bit. I have googled this error's cause but find no results.

        public class SqlServerInterface
        {

            public DataSet ExecuteDataset( String connectionString, int commandTimeout, CommandType commandType, String commandText, DatabaseParameter[] commandParameters )
            {
                // Get a new command from the parameters
                using (SqlCommand command = getSqlCommand(connectionString, commandTimeout, commandType, commandText, GetSqlParameters(commandParameters)))
                {

                    // Create an SQL Data Adapter with the command
                    using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                    {
                        // Create a dataset, fill it and return it
                        using (DataSet dataset = new DataSet())
                        {
                            adapter.Fill(dataset);
                            return dataset;
                        }
                    }
                }

            }

    A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)
    System.ApplicationException: A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)
       at System.Threading.TimerBase.AddTimerNative(Object state, UInt32 dueTime, UInt32 period, StackCrawlMark& stackMark)
       at System.Threading.TimerBase.AddTimer(TimerCallback callback, Object state, UInt32 dueTime, UInt32 period, StackCrawlMark& stackMark)
       at System.Threading.Timer..ctor(TimerCallback callback, Object state, Int32 dueTime, Int32 period)
       at System.Data.ProviderBase.DbConnectionPool.CreateCleanupTimer()
       at System.Data.ProviderBase.DbConnectionPool.Startup()
       at System.Data.ProviderBase.DbConnectionPoolGroup.GetConnectionPool(DbConnectionFactory connectionFactory)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPool(DbConnection owningObject, DbConnectionPoolGroup connectionPoolGroup)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
       at SqlServerInterface.ExecuteDataset(String connectionString, Int32 commandTimeout, CommandType commandType, String commandText, DatabaseParameter[] commandParameters) in

    Thursday, July 25, 2013 4:19 PM

All replies

  • Hello,

    Welcome to MSDN Forum !

    According to your description, I know that you connect to DB throws Exception from HRESULT: 0x8007001F ,right? , I try to search the HRESULT Number, it seems to be something wrong with your hardware, however, I'm not sure about this issue. But here there is a similar question with your  issue.

    System.Threading.Timer.Change raising Exception from HRESULT: 0x8007001F:  http://social.msdn.microsoft.com/Forums/vstudio/en-US/ea87e492-75ea-4a47-bae4-ef6d9f8255f9/systemthreadingtimerchange-raising-exception-from-hresult-0x8007001f

    Hope these helps , have a nice day.

    Best Regards,


    Lilia Gong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, July 26, 2013 6:48 AM
    Moderator
  • Hi chrisxiao2013,

    Would you mind letting me know the result of the suggestions? If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

    Have a great day!

    Best Regards,


    Lilia Gong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 30, 2013 8:39 AM
    Moderator
  • Hi Liia,

    The provided links do not seem to provide a solution related to my problem.

    A couple details I should add though.

    1) My application and related assebmly are built using VS2010. App is C# target to .net 4 and  32bit. The app has a thread to call into a DLL (vb.net, target to .net4), which calls the database metheod in 2nd DLL(C#, target .net 2). Both DLLs are marked as visible from COM. It is not necessary as all apps are in .net.

    2) The program runs on VM, instead of phsyical machine.

    3) The problem does not happen all the time. The program starts on Saturday, and clients connect on Sunday. If the problem occurs, we can just restart the program.

    4) I write another test program and test DLL to use to two separate connetion string, one with connection pooling, one without pooling. As I suspect the .net4 freamework may have a problem in connection pooling. However. the program ran fine the past weekend. I will change to change to implement the test DLL in vb.net instead of c#.

    Can you check with Microsoft development team that why System.Threading.TimerBase.AddTimerNative would throw such error? Is it a VM issue?

    Thanks,

    Chris

    Wednesday, July 31, 2013 4:13 PM
  • Hello,

    Thanks for your reply.

    According to your description, In this case,The error occurs  when the program try to call System.Threading.TimerBase.AddTimerNative function,which is used to add a native timer.And the error message we got is which means the program cannot attach to the virtual timer of the VM.

    The timer of VM is not a physical device, but a virtual device,the timer operations of .NET cannot be always right when you run the .NET Framework in a VM.so I think it is better to run a program in a physical machine than a VM.

    Hope these help,have a nice day.

    Best Regards,


    Lilia Gong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 1, 2013 3:22 PM
    Moderator
  • It is understandable if .net did not get the timer once a while. What troubles me that if the problem occurs, it will occur continuously. I do notice the available memory in the box is about 680MB for the four core VM, it's kind of low and leading me to believe the problem is related to system resources.

    However, when I stress my test system with a memory eater, the program will have exception error (mostly out-of-memory) showing very similar call stacks. Once the memory is released, the program will resume working.

    Friday, August 2, 2013 6:56 PM
  • I want to know which virtual machine software do you use?

    Please give me the detail of software version.

    Tuesday, August 6, 2013 4:07 PM
  • The server VM is a windows 2008 R2 64 bit running on Xen Server version 6.0.2 build number 53456p

    Windows details are as following:

    OS Name:                   Microsoft Windows Server 2008 R2 Standard

    OS Version:                6.1.7601 Service Pack 1 Build 7601

    OS Manufacturer:           Microsoft Corporation

    OS Configuration:          Standalone Server

    OS Build Type:             Multiprocessor Free

    Registered Owner:          Windows User

    Registered Organization:

    Product ID:             

    Original Install Date:     6/30/2010, 11:57:06 PM

    System Boot Time:          7/9/2013, 1:48:23 PM

    System Manufacturer:       Xen

    System Model:              HVM domU

    System Type:               x64-based PC

    Processor(s):              4 Processor(s) Installed.

                               [01]: Intel64 Family 6 Model 44 Stepping 2 GenuineIntel ~2533 Mhz

                               [02]: Intel64 Family 6 Model 44 Stepping 2 GenuineIntel ~2533 Mhz

                               [03]: Intel64 Family 6 Model 44 Stepping 2 GenuineIntel ~2533 Mhz

                               [04]: Intel64 Family 6 Model 44 Stepping 2 GenuineIntel ~2533 Mhz

    BIOS Version:              Xen 4.1.2, 1/17/2012

    Windows Directory:         C:\Windows

    System Directory:          C:\Windows\system32

    Boot Device:               \Device\HarddiskVolume1

    System Locale:             en-us;English (United States)

    Input Locale:              en-us;English (United States)

    Time Zone:                 (UTC-05:00) Eastern Time (US & Canada)

    Total Physical Memory:     2,044 MB

    Available Physical Memory: 689 MB

    Virtual Memory: Max Size:  5,116 MB

    Virtual Memory: Available: 3,306 MB

    Virtual Memory: In Use:    1,810 MB

    Page File Location(s):     C:\pagefile.sys

    Domain:                    PRODUCTION

    Logon Server:              

    Hotfix(s):                 141 Hotfix(s) Installed.

                               [01]: KB981391

                               [02]: KB981392

                               [03]: KB977236

                               [04]: KB981111

                               [05]: KB977238

                               [06]: 982861

                               [07]: KB977239

                               [08]: KB2670838

                               [09]: KB2592687

                               [10]: KB981390

                               [11]: KB2305420

                               [12]: KB2386667

                               [13]: KB2393802

                               [14]: KB2425227

                               [15]: KB2484033

                               [16]: KB2488113

                               [17]: KB2492386

                               [18]: KB2505438

                               [19]: KB2506014

                               [20]: KB2506212

                               [21]: KB2506928

                               [22]: KB2507618

                               [23]: KB2509553

                               [24]: KB2510531

                               [25]: KB2511250

                               [26]: KB2511455

                               [27]: KB2515325

                               [28]: KB2522422

                               [29]: KB2529073

                               [30]: KB2530548

                               [31]: KB2533552

                               [32]: KB2536275

                               [33]: KB2536276

                               [34]: KB2541014

                               [35]: KB2544893

                               [36]: KB2545698

                               [37]: KB2547666

                               [38]: KB2552343

                               [39]: KB2560656

                               [40]: KB2563227

                               [41]: KB2564958

                               [42]: KB2567680

                               [43]: KB2570947

                               [44]: KB2574819

                               [45]: KB2584146

                               [46]: KB2585542

                               [47]: KB2603229

                               [48]: KB2604115

                               [49]: KB2607047

                               [50]: KB2608658

                               [51]: KB2618451

                               [52]: KB2620704

                               [53]: KB2620712

                               [54]: KB2621440

                               [55]: KB2631813

                               [56]: KB2633952

                               [57]: KB2636573

                               [58]: KB2640148

                               [59]: KB2643719

                               [60]: KB2644615

                               [61]: KB2645640

                               [62]: KB2647753

                               [63]: KB2653956

                               [64]: KB2654428

                               [65]: KB2655992

                               [66]: KB2656356

                               [67]: KB2656373

                               [68]: KB2656411

                               [69]: KB2658846

                               [70]: KB2659262

                               [71]: KB2660075

                               [72]: KB2667402

                               [73]: KB2676562

                               [74]: KB2677070

                               [75]: KB2679255

                               [76]: KB2685811

                               [77]: KB2685813

                               [78]: KB2685939

                               [79]: KB2686831

                               [80]: KB2688338

                               [81]: KB2690533

                               [82]: KB2691442

                               [83]: KB2695962

                               [84]: KB2698365

                               [85]: KB2699779

                               [86]: KB2699988

                               [87]: KB2705219

                               [88]: KB2709630

                               [89]: KB2709715

                               [90]: KB2709981

                               [91]: KB2712808

                               [92]: KB2718523

                               [93]: KB2718704

                               [94]: KB2719857

                               [95]: KB2719985

                               [96]: KB2726535

                               [97]: KB2729094

                               [98]: KB2729452

                               [99]: KB2732059

                               [100]: KB2736422

                               [101]: KB2742599

                               [102]: KB2743555

                               [103]: KB2749655

                               [104]: KB2750841

                               [105]: KB2753842

                               [106]: KB2756921

                               [107]: KB2757638

                               [108]: KB2758857

                               [109]: KB2761217

                               [110]: KB2763523

                               [111]: KB2765809

                               [112]: KB2770660

                               [113]: KB2779562

                               [114]: KB2785220

                               [115]: KB2786081

                               [116]: KB2786400

                               [117]: KB2789645

                               [118]: KB2790113

                               [119]: KB2791765

                               [120]: KB2798162

                               [121]: KB2804579

                               [122]: KB2807986

                               [123]: KB2808679

                               [124]: KB2813170

                               [125]: KB2813347

                               [126]: KB2813430

                               [127]: KB2820197

                               [128]: KB2820331

                               [129]: KB2829361

                               [130]: KB2830290

                               [131]: KB2834140

                               [132]: KB2836942

                               [133]: KB2836943

                               [134]: KB2838727

                               [135]: KB2839894

                               [136]: KB2840149

                               [137]: KB2845690

                               [138]: KB958488

                               [139]: KB976902

                               [140]: KB976932

                               [141]: KB982018

    Network Card(s):           1 NIC(s) Installed.

                               [01]: Citrix PV Ethernet Adapter

                                     Connection Name: Local Area Connection 2

                                     DHCP Enabled:    No

                                     IP address(es)

    Wednesday, August 7, 2013 2:23 PM
  • Maybe it is a bug of Xen? Do you agree with me? Did you  encounter this bug if you run you application on the hardware?

    I think that once a time,the Hypervisor of Xen write the current time to a  wrong momery address instead of the right momery segment in which Hypervisor store the time data that belongs to each DomU.

    When you eat all the momery of a Dom, the Hypervisor will rearrange the momery of each Dom,and maybe it will correct the mistake  above.

    This is only my guess, maybe it is wrong.

    • Edited by SDXIANCHAO Thursday, August 8, 2013 4:03 PM
    Thursday, August 8, 2013 3:51 PM
  • It is unlikely Xen issue. We did not have the problem when the project is compiled by VS2008 target .net3.5 framework. We rebuild the project in VS2010 and target .net framework 4 (some are .net framework 2), the problem happens.
    Tuesday, August 13, 2013 4:59 PM