NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

EAccess Violation error

I have created a TestStand sequence and am trying to run a ScanWorksAPI .dll function (sw_LoadProject). When I try and run it I get an error: EAccessViolation. The sequence stops and hangs. The error code I get is "-17502, system level exception". What does this error mean? What causes it? How can I fix it?
0 Kudos
Message 1 of 9
(5,505 Views)
Hi Marek D,

Generally, system level exceptions indicate memory access violations such as dereferencing null pointers or accessing memory locations that don't belong to your application in general.

I assume that you are using a DLL Flexible Prototype Adapter action step to call this dll function. Does the function take any parameters? Are these parameters inputs only or are some of them outputs as well? If you are passing TestStand properties to the dll by reference it is possible for the dll to reference them in a way that is inappropriate and can cause such errors (which may indicate that you are passing parameters to it incorrectly as well). There is also a possibility that there is a problem with the dll in general and that it is causing the error regar
dless of anything you do in TestStand.

If you created this dll, you should debug it from your development environment by attaching to the Sequence Editor application process before running a sequence that calls any of the dll's functions. At any rate, the problem is most likely be caused by inappropriate use of the dll, or a flaw in the code of the dll.

If you cannot discern anything from the information I have posted above, make a comment to this answer stating the following:

1)What version of TestStand you are using.
2)If you can create a simple one-step example sequence that illustrates the problem that anyone can run (this means that no hardware is required).
3)The results of your debugging processes.

Jason F.
Applications Engineer
National Instruments
www.ni.com/ask
0 Kudos
Message 2 of 9
(5,505 Views)
Hey Jason F,

In response to your answer:
1) I'm using TestStand Version 2.0
2) I've attached a zip which contains a three step sequence that should create the same problem. I've also attached the .dll. You should note that in the "locals" section, there is a variable named ProjectName with a value "EXAMPLE1". Since you don't have a project loaded on your system, this should run the action (sw_LoadProject) and simply return a fail... but it should not cause an error (hang).
3) I did not write this dll myself, so it should work. When I run the same function in Lab Windows/CVI it does not crash.

