Add reference to DLL on the same directory

Hello,

I have a project to which I need to add a reference to a DLL. The DLL is located in some directory in my computer which causes problems when the application is moved to another PC. I know there's a dependency that needs to be maintained between computers that run the application (i.e. the DLL must be located in the directory that it was when it's reference was added); my question is, can I add the reference to the "self" directory, so the application searches the directory of the EXE for the DLL?

Thanks :)
LVL 1
bass20Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PaulHewsCommented:
>I know there's a dependency that needs to be maintained between computers that run the application (i.e. the DLL must be located in the directory that it was when it's reference was added);

That's not really how it works.  The information is stored in the registry and is referenced either by the CLSID or Program ID.  The registry allows the COM machinery to resolve the path to the DLL.  It doesn't matter where the DLL is located, as long as it is registered for COM properly.  

To register your DLL on the second computer, you can:
1.  Create an installer using the Setup and Deployment Wizard  
    http://msdn2.microsoft.com/en-us/library/aa262321(VS.60).aspx
    http://visualbasic.about.com/od/usevb6/l/bl0001a.htm

2.  Register manually using regsvr32  (start> run > Regsvr32 "C:\path to dll\dllname.dll")

3.  Register with code
Programmatically register an ActiveX control or DLL
http://www.devx.com/vb2themax/Tip/18426

Before registering, make sure that all the dependencies for the DLL are installed or you will have problems.



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.