Click here to Skip to main content
15,925,528 members
Home / Discussions / C#
   

C#

 
GeneralRe: textbox validation very urgent Pin
SandeepN10-Apr-07 11:22
SandeepN10-Apr-07 11:22 
GeneralRe: textbox validation very urgent Pin
SandeepN10-Apr-07 11:43
SandeepN10-Apr-07 11:43 
QuestionPass data between 2 Forms From datagridview Results Pin
tampasounds1-Mar-07 18:31
tampasounds1-Mar-07 18:31 
AnswerRe: Pass data between 2 Forms From datagridview Results Pin
Hayder Marzouk1-Mar-07 22:05
Hayder Marzouk1-Mar-07 22:05 
GeneralRe: Pass data between 2 Forms From datagridview Results Pin
tampasounds3-Mar-07 22:27
tampasounds3-Mar-07 22:27 
GeneralRe: Pass data between 2 Forms From datagridview Results Pin
Hayder Marzouk4-Mar-07 23:30
Hayder Marzouk4-Mar-07 23:30 
Questionshared addin Pin
kalyanit1-Mar-07 18:05
kalyanit1-Mar-07 18:05 
QuestionAccessViolation error when use DsBrowseContainer in Vista (Active Directory Container) Pin
Ronakkumar Patel1-Mar-07 17:03
Ronakkumar Patel1-Mar-07 17:03 
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 IntPtr callback;
private IntPtr lParam;
public int returnFormat;

public string userName;
public string password;

public string objectClass;
public int objectClassSize;
};

public class LibWrap
{
//int DsBrowseForContainer(PDSBROWSEINFO pInfo);

[ DllImport( "dsuiext.dll", CharSet=CharSet.Unicode )]
public static extern int DsBrowseForContainerW( ref DSBrowseInfo info );

public const int DSBI_ENTIREDIRECTORY = 0x00090000;
}

class App
{
public const int MAX_PATH = 256;

// Must be marked as STA since default is MTA. DsBrowseForContainerW calls
// CoInitialize, which initializes the COM library as STA.

[ STAThread ]
public static void Main()
{
// initialize all members
DSBrowseInfo dsbi = new DSBrowseInfo();

dsbi.structSize = Marshal.SizeOf( dsbi );
dsbi.dlgCaption = "The container picker";
dsbi.treeViewTitle = "Pick a container for this example.";

dsbi.path = new string( new char[ MAX_PATH ]);
dsbi.pathSize = dsbi.path.Length;

dsbi.flags = LibWrap.DSBI_ENTIREDIRECTORY;

dsbi.objectClass = new string( new char[ MAX_PATH ]);
dsbi.objectClassSize = dsbi.objectClass.Length;

Console.WriteLine( "Call DSBrowseForContainer..." );

int status = LibWrap.DsBrowseForContainerW( ref dsbi );

Console.WriteLine( "The status is " + status );
if( status == 1 )
{
Console.WriteLine( "The path is " + dsbi.path );
}
else
{
Console.WriteLine( "Call failed!" );
}
}
}
AnswerRe: AccessViolation error when use DsBrowseContainer in Vista (Active Directory Container) Pin
Ronakkumar Patel6-Mar-07 5:47
Ronakkumar Patel6-Mar-07 5:47 
Questionc# Pin
Ajeet mittal1-Mar-07 16:34
Ajeet mittal1-Mar-07 16:34 
AnswerRe: c# Pin
Stefan Troschuetz1-Mar-07 23:18
Stefan Troschuetz1-Mar-07 23:18 
GeneralRe: c# Pin
Ajeet mittal2-Mar-07 2:49
Ajeet mittal2-Mar-07 2:49 
GeneralRe: c# Pin
Stefan Troschuetz2-Mar-07 2:55
Stefan Troschuetz2-Mar-07 2:55 
GeneralRe: c# Pin
Luc Pattyn2-Mar-07 3:04
sitebuilderLuc Pattyn2-Mar-07 3:04 
QuestionCreating visitorID for Anonymous User Pin
SharonRao1-Mar-07 16:29
SharonRao1-Mar-07 16:29 
AnswerRe: Creating visitorID for Anonymous User Pin
Hayder Marzouk1-Mar-07 22:09
Hayder Marzouk1-Mar-07 22:09 
QuestionWhy Buttons look different and have different visual effect? [modified] Pin
Khoramdin1-Mar-07 15:50
Khoramdin1-Mar-07 15:50 
AnswerRe: Visual Differences in Buttons Created by Visual Studio 7 & 8? Pin
Luc Pattyn1-Mar-07 16:12
sitebuilderLuc Pattyn1-Mar-07 16:12 
Questionhow to import multiple dll files in c# Pin
prabir kishore1-Mar-07 13:01
prabir kishore1-Mar-07 13:01 
AnswerRe: how to import multiple dll files in c# Pin
Luc Pattyn1-Mar-07 13:32
sitebuilderLuc Pattyn1-Mar-07 13:32 
QuestionMCTS Self-Paced Training Kit (Exam 70-536) Pin
kaan06tr1-Mar-07 12:57
kaan06tr1-Mar-07 12:57 
AnswerRe: MCTS Self-Paced Training Kit (Exam 70-536) Pin
Christian Graus1-Mar-07 13:02
protectorChristian Graus1-Mar-07 13:02 
QuestionHow to draw a ontop of a background in C# Pin
laura13161-Mar-07 12:50
laura13161-Mar-07 12:50 
AnswerRe: How to draw a ontop of a background in C# Pin
Christian Graus1-Mar-07 12:52
protectorChristian Graus1-Mar-07 12:52 
QuestionDatabinding problem Pin
ejbing1-Mar-07 12:37
ejbing1-Mar-07 12:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.