Ganesan

Classs

public class XspPodcastWebsiteInfo

{

public int KeyWebsite;

public int KeyProject;

public string Name;

public string XmlFileStoragePath; // this is the xml file where you store all info for podcasts archived at this site

public string BaseFolder; // this is the root storage for this site.

public string DataFolder; // this is where the audio files for podcasts must be placed

public string ImagesFolder; // any images needed for the podcast links go here

public string DomainName; // this is the published version of BaseFolder

// e.g. BaseFolder could be c:\xrrrr\website1

// datafolder = data

// imagesfolder = img

// domainname = www.rrrr.com

// so you need to put images in c:\xspdata\website1\img and audio files in c:\xrrrr\website1\data

// when you are creating links to the images, you need to join the domain and the image folder together

// to make www.rrrrr.com/img

}

interface IXSiteProPodCastPlugin

{

/**

* Before calling anything in the plugin, the globals vars are set.

* projects: An array of projects in XSP which can be used as the parents of the websites.

* websites: An array of websites in XSP

* publishingMethod: call this method to publish the archive page for the required website

**/

void SetGlobals(XspPodcastProject[] projects);/**

}

XspPodcastWebsiteInfo [] aaaa=new XspPodcastWebsiteInfo [1] ;

aaaa[0].KeyWebsite=1;

aaaa[0].KeyProject=10;

aaaa[0].Name="Test";

aaaa[0].BaseFolder="Data";

Heare i got Obeject as null referance.

How to solve it



Re: Visual C# General how to solve Object as Null Referance?

Tom1984


aaaa[1].KeyProject=10; // shouldnt it be aaaa[0] aaaa[1] wont exist in your array.


so you would get a null object reference






Re: Visual C# General how to solve Object as Null Referance?

sirjis

Your array code is incorrect. The reason why it is failing is because array elements are initialized to null, even after the array itself is no longer null. So before accessing aaaaIdea, make sure you do aaaaIdea = new XspPodcastWebsiteInfo();. You can do this in a for loop after creating the array or just before whenever you need to access the element.

Also, the number that you give when initializing is the length of the array, not the upper bound, so either make it an array of length 2 or change aaaa[1] to aaaa[0].