AccessViolationException when choosing Microsoft Ole Db Provider for Visual FoxPro in MSDASC DataLinks RRS feed

  • Question

  • Hi all!

    I'm having a (in my opinion) strange problem.

    First my system.

    Vista Business SP1 (UAC turned off)
    .NET Framework 1.1, 2.0 sp2, 3.0 and 3.5
    Visual Studio 2005 Professional SP1 with Vista Update
    Visual Studio 2008 Professional Edition
    Microsoft Ole Db Provider for Visual FoxPro 9.0
    MDAC 2.8

    Here is my story.

    I have developed an application (C# and .NET 2.0) where one part of the application uses the MSDASC DataLinks class to build a connection string.
    The application was first developed on Windows XP and later I switched to Vista and it all worked as it should.
    Now I have a new development computer where it does not work as expected.
    I do not remember wich version of the Microsoft Ole Db Provider for Visual FoxPro i used before.

    When I run the application from the development environment in debug mode it all works fine. When I run the exe I get an exception
    when I choose Microsoft Ole Db Provider for Visual FoxPro and press next in the datalinks dialog.

    I use this code to open the dialog:

    MSDASC.DataLinksClass dlc = new MSDASC.DataLinksClass();  
    ADODB.Connection adoCon = (ADODB.Connection)dlc.PromptNew();  
    textBox1.Text = adoCon.ConnectionString;  

    I developed a small testapplication using mfc and c++ wich opens the datalinks dialog and from that application it all works fine
    (exe or developement environment).


    When opening the MSDASC datalinks dialog and chooses Microsoft Ole Db Provider for Visual FoxPro  from an application built with C# and .NET 2.0 I get an System.AccessViolationException.

    From Visual Studio 2008 when I try to add a connection from server explorer using the Microsoft Ole Db Provider for Visual FoxPro and the datalinks dialog
    Visual Studio stops responding.

    Here is the exceptioninfo:

    System.AccessViolationException: Attempted to read or write protected memory.  This is often an indication that other memory is corrupt.
       at System.Windows.Forms.UnsafeNativeMethods.IntDestroyWindow(HandleRef hWnd)
       at System.Windows.Forms.UnsafeNativeMethods.DestroyWindow(HandleRef hWnd)
       at System.Windows.Forms.NativeWindow.DestroyHandle()
       at System.Windows.Forms.Control.DestroyHandle()
       at System.Windows.Forms.Control.Dispose(Boolean disposing)
       at System.Windows.Forms.ContainerControl.Dispose(Boolean disposing)
       at System.Windows.Forms.Form.Dispose(Boolean disposing)
       at System.ComponentModel.Component.Dispose()
       at System.Windows.Forms.Application.ThreadContext.OnThreadException(Exception t)
       at System.Windows.Forms.Control.WndProcException(Exception e)
       at System.Windows.Forms.Control.ControlNativeWindow.OnThreadException(Exception e)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.RunDialog(Form form)
       at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
       at System.Windows.Forms.Form.ShowDialog()

    Hopefully someone can help me on this.

    Kind regards Patrik
    Friday, September 26, 2008 1:32 PM

All replies

  • Looks like one of the components you put on the dialog is crashing.  Which is it?  Find out by putting a breakpoint on the Dispose() method in the form's Designer.cs file.
    Hans Passant.
    Friday, September 26, 2008 9:07 PM
  • Hi

    Thanks for responding.

    I do not think I can put a breakpoint on the dispose method.
    The dialog is a Microsoft ActiveX component. But I do not think it is the MSDASC Datalinks component that is the problem
    since it only crash when I choose Microsoft OLE DB Provider for FoxPro. All the other OLE DB Providers I have tried works.

    Saturday, September 27, 2008 4:45 PM
  • Sure you can set a breakpoint on the form's Dispose method.  You'll have to do the legwork to get this resolved, it is impossible to help you diagnose this problem through an Intertube.
    Hans Passant.
    Saturday, September 27, 2008 6:46 PM
  • Hi,

    I'm sorry but I do not understand what you mean.

    Tried. The breakpoint in the dispose method was not hit.

    The exception is thrown from a component (ActiveX) wich I have not created myself, it is Microsoft stuff. And it is only thrown when I choose Microsoft Ole Db Provider for Visual FoxPro, this is when I run the exe and not from the development environment. And since it is working in the development environment, no exception thrown it is hard to debug.

    For a better understanding of the problem try this.

    1. In Visual Studio 2005 create a windows forms project.
    2. Add a reference to Microsoft ActiveX Data Objects 2.8 Library and Microsoft OLE DB Service Component 1.0 Type Library
    3. Add a button to the form and create an click event handler.
    4. In the click event handler method copy and paste the code below

    MSDASC.DataLinksClass dlc = new MSDASC.DataLinksClass();     
    ADODB.Connection adoCon = (ADODB.Connection)dlc.PromptNew();     

    Thanks again.

    Monday, September 29, 2008 6:20 AM
  • Anyone have information on this subject?

    Kind regards Patrik
    Friday, October 10, 2008 11:57 AM