Link to home
Start Free TrialLog in
Avatar of narmi2
narmi2

asked on

How to use this class - Error 1

Dear Experts,

Continuing from here:
https://www.experts-exchange.com/questions/24795491/How-to-use-this-class-Part-7.html

I have tried to compile the current code, and have received the following error:

NullReferenceException was unhandled by user code

The error happened on here on the second line

        Dim PSP(0) As ProfileSearchParameter
        PSP(0).AttributeID = imProfileAttributeID.imProfileAccessTime
        PSP(0).SearchValue = "test"

Just as a reminder, I am trying to implement this class:

public class SearchDocumentsInput
{
public string[] Databases;
public imProfileAttributeID[] OutputProfile;
public ProfileSearchParameter[] ProfileSearchParameters;
public imSearchEmail SearchEmail;
public FullTextSearch FullTextSearch;
public OutputMask OutputMask;
}

The the part I am having the error with is

public ProfileSearchParameter[] ProfileSearchParameters;

Which is the following class

public class ProfileSearchParameter
{
public imProfileAttributeID AttributeID;
public string SearchValue;
}

and imProfileAttributeID is an enum.

Can anyone please help?
Avatar of Omego2K
Omego2K
Flag of United States of America image

From a glance you are not declaring an instance of ProfileSearchParameter
change your code to this:
Dim PSP(0) As ProfileSearchParameter = {New ProfileSearchParameter()}
PSP(0).AttributeID = imProfileAttributeID.imProfileAccessTime
PSP(0).SearchValue = "test"
Avatar of narmi2
narmi2

ASKER

With that, I get the following error

Error      1      Explicit initialization is not permitted for arrays declared with explicit bounds.      C:\iConnection\Default.aspx.vb      110      13      iConnection
oh sorry yeah, change it to this:
Dim PSP As ProfileSearchParameter = {New ProfileSearchParameter()}
PSP(0).AttributeID = imProfileAttributeID.imProfileAccessTime
PSP(0).SearchValue = "test"
Avatar of narmi2

ASKER

I now get the error:

Error      1      Array initializers are valid only for arrays, but the type of 'PSP' is 'ProfileSearchParameter'.      C:\iConnection\iConnection\Default.aspx.vb      114      13      iConnection
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial