Link to home
Start Free TrialLog in
Avatar of guidway
guidwayFlag for United States of America

asked on

problem with error code in LoadLibrary

This is really weird (in my opinion)

I originally created a dll for a project I'm working on and as long as I stay in the same user account I created it in it works fine. However logging in as a different user I get "error in loading dll" when I try to run my app. I then found code on the MS website to query for the particular error that is causing this (LoadLibrary errors). Here's the strange part... It returns a value of 1?!?!? The lookup table of error messages for LoadLibrary does not even contain a 1. It has 0, 2 and up through 30 (with the exception of a few). How do I found what error code 1 means? I can't debug it without knowing the problem. Why did Microsoft leave off some of the error code information from their lookup tables? It doesn't make sense (to me anyway). Thanks for anyone that can help!

here's the information I'm referring to: http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q142/8/14.asp&NoWebContent=1

guid
Avatar of NBrownoh
NBrownoh

its cuz they need something to update in future releases right?

as far as that goes, where is your dll stored at?  is that drive or folder available to other users?
Perhaps the dll attempting to be accessed is in a location where your original login has proper rights but the different user does not.
i think were gonna have to split the question up azra :) j/k
I didn't even read your full comment.  You got it first (if thats really the issue).   :-)
Avatar of guidway

ASKER

both accounts are power users and I didn't set any restrictions on what areas they can access or not. I just checked and everyone has full access to that directory and the dll and program file. I don't think it is a permissions issue. thanks for the responses, any other ideas?

guid
Avatar of guidway

ASKER

>>its cuz they need something to update in future releases right?<<

I was wondering that myself. Either that or they expect you to call and pay a nice high fee to get the rest of the codes from their tech support group... I figured they would have *all* the codes documented somewhere or something.
So you created a COM dll?  Any ideas which dll is causing the LoadLibrary problem?
somewhere, deep inside msdn.com, i hate that site.  Everything is stored in very odd hard to find places.  Id check permissions on folders before going there to find the def to an error code that probably wont turn up much help.
ok, i found a description for error code 1

1 Incorrect function. ERROR_INVALID_FUNCTION

so id check your dll and make sure there isnt any errornous code in that, seems to be what geterror would be reporting.
Avatar of guidway

ASKER

Azra,

>>So you created a COM dll? <<
yeah, basically the dll is an extension I created for an application called ArcGIS 8.2. The ArcGIS 8.2 application works fine on the new user account, but not my dll/program which runs under it.

>>Any ideas which dll is causing the LoadLibrary problem? <<
The one that returns the error code 1 I mentioned is my dll file (called tools.dll). Again it works fine on my user account, but not on another account.

NBrownoh,

I checked the permission under the Security tab of both the directory and the files themselves. Is there somewhere else I need to check permissions?

thanks again
guid
Avatar of guidway

ASKER

NBrownoh,

where did you find the error code at? So I know where I can obtain the info. thanks
Avatar of guidway

ASKER

NBrownoh,

thanks for the list of system error codes but I don't believe those are the same error codes used in LoadLibrary. For instance on loadlibrary, code 0 means not enough memory whereas the system code you provided means the operation completed. I think these are two different lookup tables. Azra, what do you think about this? Am I wrong in thinking that?

guid
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of guidway

ASKER

NBrownoh,

Assuming you are correct ...

why would one function work in one user account but not the other? I could see if I was creating something that accessed user information in their own profiles, but everything I do is in a common directory everyone has access to.

Although this is M$... anything is possible. ;-) I'll take a look at it and see if I can find anything.
Avatar of guidway

ASKER

Azra,

thanks for the info!

>>perhaps its an API call within your dll that is actually returning the error. <<

is there anyway I can determine what that call would be? The only error I get is "Error in dll". I tried loading it in my VB environment under the new user account and trying to run it and I get this error before it even hits any of my code. Anyway to figure out the details of it?
not too sure there.  its strange.
All your global Declare statements in your project will be called when your project loads.  There really isn't a way to pinpoint which one causes the error that I am aware of.  Do you have a lot of Declares or just a few?  Also, are you accessing a lot of dlls, or just a couple (like kernel, user32).
Avatar of guidway

