12-04-2009 11:52 AM
Hello,
I try to use the function TS_DotNetModuleGetParameters to get paramaters of a function include in a .dll.
No error is detected but it seems that the parameters is empty. Because when I count items with TS_DotNetParametersGetCount, the method return 0.
The paramaters of TS_DotNetModuleGetParameters look correct.
Someone have any ideas of the problem?
Thanks a lot,
Anthony
12-08-2009 10:35 AM - edited 12-08-2009 10:36 AM
Anthony -
Calling the TS_DotNetModuleGetParameters function in CVI corresponds to getting the DotNetModule.Parameters property. The TestStand Help for DotNetModule.Parameters states that before calling this method, you must call DotNetModule.LoadPrototypeFromMetadataToken() befor calling DotNetModule.Parameters.
Are you calling TS_DotNetModuleLoadPrototypeFromMetadataToken before calling TS_DotNetModuleGetParameters?
Hope this helps.
12-08-2009 10:50 AM
Hello Manooch H,
Yes, I'm calling TS_DotNetModuleLoadPrototypeFromMetadataToken before calling TS_DotNetModuleGetParameters.
I tried before with an obsolete method TS_DotNetModuleLoadMemberInfo but it doesn't work too. May be I forget something?
Have you got an example for me?
I show a part of my code :
if (sModulePath != NULL && strcmp(sModulePath, "") != 0) { tsApiErrChk(TS_DotNetModuleSetAssembly(hTSStepModule, &errorInfo, TSConst_DotNetModule_AssemblyLocation_File, sModulePath), TS_ERROR); } else if ( iStepType != TS_StepType_CustomValue ) { tsErrThrow(TS_ERROR_NOMODULEPATH, TS_ERRMSG_DOT_NOMODULEPATH, TS_ERROR); } if (sClassName != NULL && strcmp(sClassName, "") != 0) { tsApiErrChk(TS_DotNetModuleSetClassName(hTSStepModule, &errorInfo, sClassName), TS_ERROR); } else if ( iStepType != TS_StepType_CustomValue ) { tsErrThrow(TS_ERROR_NOCLASSNAME, TS_ERRMSG_DOT_NOCLASSNAME, TS_ERROR); } generateObjectReferenceName(sModulePath, szObjectReferenceName); tsApiErrChk(TS_DotNetModuleSetClassReference (hTSStepModule, &errorInfo, szObjectReferenceName), TS_WARNING); tsApiErrChk(TS_PropertyExists (hTSMainSequence, &errorInfo, szObjectReferenceName, TS_PropOption_NoOptions, &bExists), TS_WARNING); if (!bExists) { tsApiErrChk(TS_PropertyNewSubProperty (hTSMainSequence, &errorInfo, szObjectReferenceName, TS_PropValType_Reference, VFALSE, "", TS_PropOption_NoOptions), TS_WARNING); tsApiErrChk(TS_DotNetModuleSetCreateObject (hTSStepModule, &errorInfo, VFALSE), TS_WARNING); } if (sFunctionName != NULL && strcmp(sFunctionName, "") != 0) { tsApiErrChk(TS_DotNetModuleSetMemberType(hTSStepModule, &errorInfo, TSConst_DotNetMember_CallMethod), TS_WARNING); tsApiErrChk(TS_DotNetModuleSetMemberName(hTSStepModule, &errorInfo, sFunctionName), TS_ERROR); } else if ( iStepType != TS_StepType_CustomValue ) { tsErrThrow(TS_ERROR_NOFUNCTION, TS_ERRMSG_DOT_NOFUNCTION, TS_ERROR); } //tsApiErrChk(TS_DotNetModuleLoadMemberInfo (hTSStepModule, &errorInfo, VFALSE, &bHasMemberInfo), TS_ERROR); tsApiErrChk(TS_DotNetModuleGetMetadataToken (hTSStepModule, &errorInfo, &metadata), TS_ERROR); tsApiErrChk(TS_DotNetModuleLoadPrototypeFromMetadataToken (hTSStepModule, &errorInfo, metadata, 0, &bHasMemberInfo), TS_ERROR);
and after, I do :
// iModuleAdapter = [rechercher le module adapter spécifié dans le step] iModuleAdapter = getModuleAdapter(); if (iModuleAdapter == TS_ModuleAdapter_None) { tsErrThrow (TS_ERROR_UNKNOWNMODULEADAPTER, TS_ERRMSG_UNKNOWNMODULEADAPTER, TS_ERROR); } // hTSStepModule := [obtenir le module du step créé] tsApiErrChk(TS_StepGetModule (hTSNewStep, &errorInfo, &hTSStepModule), TS_ERROR); if ( iModuleAdapter != TS_ModuleAdapter_SequenceCall ) { // hParametersList := [rechercher la liste des paramètres] tsApiErrChk(getParametersList(iModuleAdapter, hTSStepModule, &errorInfo, &hTSParametersList), TS_ERROR); // lNbParam := [rechercher le nombre de paramètres] tsApiErrChk(getParametersCount (iModuleAdapter, hTSParametersList, &errorInfo, &lNumberOfParameters), TS_ERROR); // WHILE (index < lNbParam AND NOT bParamFound) // DO // hLbvParameter := [rechercher le paramètre à l'index courant] // sCurParamName := [rechercher le nom du paramètre courant] // IF (sCurParamName == sParamName) THEN // [mettre la valeur du paramètre à sValueExpr] // bParamFound := TRUE // FI // [liberer le handle hLbvParameter] // OD // [liberer le handle hLbvParameters] for (iIndex = 0; iIndex < lNumberOfParameters && !bParameterFound; iIndex++) { tsApiErrChk(getParametersItem (iModuleAdapter, hTSParametersList, &errorInfo, iIndex, &hTSParameter), TS_ERROR); tsApiErrChk(getParameterName (iModuleAdapter, hTSParameter, &errorInfo, &sParameterName), TS_ERROR); if ( strcmp (sParameterName, sParamName) == 0) { tsApiErrChk(setParameterValueExpr (iModuleAdapter, hTSParameter, &errorInfo, sValueExpr), TS_ERROR); bParameterFound = VTRUE; } CA_DiscardObjHandle(hTSParameter); } }
Thanks,
Anthony
12-08-2009 10:54 AM
Moreover, the function TS_DotNetModuleGetMetadataToken returns metadata=-1. So I think, I've done an error before this function.
Anthony
12-08-2009 11:50 AM
Anthony -
Please provide an explanation of what you are trying to do along with an example assembly for which you wish to accomplish this task and I will try to provide a simple example of doing so.
12-08-2009 02:18 PM
I do a software which can automatically generate TestStand sequences from a model. (For information it's called MaTeLo but it's not the topic! lol)
And this software can create steps in sequence TestStand with different module adapters like sequence call, CVI, labview, Dll,... But it doesn't work with the dot net adapter and i don't know why.
(If you want an evaluation licence of our software for understanding, i can send it)
Anthony
12-10-2009 05:01 PM
Anthony -
It turns out that this isn't a trivial implementation. I am working on putting together an example that will help you accomplish this task. I will attach it to this thread when I have completed it.
Thanks for your patience.
12-11-2009 02:44 AM
Thank you for your help. I look forward to your message.
Anthony
12-14-2009 03:00 PM - edited 12-14-2009 03:01 PM
Anthony -
Currently, functionality for retrieving the Metadata Token for a class constructor or member is not fully provided in the TestStand .NET Adapter API. The DotNetModule.GetConstructorMetadataToken() and DotNetModule.GetMetadataToken() methods only return the correct Metadata Token when the member/constructor prototypes have already been loaded. Thus, in the case of your code, when you call DotNetModule.GetMetadataToken(), the method is returning -1 because the member prototype for the Step you are referring to has not yet been loaded.
This leaves you with a few options for moving forward. The DotNetModule.LoadConstructorPrototypeFromMetadataToken() and DotNetModule.LoadPrototypeFromMetadataToken() methods will function properly when provided with a correct Metadata Token. In order to get the Metadata Token for the required constructor/member, you can use one of the following approaches:
Get Metadata Token from IL DASM
Get Metadata Token from TestStand
Create your own tool to get Metadata Tokens
Hope this helps. Please let me know if you have any questions.
01-04-2010 01:37 AM