Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
6633 Discussions

Invalid access to memory location error for C# wrapper

hurlekt
Beginner
268 Views

I have the Intel compiler version 10. I'm trying to create a C# wrapper for some of the image processing library functions. To start off, I downloaded the C# wrapper samples you had and tried to just wrap a simple copy command based off your ipps.cs file:

[DllImport("ipps-6.0.dll", EntryPoint = "ippsCopy_16s")]
unsafe public static extern IppStatus ippsCopy_16s(short* pSrc, short* pDst, int len);

unsafe public static string Copy(string str)
{
if (str == null)
throw new System.ArgumentNullException();
char[] temp = new char[str.Length];
fixed (char* pt = temp, ps = str)
{
ippsCopy_16s((short*)ps, (short*)pt, str.Length);
}
return new System.String(temp);
}

When I try to run this, when it gets to the actual ippsCopy_16s call, I get a Unable to load DLL 'ipps-6.0.dll': Invalid access to memory location. It seems to locate the file okay, and DependencyWalker isn't really telling me anything. What am Imissing?

I can build everything just fine. The stripps.exe app that I had built before I tried modifying anything was receivingthe same exact error.

Please help! Thanks...

0 Kudos
2 Replies
Albert_Stepanov
New Contributor I
268 Views

Hi,
could you please give more information on your machine, OS, Visual Studio?
I wrote the sample with your code:

//foo.cs
using System;
using System.Runtime.InteropServices;

namespace foo {
class foo {

[DllImport("ipps-6.0.dll", EntryPoint = "ippsCopy_16s")]
unsafe public static extern
int ippsCopy_16s(short* pSrc, short* pDst, int len);

unsafe public static string Copy(string str)
{
if (str == null)
throw new System.ArgumentNullException();
char[] temp = new char[str.Length];
fixed (char* pt = temp, ps = str)
{
ippsCopy_16s((short*)ps, (short*)pt, str.Length);
}
return new System.String(temp);
}

public static void Main( System.String[] args ) {
string src = "'Any string'";
string dst = Copy(src);
Console.WriteLine(dst);
}
}
}

compiled it:
>csc /t:exe /unsafe foo.cs

and passed without problems:
>foo.exe
'Any string'


Regards,
Albert
Joseph_S_Intel
Employee
268 Views
Quoting - hurlekt

I have the Intel compiler version 10. I'm trying to create a C# wrapper for some of the image processing library functions. To start off, I downloaded the C# wrapper samples you had and tried to just wrap a simple copy command based off your ipps.cs file:

[DllImport("ipps-6.0.dll", EntryPoint = "ippsCopy_16s")]
unsafe public static extern IppStatus ippsCopy_16s(short* pSrc, short* pDst, int len);

unsafe public static string Copy(string str)
{
if (str == null)
throw new System.ArgumentNullException();
char[] temp = new char[str.Length];
fixed (char* pt = temp, ps = str)
{
ippsCopy_16s((short*)ps, (short*)pt, str.Length);
}
return new System.String(temp);
}

When I try to run this, when it gets to the actual ippsCopy_16s call, I get a Unable to load DLL 'ipps-6.0.dll': Invalid access to memory location. It seems to locate the file okay, and DependencyWalker isn't really telling me anything. What am Imissing?

I can build everything just fine. The stripps.exe app that I had built before I tried modifying anything was receivingthe same exact error.

Please help! Thanks...


Also make sure you are building the app for the same architecture that it will be run on, e.g. I've seen this error whenan application is built for 32 bit but run on a 64 bit OS
Reply