Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional Windows PowerShell Programming ISBN: 978-0-470-17393-0
This is the forum to discuss the Wrox book Professional Windows PowerShell Programming: Snapins, Cmdlets, Hosts and Providers by Arul Kumaravel, Jon White, Michael Naixin Li, Scott Happell, Guohui Xie, Krishna C. Vutukuri; ISBN: 9780470173930
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Windows PowerShell Programming ISBN: 978-0-470-17393-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 30th, 2008, 12:41 PM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default InitializeDefaultDrives error

I get the following error from asnp when I try to add drives in the InitializeDefaultDrives method.
"Object reference not set to an instance of an object."
Here is code that reproduces the problem.

    protected override Collection<PSDriveInfo> InitializeDefaultDrives()
    {
      Collection<PSDriveInfo> drives = new Collection<PSDriveInfo>();
// PSDriveInfo psDrive = new PSDriveInfo("myDrive", base.ProviderInfo, "myRoot", "Description", base.Credential);
      PSDriveInfo psDrive = new PSDriveInfo("myDrive", ProviderInfo, "myRoot", "Description", Credential);
      drives.Add(psDrive);
      return drives;
    }// InitializeDefaultDrives

I get the same error even if I use the base ProviderInfo and Credentials. I don't get the error if I remove the "drives.Add(psDrive);" line.

Any ideas?
Thanks,
Phil
 
Old May 1st, 2008, 10:20 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I figured out what I was doing wrong. My provider's NewDrive method gets called with the drive added in InitializeDefaultDrives. NewDrive was accessing the provider's DynamicParameters property which was not yet set through a call to my provider's NewDriveDynamicParameters method. I just needed to check whether DynamicParameters was null before attempting to access the expected items.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
[Resolved] Error calling a sp - parameter error snufse .NET Framework 2.0 2 February 12th, 2008 04:46 PM
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 02:51 AM
Phile Page error, visual studio error reps BOOK: ASP.NET Website Programming Problem-Design-Solution 0 September 27th, 2003 10:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.