Hexagon Geospatial
MENU

ERDAS APOLLO & ECW/JP2

Wondering how others have configured their ERDAS APOLLO server or what data they are crawling? The ERDAS APOLLO Discussion board is a place to find information, share ideas and more. Join the community, connect, contribute and share.
Showing results for 
Search instead for 
Do you mean 
Reply
New Member
Posts: 1
Registered: ‎02-01-2018

Violation Exception

[ Edited ]

Hello Everyone. I just write a c# wrapper for ECW SDK and I get an exception. I can get any ecw/jp2 file's meta data successfully but I wanted to wrap another basic function from dll and I get an interesting exception. The exception stays on top even while I loged out. and the exception is coming from NCSEcw.dll file. So can you help me?

 

public void SetFileView(String path)
        {
            UInt32 temp;
            NCSError error;
            error = NCSInit();
            error = NCSOpenFileViewA(path, out temp);
            IntPtr tempPointer = new IntPtr(temp);

            int[] bands = new int[3];
            for (int i = 0; i < 3; i++)
            {
                bands[i] = i;
            }

            IntPtr p = Marshal.AllocHGlobal(bands.Length);
            Marshal.Copy(bands, 0, p, bands.Length);

            IntPtr fileInfo;
            NCSFileInfo nCSFileInfo = new NCSFileInfo();
            error = NCSGetViewFileInfo(tempPointer, out fileInfo);
            Marshal.PtrToStructure(fileInfo, nCSFileInfo);


            error = NCSSetFileView(tempPointer, nCSFileInfo.nBands, p, 0, 0, 1499, 1499, 333, 333);


        }


        [DllImport("C:\\NCSEcw.dll", CallingConvention = CallingConvention.Cdecl)]
        private static extern NCSError NCSInit();

        [DllImport("C:\\NCSEcw.dll", CallingConvention = CallingConvention.Cdecl)]
        private static extern NCSError NCSOpenFileViewA([MarshalAs(UnmanagedType.LPStr)] string path, out UInt32 a);

        [DllImport("C:\\NCSEcw.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        private static extern NCSError NCSGetViewFileInfo(IntPtr a, out IntPtr fileInfo);

        [DllImport("C:\\NCSEcw.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        private static extern NCSError NCSCloseFileView(IntPtr a);

        [DllImport("C:\\NCSEcw.dll", CallingConvention = CallingConvention.Cdecl)]
        private static extern NCSError NCSShutdown();

        [DllImport("C:\\NCSEcw.dll", CallingConvention = CallingConvention.Cdecl)]
        private static extern NCSError NCSEditClose(IntPtr 
[DllImport("C:\\NCSEcw.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern NCSError NCSSetFileView(IntPtr pNCSFileView, int nBands, IntPtr pBandList, int nTLX, int nTLY, int nBRX, int nBRY, int nSizeX, int nSizeY); [DllImport("C:\\NCSEcw.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern NCSError NCSCopyFileInfo(IntPtr dst, IntPtr src);
Staff
Posts: 503
Registered: ‎02-02-2016

Re: Violation Exception

The exception report indicates that it is coming from the refresh call-back in the ECW library. When an image is opened in progressive mode (a callback is passed to NCSOpenFileView) if an exception is thrown in your code during this call-back and not caught, the SDK attempts to catch it and report the issue since the SDK started that thread. That’s the dialog that pops up.

 

You can suppress this dialog by calling NCSRethrowCaughtException(true). However, the application will still terminate if it does not catch the exception, it’s not the cause of the crash. You can also call NCSShowExceptionDialog(false) and let the exception be caught by the SDK, but no warning dialog will be shown.

 

Without seeing the full code for your wrapper class, this is hard to diagnose but it looks to be an error in the implementation of the refreshCallback function, or you haven’t supplied one. In your code NCSOpenFileViewA takes a third parameter (the callback), setting this to nullptr will use non-progressive decoding and might be what you’re after.

 

Regards,

 

Stephen Bent

Hexagon Geospatial Support

 

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.