Cannot Release C++ win32 dll loaded by vb.net

S

sanu

Hi,

I have a dll declared in my VB.Net Webservice as below

Declare Function fntest Lib "test.dll" _
Alias "TEST_FUNC" (ByVal a As Integer, ByVal b As Integer, ByVal c As
Single) As Double

result = fntest (1,3,5)
Return result

After running this webservice, iam not able to delete the test.dll, it
says access denied. I have to re-boot my machine to delete this
test.dll.

How can we get this dll loaded to be released in the VB.net code?
Will the dll be loaded to memory each time we call the webservice?

I would appreciate any help

Thanks
Saish
 
M

Mattias Sjögren

How can we get this dll loaded to be released in the VB.net code?

You can try calling FreeLibrary. But why do you want to release it? If
it's only for replacing it during development, you can kill the
ASP.NET worker process.

Will the dll be loaded to memory each time we call the webservice?

No, it's only loaded once per process.



Mattias
 
S

sanu

Hello Mattias

Thanks for your reply.

I was reading about loading and releasing in VB using the below
functions
Public Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As
Long,... Public Declare Function LoadLibrary Lib "kernel32" Alias
"LoadLibraryA"
Public Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As
Long) ...

But it also says in vb.net it does not matter if we use the above
functions..,

Also when you declare your dll functions as below
Declare Function fntest Lib "test.dll" _
Alias "TEST_FUNC" (ByVal a As Integer, ByVal b As Integer, ByVal c As
Single) As Double
It loads your dll, so no need to use loadlibrary.
Using the above "fntest" declaration I don't know how to get the
FreeLibrary function called as I don't have a handle to the dll.

Please can you help me how can this be coded.

Thanks
Saish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top