468,463 Members | 1,959 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,463 developers. It's quick & easy.

VB.NET - Set path for DLLs

Max
Have a little problem here; I have a solution with two projects. One of
the projects is an executable file and the other is a dll. The dll is
just basically one class, so in the exe I've added that project as a
reference and am able to use all the contents by creating a new object
(Dim myclass as new dll_file.myclass). That works fine, when I build the
solution it creates those two files and everything works, however, what
I need to do is have the dll in a different folder then the executable.
How do I tell the exe file to look for this dll in the \bin\ folder for
example? Right now I've specified the target paths so it automatically
puts the files where they need to be, but when I launch the program it
comes up with an error that basically states file not found.
Nov 20 '05 #1
6 14261
"Max" <ma*****@yahoo.com> schrieb
Have a little problem here; I have a solution with two projects. One
of the projects is an executable file and the other is a dll. The
dll is just basically one class, so in the exe I've added that
project as a reference and am able to use all the contents by
creating a new object (Dim myclass as new dll_file.myclass). That
works fine, when I build the solution it creates those two files and
everything works, however, what I need to do is have the dll in a
different folder then the executable. How do I tell the exe file to
look for this dll in the \bin\ folder for example? Right now I've
specified the target paths so it automatically puts the files where
they need to be, but when I launch the program it comes up with an
error that basically states file not found.


Maybe this helps?

http://msdn.microsoft.com/library/en...assemblies.asp
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
Max
Armin Zingler wrote:
"Max" <ma*****@yahoo.com> schrieb

Have a little problem here; I have a solution with two projects. One
of the projects is an executable file and the other is a dll. The
dll is just basically one class, so in the exe I've added that
project as a reference and am able to use all the contents by
creating a new object (Dim myclass as new dll_file.myclass). That
works fine, when I build the solution it creates those two files and
everything works, however, what I need to do is have the dll in a
different folder then the executable. How do I tell the exe file to
look for this dll in the \bin\ folder for example? Right now I've
specified the target paths so it automatically puts the files where
they need to be, but when I launch the program it comes up with an
error that basically states file not found.


Maybe this helps?

http://msdn.microsoft.com/library/en...assemblies.asp


Could you give me some code examples?
Nov 20 '05 #3
"Max" <ma*****@yahoo.com> schrieb


Maybe this helps?


http://msdn.microsoft.com/library/en...runtimelocates

assemblies.asp



Could you give me some code examples?


No.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
Max,
In addition to Armin's comments.

You can use either AppDomain.AppendPrivatePath or the
runtime/assemblyBinding/probing/privatePath app.config setting.

The problem with AppDomain.AppendPrivatePath, is it gets done after the
startup class & method starts, so if the startup class & method refers to
anything in the class assemblies you get JIT errors...

Public Sub Main()
AppDomain.CurrentDomain.AppendPRivatePath("bin")
...
End Sub

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin" />
</assemblyBinding>
</runtime>
</configuration>

Hope this helps
Jay

"Max" <ma*****@yahoo.com> wrote in message
news:6u********************@comcast.com...
Have a little problem here; I have a solution with two projects. One of
the projects is an executable file and the other is a dll. The dll is
just basically one class, so in the exe I've added that project as a
reference and am able to use all the contents by creating a new object
(Dim myclass as new dll_file.myclass). That works fine, when I build the
solution it creates those two files and everything works, however, what
I need to do is have the dll in a different folder then the executable.
How do I tell the exe file to look for this dll in the \bin\ folder for
example? Right now I've specified the target paths so it automatically
puts the files where they need to be, but when I launch the program it
comes up with an error that basically states file not found.

Nov 20 '05 #5
Max
Thanks for that suggestion, however I'm not exactly sure how to use that
<configuration> stuff?
I tried AppDomain way, but still doesn't seem to find the dll:

Public Sub Main()
AppDomain.CurrentDomain.AppendPrivatePath("bin")

Dim Shell As New Shell_dll.Shell_Main
Shell.TestSub()
End Sub

