Pelco Developer Network (PDN)

AccessViolationException when trying to get camera device

Hi,

I am always getting an 'AccessViolationException' when I tried to get camera device using 'getGetItemByKey(string devickey)' as shown below. I am currently stumped to how to rectify this problem as I have tried to keep my codes as similar to the working export sample code provided.

The only major differences are that my code variables/methods are static and my application is a windows service though I doubt these are the possible causes. I have checked that I was using .Net framework version 4.5.1 at least. I have also tried using both debug/release version and both gives me the same error.Any advice and help you can give me is deeply appreciated. Thank you..

Framework Version v.4.0.30319
Description. The process was terminated due to an unhandled exception.
Exception Info.System.AccessViolationException
at Pelco.SDK.SystemCollection.!SystemCollection()
at Pelco.SDK.SystemCollection.Dispose(Boolean)
at Pelco.SDK.SystemCollection.Finalize()

Best Regards,
M.Syafiq

Hello there!

Sorry to hear about the problems you're having. I fired up the ExportVideo C# sample that is included with the Pelco SDK, and added a line of code to quickly test this out. I added the following line of code after line #160 in the LoadCameras(...) method:

Pelco.SDK.Device getDevice = dc.GetItemByKey("xxxxx");

If I replace the string there with a camera's UDN, I'm successfully obtaining camera devices using the UDN to assign to my new device object -- without getting an access violation. The sample code seems to be working from these tests to access the objects and the device cache as necessary.

I wish that I could help you out further ... really what I can offer would be suggestions on things to take a look at. The PelcoDeviceCache.db file might be inaccessible from the calling service or application, or it could possibly be a problem with different calling objects within the code. There could be other reasons, too.

One other point I might make too was that you indicated that you are using.NET 4.5.1, but the error message you've pasted indicates Framework Version v.4.0.30319. Perhaps the application / project is targeting an incorrect .NET framework version?