none
clr20r3 error when connecting on some WindowsXP Systems

    Dotaz

  • Hello Everyone,

    I have developed a Windows Forms .net 4 application that uses SQL Server CE version 4.  I have two versions one for 32 bit and one for 64 bit systems.  Both work fine in Windows 7 and most Windows XP deployments.  However on some Windows XP machines I get the infamous cl20r3 Error.  I have one test machine which produces the error consistently which is XP service pack 3 and is up to date as far as I know.  Here is the full error from the event viewer:

    1st Event:

    EventType clr20r3, P1 myApplication.exe, P2 2.0.0.16, P3 4f2a8575, P4 mscorlib, P5 4.0.0.0, P6 4e181ae3, P7 3cb1, P8 4, P9 pszqoadhx1u5zahbhohghldgiy4qixhx, P10 NIL. 

    2nd Event:

    Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.Runtime.InteropServices.COMException
    Stack:
       at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32, IntPtr)
       at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32)
       at System.Data.SqlServerCe.UnmanagedLibraryHelper..ctor(System.String)
       at System.Data.SqlServerCe.NativeMethodsHelper..ctor(System.String)
       at System.Data.SqlServerCe.NativeMethods.LoadValidLibrary(System.String)
       at System.Data.SqlServerCe.NativeMethods.LoadNativeBinariesFromPrivateFolder(System.String)
       at System.Data.SqlServerCe.NativeMethods.LoadNativeBinaries()
       at System.Data.SqlServerCe.SqlCeConnection..ctor()

    I would be grateful for any help.

    Thanks

    Chris Tagg


    Chris Tagg

    2. dubna 2012 10:55

Odpovědi

  • Hi Everyone,

    The solution at last! :)  Thanks for Microsoft's Support especially Ryszard Gawron in Germany.

    Cause - This is because "VC++ 2008 SP1 MFC Security update" is not installed on the machine. This causes sqlceme40.dll  to fail.  Clearly there is some dependency that sqlceme40.dll needs.

    Resolution - Install "VC++ 2008 SP1 MFC Security update".  Here it is:

    http://www.microsoft.com/download/en/details.aspx?id=26368

    My thanks also to you Erik and to you Amber for your helpful posts.


    Chris Tagg

    • Označen jako odpověď Chris Tagg 20. dubna 2012 15:34
    20. dubna 2012 15:34

