Troubleshooting: API errors - error when trying to call most functions

System.Security.SecurityException OR "Request for the permission of type 'System.Security.Permissions.FileIOPermission...' failed" OR "System.TypeInitializationException: The type initializer for 'OzSoft.VETtrakAPI.Functions.Validation' threw an exception" error when trying to call most functions


One cause of this error is if the the DLL files were extracted from a ZIP file that was from the Internet zone and thus are not "trusted" files. Go to the Properties of each of the DLL files in the API's bin folder (one at a time), and there may be an Unblock button - click this to trust the file.



In some cases (administrator file security restrictions), this unblock may not "stick" and the Unblock button may still be there when going back into the file's Properties - to fix this, copy all the DLL files from the API's bin folder to a writeable location (like Documents), unblock the DLLs, then copy the DLL files back into the API's bin folder.

After unblocking all the files, restart the API's app pool to ensure that the change is picked up. To avoid this problem, you need to "Unblock" the ZIP file first before extracting it, so that the extracted files are not blocked.

Another cause of this error is if the API is not running with full trust (perhaps medium trust is configured in the machine.config). To run as full trust, change the API's web.config file to add this tag to the inside of the system.web element:

<trust level="Full"/>


Note that "Full" is case-sensitive.


If this causes the following error -

"This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file."

- then the computer's machine.config or other parent .config file will need to be changed to turn on allowOverride.

In IIS 7+, the trust level can also be checked in the .NET Trust Levels icon in the API's application.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.
×