ASKER

I see what you mean. I didn't even think of those. I'll take a look at those (one by one) now and check them. I do use quite a few but they are mostly from the kernel32, advapi32 libraries I think. I'll let you know what happens. thanks a bunch!

guid
>>All your global Declare statements in your project will be called when your project loads

I have always been under this impression, but I haven't found any documentation to back this up.  All sources seem to indicate that the dlls specifed in the Declares are only loaded when one of their functions is first called, regardless if they are globally/publicly declared or not.  However, you say that you get an error before it even loads any of your code.  Perhaps its an issue with the msvbvm60.dll?
Avatar of guidway

ASKER

made a BIG mistake I just found...

I just realized that my normal account I wrote this on was an administrator account (my stupidity for forgetting that). The new account is a power user account. I'm guessing there are some dlls that power users can't access or some areas of the registry I can't access or something... I can see I got myself in a pickle with this one... :-( I shouldn't have programmed as an administrator. It didn't dawn on me at the time I might have this trouble.

Any advice you can provide on how to make this app user friendly to power users (now that I know it was written as an administrator) will result in more points or if you feel I am trying to piggy back on this question and would rather me create a new question let me know and I will do so.  Sorry for not realizing that earlier.

I'm still looking through the declare statements but no luck yet.
My first guess would be to take a look at the access rights of power users to the system32 folder.  That is where these dlls in question usually reside.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of guidway

ASKER

I switched my main account to a power user for debugging and it works great as a power user (nothing failed). I went back to the other account (the new one that is a power user) and it fails still. I commented out all the references to API calls I make in the dll and tried compiling again and got the same error. I tried renaming the dll and copying a whole new dll and same error. I tried re-registering the dll with the system and it registered fine but then I got this same error when running. Anything else I could try? thanks again for the help.

guid
Avatar of guidway

ASKER

It seems power user and administrator really aren't that much different (whew!). Still hasn't fixed my error but that had me worried for a while.
Well, it still has something to do with a non COM dll because, as mentioned before, COM dlls are not loaded using LoadLibrary.  


>>I commented out all the references to API calls I make in the dll and tried compiling again and got the same error

Can you explain again where and when you get the error?
Avatar of guidway

ASKER

>>Can you explain again where and when you get the error? <<

sure... when I click on my executable file (under the new user account as power user) it gives the error above, no other messages associated with it. This executable is linked to the dll file I created. So when that didn't work I decided to try to run my VB IDE and debug the application while it was on the new user account to see if it was an error in my code. I put a breakpoint on my first line I run in main and tried to run it. As soon as I click on the compilation button or the run/debug button in VB it produces this same error without even touching my breakpoint (it must be something happening before it steps through the code as you previously mentioned).

I have isolated the dll project from the other executable project and still can't compile it (the executable compiles fine by itself) so I know it is my dll that is the problem (as you said already). However the only error I have to go by is "Error in loading dll". Even without the API declarations I still get the error.

is that any more helpful?

Avatar of guidway

ASKER

ok. it seems to have started working and I'm not sure why. I still get the error in the VB environment although but at least since the executable is working now that is the important part. I just created a new test user account and tried to run the program and it worked great. Not sure why the VB environment gives this error, but I'm hoping it stays only in VB and maybe I can work past it. I will give points tomorrow since I'm already late for a class. thanks again for your help.
Avatar of guidway

ASKER

splitting point like this:

300pts for Azra
200pts for NBrownoh in this question and a 100pt "pts for" question in this area found at: https://www.experts-exchange.com/questions/20791007/pts-for-NBrownoh.html

thanks again for your help.

I still want to try to fix the issue with VB not compiling my project under any other user account however I have created a new question at:

https://www.experts-exchange.com/questions/20791014/VB-not-compiling-project-under-different-user-account.html