AccessViolation error when use DsBrowseContainer in Vista (Active Directory Container)
-
Hi guys, I went through and played with the Example given in .net 2.0 It is working perfectly fine in 32 bit Os that is XP... and i am getting the error AccessViolation in Vista...Please help me how to solve it....My Vista is aslo 32 bit.. Unhandled Exception : System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at NetSDKSamples.LibWrap.DsBrowseForContainerW(DSBrowseInfo & info) at NetSDKSamples.App.Main() I have also tried running the exe as an Administrator..still the same result. I have also tried runnint it from CMD promprt where cmd is also run as administrator...still same result.. I am running out of ideas now... please help...me.. Path of Sample on My machine... C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\LateBreaking\PlatformInvoke\WinAPIs\ActiveDir Code: //----------------------------------------------------------------------- // This file is part of the Microsoft .NET Framework SDK Code Samples. // // Copyright (C) Microsoft Corporation. All rights reserved. // //This source code is intended only as a supplement to Microsoft //Development Tools and/or on-line documentation. See these other //materials for detailed information regarding Microsoft code samples. // //THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY //KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE //IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A //PARTICULAR PURPOSE. //----------------------------------------------------------------------- // ActiveDir.cs using System; using System.Text; using System.Runtime.InteropServices; using System.Threading; /* typedef struct { DWORD cbStruct; HWND hwndOwner; LPCWSTR pszCaption; LPCWSTR pszTitle; LPCWSTR pszRoot; LPWStr pszPath; ULONG cchPath; DWORD dwFlags; BFFCALLBACK pfnCallback; LPARAM lParam; DWORD dwReturnFormat; LPCWSTR pUserName; LPCWSTR pPassword; LPWStr pszObjectClass; ULONG cchObjectClass; } DSBROWSEINFOW, *PDSBROWSEINFOW; */ // all strings in structure will be marshaled as LPWStr [ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Unicode )] public struct DSBrowseInfo { public int structSize; private IntPtr dlgOwner; public string dlgCaption; public string treeViewTitle; public string rootPath; // in/out string must be declared as String in struct/class, // not as StringBuilder public string path; public int pathSize; public int flags; private Int