Basically have Shell_dll namespace and a class Shell_Main in the
Shell.dll file that's in \bin directory. TestSub should simply give me a
msgbox to let me know that it works.
Jay B. Harlow [MVP - Outlook] wrote:
Max,
In addition to Armin's comments.

You can use either AppDomain.AppendPrivatePath or the
runtime/assemblyBinding/probing/privatePath app.config setting.

The problem with AppDomain.AppendPrivatePath, is it gets done after the
startup class & method starts, so if the startup class & method refers to
anything in the class assemblies you get JIT errors...

Public Sub Main()
AppDomain.CurrentDomain.AppendPRivatePath("bin")
...
End Sub

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin" />
</assemblyBinding>
</runtime>
</configuration>

Hope this helps
Jay

"Max" <ma*****@yahoo.com> wrote in message
news:6u********************@comcast.com...

Have a little problem here; I have a solution with two projects. One of
the projects is an executable file and the other is a dll. The dll is
just basically one class, so in the exe I've added that project as a
reference and am able to use all the contents by creating a new object
(Dim myclass as new dll_file.myclass). That works fine, when I build the
solution it creates those two files and everything works, however, what
I need to do is have the dll in a different folder then the executable.
How do I tell the exe file to look for this dll in the \bin\ folder for
example? Right now I've specified the target paths so it automatically
puts the files where they need to be, but when I launch the program it
comes up with an error that basically states file not found.


Nov 20 '05 #6
Max,
To use the <configuration> stuff you need to add an app.config to your EXE
project, the "best" way to do this is to use "Project - Add New Item -
Application Configuration File". This will create an empty app.config file
in the root of your project.

After you do this, when you build your app a file will be created in your
bin directory called YourProject.exe.config (that matches your
YouProject.exe).

Hope this helps
Jay

"Max" <ma*****@yahoo.com> wrote in message
news:tr********************@comcast.com...
Thanks for that suggestion, however I'm not exactly sure how to use that
<configuration> stuff?
I tried AppDomain way, but still doesn't seem to find the dll:

Public Sub Main()
AppDomain.CurrentDomain.AppendPrivatePath("bin")

Dim Shell As New Shell_dll.Shell_Main
Shell.TestSub()
End Sub

Basically have Shell_dll namespace and a class Shell_Main in the
Shell.dll file that's in \bin directory. TestSub should simply give me a
msgbox to let me know that it works.
Jay B. Harlow [MVP - Outlook] wrote:
Max,
In addition to Armin's comments.

You can use either AppDomain.AppendPrivatePath or the
runtime/assemblyBinding/probing/privatePath app.config setting.

The problem with AppDomain.AppendPrivatePath, is it gets done after the
startup class & method starts, so if the startup class & method refers to
anything in the class assemblies you get JIT errors...

Public Sub Main()
AppDomain.CurrentDomain.AppendPRivatePath("bin")
...
End Sub

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin" />
</assemblyBinding>
</runtime>
</configuration>

Hope this helps
Jay

"Max" <ma*****@yahoo.com> wrote in message
news:6u********************@comcast.com...

Have a little problem here; I have a solution with two projects. One of
the projects is an executable file and the other is a dll. The dll is
just basically one class, so in the exe I've added that project as a
reference and am able to use all the contents by creating a new object
(Dim myclass as new dll_file.myclass). That works fine, when I build the
solution it creates those two files and everything works, however, what
I need to do is have the dll in a different folder then the executable.
How do I tell the exe file to look for this dll in the \bin\ folder for
example? Right now I've specified the target paths so it automatically
puts the files where they need to be, but when I launch the program it
comes up with an error that basically states file not found.


Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by ketulp_baroda | last post: by
9 posts views Thread by Grant Edwards | last post: by
6 posts views Thread by Laszlo Zsolt Nagy | last post: by
4 posts views Thread by Matt Sawyer | last post: by
1 post views Thread by iana_kosio | last post: by
reply views Thread by Reini | last post: by
reply views Thread by Chris Ashley | last post: by
7 posts views Thread by siggi | last post: by
6 posts views Thread by HONOREDANCESTOR | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.