Všechny reakce

  • Hi Chris Tagg,

    >> EventType clr20r3, P1 myApplication.exe, P2 2.0.0.16, P3 4f2a8575, P4 mscorlib, P5 4.0.0.0, P6 4e181ae3, P7 3cb1, P8 4, P9 pszqoadhx1u5zahbhohghldgiy4qixhx, P10 NIL.

    Regarding to the EventType clr20r3 is just a common error message showing there's an unhandled exception in your application.
    According to the error message "EventType clr20r3 ..." is to catch the mistake in your application. To deal with this issue, you have to check your source code and handle the exception.

    To make the error information more sense, we can handle the AppDomain.UnhandledException event to log the error in a more meaningful way, for more information about the AppDomain.UnhandledException event, you can check this document.

    Based on my research, there are many threads with this error message please refer to the replies as below:
    1. http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/199be638-a921-4b55-81a6-cabada8c27f0/
    2. http://social.msdn.microsoft.com/Forums/en/clr/thread/92590c67-8da3-4093-9cd4-27ea638bf432/

    Meanwhile this issue might be related to .NET development, please link to  .NET Development Forums 


    Regards,
    Amber zhang
    TechNet Subscriber Support
    If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.

    3. dubna 2012 6:01
  • Thank you Amber,

    Using the document you suggested as a guide I added an AppDomain.UnhandledException handler to the method where the error occurs and got this result:

     This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)

    The line of code is failing on 

    conn = new SqlCeConnection();

    So I guess the error is happening in the connection class constructor.  As far as I can see the configuration is correct.  We did have another xp test machine but that is presently being repaired.  If my memory serves me correctly it worked well on that machine and on other 32 bit Windows 7 machines.  

    Best regards,

    Chris Tagg


    3. dubna 2012 13:40
  • Why not a single app that includes all the required files? See http://erikej.blogspot.com/2011/02/using-sql-server-compact-40-with.html

    Please mark as answer, if this was it. Visit my SQL Server Compact blog

    3. dubna 2012 15:49
  • Hello Erik

    I read carefully your blog and tried to modify the application in the way you stated.  Your example is a wpf project whereas mine is a windows forms project but I don't see that that should make a difference.

    I included all the files in the application and marked them as 'content' and 'copy always'.  The folders themselves did not have these properties.

    When it came to modifying the app.config file, as there is already some content in there referring to a web service.  Perhaps it would be best if I included here the entire contents of the file with some irrelevant stuff removed.

    <?xml version="1.0"?>
    <configuration>
        <configSections>
            <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                <section name="Treadmark.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
            </sectionGroup>
        </configSections>
        <userSettings>
            <Treadmark.Properties.Settings>
                <setting name="MainFormState" serializeAs="String">
                    <value>Normal</value>
                </setting>
                <setting name="MainFormWidth" serializeAs="String">
                    <value>908</value>
                </setting>
                <setting name="MainFormHeight" serializeAs="String">
                    <value>696</value>
                </setting>
                <setting name="MainFormLeft" serializeAs="String">
                    <value>20</value>
                </setting>
                <setting name="MainFormTop" serializeAs="String">
                    <value>20</value>
                </setting>
                <setting name="imgxCtrlSetting" serializeAs="String">
                    <value>None</value>
                </setting>
            </Treadmark.Properties.Settings>
        </userSettings>
    <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><system.serviceModel>
            <bindings>
                <basicHttpBinding>
                </basicHttpBinding>
            </bindings>
            <client>
            </client>
        </system.serviceModel>
      <system.data>
        <DbProviderFactories>
          <remove invariant="System.Data.SqlServerCe.4.0"/>
          <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
        </DbProviderFactories>
      </system.data>
    </configuration>

    However the application still stalls when creating the SqlServerCe connection object.

    Thanks

    Chris


    Chris Tagg

    9. dubna 2012 9:48
  • Stall ? Same error message or long time to open database? Long time is caused by creating a database on Windows 7 and opening on XP. What is your connection string, and what size is your db?

    Please mark as answer, if this was it. Visit my SQL Server Compact blog

    9. dubna 2012 11:41
  • Hi Erik

    Sorry, 'Stall' is the wrong word.  It doesn't get as far as setting the connection string and attempting to open the database.  The line it fails on is

    SqlCeConnection conn = new SqlCeConnection();

    Please see my previous post of April 3rd for the error message.  It does work on some XP systems, but fails on others.

    Thanks,

    Chris


    Chris Tagg

    9. dubna 2012 17:03
  • OK. What happens if you start the application without an app.config file?

    And my previous questions:

    Long time is caused by creating a database on Windows 7 and opening on XP. Is that waht you do?

    What is your connection string, and what size is your db?


    Please mark as answer, if this was it. Visit my SQL Server Compact blog

    9. dubna 2012 17:23
  • Hi Eric

    If I install the app without app.config (renames itself TreadmarkExpress.exe.config) then the same error happens in the same place.

    The database is not created by the application.  The install process (standard msi file) copies the database file to the main application folder.  On first start-up, before attempting to make any connection, the application copies the database file to a newly created folder in the 'My Documents' folder.  Only then does it attempt to create the connection object which causes the error.  In Windows 7, Vista, and most XP both 32 and 64 bit this process works fine.  It only fails on some XP installations.  Fortunately I am able to reproduce the error on my test XP machine.

    The size of the database file is just over 21 mb.  The connection string is "Data Source=" + path + ";Password=<password removed>"  The path is the path of the database which was copied to the 'My Documents' folder.

    Thanks


    Chris Tagg

    10. dubna 2012 10:02
  • Sorry Erik, Reading over the first sentence in my last reply may not be clear.  Removing app.config makes no difference to the behavior.

    Chris Tagg

    10. dubna 2012 10:04
  • Test without a password on the database.

    Please mark as answer, if this was it. Visit my SQL Server Compact blog

    10. dubna 2012 10:27
  • Hi Erik

    It took a while to create an exe version and database without password.  Tested it with the same result.

    Chris


    Chris Tagg

    11. dubna 2012 14:47
  • Dear Erik

    This thread seems to have fallen silent since your last post.  I really would appreciate your help as our customer is waiting for a fix for the software we have delivered.

    Some of your replies including the last one have focused on connecting to the database.  Connecting does not appear to be the problem.  The application does not get as far as setting the connection string and opening the database.  The error occurs here:

    SqlCeConnection conn = new SqlCeConnection();

    It is the following line that sets the connection string.  The next lines are the conn.Open() and conn.Close() which are inside are inside a try... catch...

    I tried to make this clear in my previous posts.  So perhaps I can ask some specific questions to see if they help to solve the problem.

    1. Is the problem likely to be that there is incompatibility with a previous version in the GAC?
    2. If the answer to question 1 is ‘yes’ then is there a way of interrogating the GAC to see if this actually the case?
    3. Earlier you suggested:  "Why not a single app that includes all the required files? See http://erikej.blogspot.com/2011/02/using-sql-server-compact-40-with.html"  As I replied I did my best to implement this, posted the app.config contents.  Please would you look at the contents of this file and confirm that this file is correct, according to your blogspot article.
    4. Is this a known issue?  Are there others who find that Sql Server Compact Edition version 4 is incompatible with some instances of Windows XP?

    Kind regards,


    Chris Tagg

    16. dubna 2012 10:36
  • Hi Chris

    Understand that I do not work for Microsoft support, I am only here to do my best to help out. I have heard of others having issues with non-admin users and encryption, but otherwise I have not come across any issues with Windows XP SP3 (SP3 is required).

    You need to find out how the various XP machines differ!

    Re your questions:

    1: No. In that case you would get another error message.

    3: Your app.config file looks fine

    4: See above


    Please mark as answer, if this was it. Visit my SQL Server Compact blog


    16. dubna 2012 11:15
  • Hi Erik

    Sorry for my misunderstanding.  Thank you very much for all your help. It is service pack 3 so I had better see if I can get some support from Microsoft on this one.

    Best regards,


    Chris Tagg

    16. dubna 2012 11:24
  • Do that, and update this thread if you find a solution - I am keen to know of it.


    Please mark as answer, if this was it. Visit my SQL Server Compact blog

    16. dubna 2012 11:46
  • Hi Everyone,

    The solution at last! :)  Thanks for Microsoft's Support especially Ryszard Gawron in Germany.

    Cause - This is because "VC++ 2008 SP1 MFC Security update" is not installed on the machine. This causes sqlceme40.dll  to fail.  Clearly there is some dependency that sqlceme40.dll needs.

    Resolution - Install "VC++ 2008 SP1 MFC Security update".  Here it is:

    http://www.microsoft.com/download/en/details.aspx?id=26368

    My thanks also to you Erik and to you Amber for your helpful posts.


    Chris Tagg

    • Označen jako odpověď Chris Tagg 20. dubna 2012 15:34
    20. dubna 2012 15:34