Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2004

Tip: Looking for answers? Try searching our database.

iadstools ctor access violation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
frank brown - 14 Sep 2004 23:46 GMT
The following line of c# code:

IADsTools.DCFunctionsClass oIADsTools = new IADsTools.DCFunctionsClass();

causes a memory access violation (but the rest of the program runs,
including calls to oIADsTools member functions).

Can anyone provide a clue what I'm doing wrong?  I created IADsTools.dll via
the tlbimp.exe utility.

-Frank Brown
http://www.inwa.net/~frog/
Joe Richards [MVP] - 16 Sep 2004 13:27 GMT
I am not sure why you would see that, do you get the same when using it from VB
or perl?

Note that iadstools has some serious issues in its functions that return times,
specifically last replication and last attempted replication. It will usually be
off by at least 2*TZ Bias in hours. So if you are in GMT-5 it will be off by at
least 10 hours. If you are in GMT+1 it will be off by at least +2 hours.

--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net

> The following line of c# code:
>
[quoted text clipped - 8 lines]
> -Frank Brown
> http://www.inwa.net/~frog/
frank - 17 Sep 2004 00:16 GMT
VB is not installed on my machine so I can't test that...however I do have
perl; how would I call it from perl?  The following gives me an 'invalid
class string' error:

$oIADsTools = Win32::OLE->CreateObject("IADsTools.dll");

FYI the c# app evokes the same memory error when run from Win2000/SP4 and
XP/SP2.  I don't care about timestamps; I'm just using it to resolve GPO
names from their GUIDs.

-Frank

>I am not sure why you would see that, do you get the same when using it
>from VB or perl?
[quoted text clipped - 22 lines]
>> -Frank Brown
>> http://www.inwa.net/~frog/
Joe Richards [MVP] - 17 Sep 2004 00:28 GMT
Here is an example perl script of using iadstools (watch line wrap)

use OLE;

print "\niadstools-test V01.00.00pl  Joe Richards (joe\@joeware.net) September
2004\n\n";

$IADSTool=CreateObject OLE ("IADsTools.DCFunctions");

$fqdn=shift;
$nc=shift;

$directpartnercount=$IADSTool->GetDirectPartners($fqdn,$nc);
if ($directpartnercount == -1)
 {
  print "         ERROR - Couln't retrieve partners:
".$IADSTool->LastErrorText."\n";
  exit;
 }

for $k(1..$directpartnercount)
 {
  print "--\n";
  print "Partner Name: ".$IADSTool->DirectPartnerName($k)."\n";
  print "Last Success: ".$IADSTool->DirectPartnerLastSuccessTime($k)."\n";
  print "Last Attempt: ".$IADSTool->DirectPartnerLastAttemptTime($k)."\n";
  print "Failure Count: ".$IADSTool->DirectPartnerNumberFailures($k)."\n";
  print "--\n";
 }

You should also be able to call it from vbscript

wscript.echo
wscript.echo "iadstools-test2 V01.00.00vbs  Joe Richards (joe\@joeware.net)
September 2004"
wscript.echo
wscript.echo

set IADSTool=CreateObject("IADsTools.DCFunctions")

fqdn=wscript.arguments.item(0)
nc=wscript.arguments.item(1)

directpartnercount=IADSTool.GetDirectPartners(cstr(fqdn),cstr(nc))
if (directpartnercount = -1) then
  wscript.echo "         ERROR - Couldn't retrieve partners: " &
IADSTool.LastErrorText() & "."
  wscript.quit()
end if

for k=1 to directpartnercount
  wscript.echo "--"
  wscript.echo "Partner Name: " & IADSTool.DirectPartnerName(k)
  wscript.echo "Last Success: " & IADSTool.DirectPartnerLastSuccessTime(k)
  wscript.echo "Last Attempt: " & IADSTool.DirectPartnerLastAttemptTime(k)
  wscript.echo "Failure Count: " & IADSTool.DirectPartnerNumberFailures(k)
  wscript.echo "--"
next

--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net

> VB is not installed on my machine so I can't test that...however I do have
> perl; how would I call it from perl?  The following gives me an 'invalid
[quoted text clipped - 35 lines]
>>>-Frank Brown
>>>http://www.inwa.net/~frog/
frank brown - 21 Sep 2004 19:19 GMT
OK it works from perl.  Not sure why it generates access violation in c#.  I
can recode my app from c# to perl as a workaround.

-Frank

> Here is an example perl script of using iadstools (watch line wrap)
>
[quoted text clipped - 98 lines]
> >>>-Frank Brown
> >>>http://www.inwa.net/~frog/
Joe Richards [MVP] - 22 Sep 2004 19:40 GMT
Cool

--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net

> OK it works from perl.  Not sure why it generates access violation in c#.  I
> can recode my app from c# to perl as a workaround.
[quoted text clipped - 144 lines]
>>>>>-Frank Brown
>>>>>http://www.inwa.net/~frog/

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.