Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DllImport problem

Status
Not open for further replies.

sbayeta

Programmer
Apr 4, 2003
13
0
0
AR
Hi,



I'm using p/invoke to call a couple of BLAS routines, and the strangest thing is happening. Yesterday I wrote the code to call an unmanaged function called dgemm, using a dll I downloaded from the web.


Code:
[DllImport("blas_win32.dll")]

//[DllImport("libacml.dll")]

unsafe private static extern int dgemm_(string transa, string transb, int* m, int* n, int* k, double* alpha,

double[] a, int* lda, double[] b, int* ldb, double* beta, double[] c, int* ldc);


Then I downloaded a faster version of the library specially targeted for AMD processors. I tried the code and everything worked just fine. I was able to run the code using both dllimports (blas_win32 and libacml) and to evaluate execution speeds and results. I put the dll files in the same folder as the project (\bin\debug) and only there.



Today I tried to run the code before start programming and I was surpprised to find a DllNotFoundException with the message The specified procedure could not be found HRESULT: 0x8007007F



I can't think of anything changing from lastnight, so I'm very frustrated about this.



I tryed a lot of things to make this work, like copying the file to system32, to another project and call the original function from there, used Dependency Walker to find dependencies, reinsatalled the amd package, etc. I even ran all the apps I remember runing yesterday, thinking this maight load something in memory, but nothing worked.



The dependency walker shows a dependency of the file on cygwin1.dll, but I don't have this file, and never did.



Does anyone know what may be causing this problem?



Thanks in advance,

Santiago.

 
cygwin1.dll, Isn't that for CD Burning?

By any chance did you click "Rebuild" in visual studio? If the DLL was in your bin directory the rebuild would have deleted it.

To get around this, you have 2 easy options.

1. Write a post-build script that copies the DLL into your BIN directory if that is in fact the place where the DLL needs to be.

2. You said you copied the DLL into the system32 directory - did you use regsvr32? This makes windows globally aware of the file. Open a command prompt and type

regsvr32 C:\Windows\System32\blas_win32.dll or whatever the path is to your dll.

Then re-run your app.

As an added note: don't put the dll in the bin, and register it. It will cause you nothing but pain.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top