Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 03:46 PM
Parse error: syntax error, unexpected T_STRING ginost7 Beginning PHP 1 November 9th, 2007 01:51 AM
Phile Page error, visual studio error reps BOOK: ASP.NET Website Programming Problem-Design-Solution 0 September 27th, 2003 10:11 AM



All times are GMT -4. The time now is 10:50 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.