C# Registry edit problem RRS feed

  • Question

  • Hello all,

    I have problem with my C# appi for windows mobile. If I start this appi in windows mobile 6.5 I have this error - 

    {"An error occured creating the registry key."}

    ErrorCode -2147467259


    I have no idea where can be the problem. I think that problem is in permissions but i'm not sure.


    Here is my code:


    private void ResetCERegistryKeys()


                CERegistryKey ceRegKey = CERegistry.CurrentUser.CreateSubKey("Software\\_Poruchy");

                ceRegKey.SetValue("TransferRunning", 0);

                ceRegKey.SetValue("Transfer_AppPoruchyRunning", 0);

                ceRegKey.SetValue("Transfer_PDA_2_PC", 0);

                ceRegKey.SetValue("Transfer_PC_2_PDA", 0);

                string name = ceRegKey.GetValue("TransferRunning").ToString();


            private int TransferPC2PDARunning()


                CERegistryKey ceRegKey = CERegistry.CurrentUser.CreateSubKey("Software\\_Poruchy"); // here is the problem on this line 

                return (Convert.ToInt16(ceRegKey.GetValue("Transfer_PC_2_PDA", 0).ToString()));           


            private int TransferPDA2PCRunning()


                CERegistryKey ceRegKey = CERegistry.CurrentUser.CreateSubKey("Software\\_Poruchy");

                return (Convert.ToInt16(ceRegKey.GetValue("Transfer_PDA_2_PC", 0).ToString()));





    Friday, January 21, 2011 2:17 PM


  • I don't have OpenNetCF to try your exact code, but this works fine for me. Can you try switching to the Microsoft.Win32 version instead to see if that makes a difference?

    RegistryKey ceRegKey = Registry.CurrentUser.CreateSubKey("Software\\_Poruchy"); 

    Also, if the OpenNetCF version is anything like the Microsoft.Win32 version you should be sure to Close or Dispose of the key when you're finished. I use a using() declaration, typically.


    • Marked as answer by Bin-ze Zhao Monday, January 24, 2011 8:57 AM
    Friday, January 21, 2011 8:10 PM