Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8271361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:49:13+00:00 2026-06-08T06:49:13+00:00

I have an application that uses a third party native C dll. Everything works

  • 0

I have an application that uses a third party native C dll. Everything works well on a Windows 7 machine with .Net 4 but fails on Windows XP (SP3) with .Net 4.

I get the following exception on Windows XP machine.

Unhandled Exception: System.AccessViolationException: Attempted to read or write
protected memory. This is often an indication that other memory is corrupt.

When I debug,

First-chance exception at 0x10069e1d in CacheInteropTest.exe: 0xC0000005: Access violation reading location 0x00000000.

this is my simplified test application code:

public unsafe class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        var status = CacheEnd();
        Console.ReadKey(true);
    }

    [SuppressUnmanagedCodeSecurity]
    [DllImport("cachet.dll", EntryPoint = "#24", CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
    internal extern static int CacheEnd();
}

I compiled the above program on Windows XP (SP3) 32 bit and copied to a Windows 7 machine and ran, it did not give any exception. The third party dll is available in the same folder as the executable.

I found many replies for issues related to AccessViolationException, particularly this
AccessViolationException in P/Invoke call is a close match.
Another site has kind of an overview about PInvoke and memory related issues here
http://dotnetdebug.net/2006/04/17/pinvoke-and-memory-related-issues/ but does not help me in this case.

The third party dll is a database kernel and provides multi-threaded database access (maintains one connection per thread). In the documentation of the API it was mentioned that the dll must be statically linked and C++ application that consumes this dll on Windows XP works well too.

I think the problem is in the implementation of the native dll, but why it works well on Windows 7?

Any one has any idea what could be going wrong on Windows XP?

The native function proto type provided by the vendor is

extern  int  CFPROTOD(CacheEnd,(void));

So I guess the issue is not related to calling conventions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:49:15+00:00Added an answer on June 8, 2026 at 6:49 am

    The issue is because of a limitation in Windows. The static linking requirement for the API came from this limitation that was already known to the vendor.
    http://support.microsoft.com/kb/118816 explains the issue in Windows. Looks like this has been fixed in Win 7

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a Windows Forms application that uses a (third party) ActiveX control, and
I am building an android application that uses several third party libraries. I have
I have an ASP.NET 4.0 web application which uses a third-party API for external
I have a winform application that works with/for third party exes. These third party
I have a java application that uses some third party API. The third party
I have a Visual C++ 9 Win32 application that uses a third-party library. When
I have an MFC application that uses an ancient (circa 1999) third-party ActiveX control.
I have an application I'm working on that uses two third party libraries, each
Background I have a Windows service that uses various third-party DLLs to perform work
I have a WPF application that uses a third-party library to perform a specific

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.