Im Building a wraper in C# for the C++ API, im able to connecto to the server and get the ProjectList, even open a project, the problem is when a try to get the jobs of the Project, if i try to get the info of a Project with no jobs the return value is -1007 wich is ok, but if i try to get the info of a project with jobs I get a System.NullReferenceException, here is my code, thanks and sorry for the bad english.
[DllImport("vmdsapi.dll")] internal static extern int DSGetProjectInfo(IntPtr Project, int InfoType,[InAttribute(),Out()] IntPtr ProjectInfo);
public int GetProjectInfoDS(DSPROJECTINFO_VALUES Info)
{
int Resultado;
IntPtr Jobs;
try
{
Resultado=0;
Jobs=new IntPtr();
//DSDatos.PuntProy is apointer to the structure DSPROJECT
switch(Info)
{
case DSPROJECTINFO_VALUES.DSJ_JOBLIST:
Resultado=DSGetProjectInfo(DSDatos.PuntProy,DSJ_JOBLIST,Jobs);
break;
case DSPROJECTINFO_VALUES.DSJ_PROJECTNAME:
Resultado=DSGetProjectInfo(DSDatos.PuntProy,DSJ_PROJECTNAME,Jobs);
break;
case DSPROJECTINFO_VALUES.DSJ_HOSTNAME:
//Resultado=DSGetProjectInfo(DSDatos.PuntProy,DSJ_HOSTNAME,Jobs);
break;
};
return(Resultado);
}
catch(System.NullReferenceException Ex)
{
throw(Ex);
}
catch(Exception Ex)
{
throw(Ex);
}
}
Development Kit API problems with DSGetProjectInfo
Moderators: chulett, rschirm, roy
Re: Development Kit API problems with DSGetProjectInfo
Ok, i no longer get the system.NullReferenceException, i changed the DSGetProjectInfo declaration to
[DllImport("vmdsapi.dll")] internal static extern int DSGetProjectInfo(IntPtr Project, int InfoType,[InAttribute(),OutAttribute()]ref IntPtr ProjectInfo);
Check the ref keyword, now the problem is that the pointer has a value of 2 from the function, and when i tried to use Marshal.PtrToStructure i get another exception, thanks.
[DllImport("vmdsapi.dll")] internal static extern int DSGetProjectInfo(IntPtr Project, int InfoType,[InAttribute(),OutAttribute()]ref IntPtr ProjectInfo);
Check the ref keyword, now the problem is that the pointer has a value of 2 from the function, and when i tried to use Marshal.PtrToStructure i get another exception, thanks.
Re: Development Kit API problems with DSGetProjectInfo
Problem Solved, thanks for your help.