One thing that a college mentioned is that the dll seems to output to the standard I/O. The information that it outputs is not used, but could this be generat
ing the memory allocation fault as it tries to print to a console window that doesn't exist?
0 Kudos
Message 3 of 9
(5,505 Views)
The dll you are using requires other dlls that are not part of the windows system, namely borlndmm.dll, cc3250mt.dll and proxydll.dll. The first two appear to be part of a Borland run-time installation and the 3rd may possibly be a Microsoft toolkit module for SMS. Because of these dependencies I cannot run your example, and it may not be prudent to post all of these dlls to the forum since licensing issues may get in the way with the 3rd party packages you are using. If you are certain that this is not a problem, please check the dependencies of the dll (with Microsoft's QuikView or Depends) and include the dlls I mentioned above in your next post. If you cannot include these dlls then I will only be able to speculate as to what the problem is a
s follows:

Can you tell me what step in the MainSequence you are getting the error on? Are you sure that you have defined the prototypes for each of the DLL Flexible Prototype Adapter function call steps correctly? If it happens on the function call to sw_LoadProject, are you certain that the function does not expect this to be a string buffer instead of a const (maybe it is trying to put new data into the buffer you pass)? Are you sure the calling convention for the functions is stdcall, or is it supposed to be cdecl? (A good indication of whether to use cdecl or stdcall would come from your work done in LW/CVI. If when you prototype the function for use in LW/CVI you did not specify a calling convention at all then it is cdecl, since this is the default in CVI unless you have changed the compiler setting for this. If you specified a calling convention then it should be evident as to what you should use.)

Try working with different settings in the areas of interest I menti
oned above and let me know of any updates or if you can indeed give me the rest of the files to run your example.

Jason F.
Applications Engineer
National Instruments
www.ni.com/ask
0 Kudos
Message 4 of 9
(5,505 Views)
Jason F.

I've included the fore mentioned dlls in a new zip file, hopefully this will allow you to run my example.

To answer you questions:
-I'm am getting the error message in the Setup section when I run the "sw_LoadProject" step.
-I am quite sure that the functions have been defined properly... just in case though, I've also included the prototype file (msswproto.h).
-I have tried using both a const and a string buffer as the parameter and I get the same error when I run sw_LoadProject.
-I did not specify a calling convention while using CVI, so I assume that I am using cdecl, not stdcall. Does this effect TestStand in any way?

Thanks,
Marek
0 Kudos
Message 5 of 9
(5,505 Views)
Marek D,

First off, thanks for submitting the rest of the files.

Now, the only problem is that I cannot properly use this dll in TestStand or CVI by following the prototypes given in the msswproto.h include file.

When using the dll's functions in the same manner that you were trying to, the system level exception is actually happening on the call to sw_connect and not sw_loadproject. According to the include file, the functions use the stdcall calling convention, and if you did in fact use this header file in your CVI project then you were indeed using stdcall instead of cdecl. So now I am a bit skeptical as to whether this dll is being used properly or if this header file is indeed the header provided by the Sc
anWorksAPI.dll developer. I have included a zip file to this post that contains a new TS 2.0 seq file that for all intents and purposes is using the dll properly according to the prototypes in the msswproto.h include file, and I have also included a CVI 6.0 project that simply uses the same functions as the sequence file in the exact same manner and illustrates the same error.

From this point, I would like to see some code or example that actually uses this dll properly without error. Unless you can give me the CVI project you mentioned that works so I can discern how to actually use this dll, I will have to just leave the diagnosis as "improper use of dll" as the cause of the error you are seeing.

Jason F.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 9
(5,505 Views)
Jason F,

Thank you for the sample example... the way you were using the LoadProject is the correct way. Unfortunately, I negleted to mention that the ScanWorksAPI requires the ASSET environment to be loaded on your machine. A license is not require in version 3.1.1, but IS required for version 3.2.

Eitherway, you will not be able to successfully "connect" to ASSET if the software is not include. I appologies for the oversight.

I've attached a working demo of my CVI project. Unfortunately, this project requires ASSET to run. I am unaware if you have access to the ASSET ScanWorks application, but if you do, then hopefully this will provided you with all the information you need.

If you are able to run this, then
you should note that when run through CVI, the LoadProject function call work correctly (returning an errorcode of 0) but when the saved sequence is run in TestStand an error occurs.

Thanks again,
Marek D.
0 Kudos
Message 7 of 9
(5,505 Views)
Marek D,

Unfortunately we don't have a license for ScanWorks to use in this case. I tried looking for a demo version on Intertech's website, but it appears that you can only download a release version that requires a password.

Now, after looking at the sample CVI project that you sent, I do believe that there is something that is being overlooked here when comparing the dlls use to what you are doing in TS. I'm not sure if this is required or not when using the dll, but before you called the "sw_LoadProject" function in CVI you called the "sw_GetProjectNameAt" to basically retrieve the name of a project that actually exists. So, in the case of TS, are you sure that the project name you used exists? What i
f you try using sw_GetProjectNameAt to retrieve a project name and then use the returned value with sw_LoadProject in TS? In the case of CVI, what happens if you use a bogus project name when you call sw_LoadProject, does it throw a system exception just like in TS? This would be my best guess for determining whether or not we are using it right in TS.

What I can tell you is that it doesn't appear that there is actually a problem with TS loading and using this dll in your case, since you don't get any load errors and the sw_connect function is located and executed properly. It really does just seem like the dll is being used in an improper fashion, and I would like you to try out the things I mentioned above to see if it will tell us anything. Thanks!

Jason F.
Applications Engineer
National Instruments
www.ni.com/ask
0 Kudos
Message 8 of 9
(5,505 Views)

Hi, I created a dll by labwindows/cvi for teststand call.. the dll is runs scanworks and loads and runs projects. but there is problem when i call the dll in teststand.. but if write the code for executable there is no problem to access scanworks.. because there is a use of InitCVIRTE.. but i cant find any usage of this function for teststand dll..

 

executable ---- WORKS!!

int main (int argc, char *argv[])
{
    if (InitCVIRTE (0, argv, 0) == 0)    /* Needed if linking in external compiler; harmless otherwise */
        return -1;    /* out of memory */
}

 

but my dll has to contain the start of..

void __declspec(dllexport) BS_Test( .... ... ... ...)

 

how can i use InitCVIRTE?? i have to access scanworks..

0 Kudos
Message 9 of 9
(4,773 Views)