473,499 Members | 1,533 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help, .NET dll deployment path location

I have created a dll with several classes in C#. One of the classes
references image files in the subdirectories of the bin/Release folder
(basically where the dll resides).

Now, I want to use the dll from a C# Windows application.

In the class that references the images in the subdirectory, I use the
following code to make use of that directory:
Environment.CurrentDirectory

When I reference the dll from the new Windows Application and run, I
get an error saying the images can't be found because it's trying to
find them in that Windows application /bin/Release.

So for example, my dll is:
C:\MyDLLApp\bin\Release\mydll.dll

My Windows app is
C:\MyWinApp\bin\Release\myWinApp.exe

What do I have to do in the dll project to make it reference the dll's
resident directory, not the calling application?

Thanks for any help!
-Vinny Davi
Jul 21 '05 #1
2 4332
Have you tried Assembly.GetExecutingAssembly().CodeBase?

--
____________________
Klaus H. Probst, MVP
http://www.vbbox.com/

"Vincenzo Davi" <da***@hotmail.com> wrote in message
news:7d**************************@posting.google.c om...
I have created a dll with several classes in C#. One of the classes
references image files in the subdirectories of the bin/Release folder
(basically where the dll resides).

Now, I want to use the dll from a C# Windows application.

In the class that references the images in the subdirectory, I use the
following code to make use of that directory:
Environment.CurrentDirectory

When I reference the dll from the new Windows Application and run, I
get an error saying the images can't be found because it's trying to
find them in that Windows application /bin/Release.

So for example, my dll is:
C:\MyDLLApp\bin\Release\mydll.dll

My Windows app is
C:\MyWinApp\bin\Release\myWinApp.exe

What do I have to do in the dll project to make it reference the dll's
resident directory, not the calling application?

Thanks for any help!
-Vinny Davi

Jul 21 '05 #2
Hi

The .Net runtime looks for specific folders when it loads
the referenced assemblies. So even if you get thecurrent
directory's path it wont be of any help as the runtime
will NOT search there. The runtime searches the AppBase,
GAC, Location in CodeBase element of config file, Location
in PrivateBinPath element of config file when a assembly
is to be loaded

You have 4 options

1) Put the referenced dll in the same location(AppBase) as
the calling assembly i.e. the bin folder. This probably
you dont want as per ur reqmt.

2) Create a subfolder inside bin and place the referenced
assembly dll there. In this case you have to add a
PrivateBinPath element in the application/web config file
with the subfolder location specified

3) If you want to place the referenced assembly dll
outside the calling application folder structure then you
have 2 options a) Using Shared Assemblies (or) b)Using the
Codebase Element

Note : Both the below options require u to strongname the
assembly

a) Shared Assemblies : Shared assemblies are those
assemblies wghich are placed in the GAC and shared across
many apps in the machine. So you can strongname your
referenced assembly and place it in the GAC using the
GACUtil utility

b) Codebase Element. What you can do in this is that,
first strongname your referenced assembly and place it in
any location on the local disk(could even be a remote
file/http server with proper permission sets). Then
specify the location in the codebase element of the config
file. This will be used by the runtime to locate your
assembly.

Also if you do not want any of this you can use the Load
Assembly function of the AppDomain to load an assembly
from any location, but i suggest you do not use this to
avoid versioning problems!!!
For more info on the above options, check out MSDN for
Shared Assemblies, CodeBase, Private BinPath,
LoadAssembly. Do post/mail me in case you have any more
doubts

hth

regards,

sr

-----Original Message-----
I have created a dll with several classes in C#. One of the classesreferences image files in the subdirectories of the bin/Release folder(basically where the dll resides).

Now, I want to use the dll from a C# Windows application.

In the class that references the images in the subdirectory, I use thefollowing code to make use of that directory:
Environment.CurrentDirectory

When I reference the dll from the new Windows Application and run, Iget an error saying the images can't be found because it's trying tofind them in that Windows application /bin/Release.

So for example, my dll is:
C:\MyDLLApp\bin\Release\mydll.dll

My Windows app is
C:\MyWinApp\bin\Release\myWinApp.exe

What do I have to do in the dll project to make it reference the dll'sresident directory, not the calling application?

Thanks for any help!
-Vinny Davi
.

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1974
by: Cuperman | last post by:
Hi all, I have an XML file that I reference in my windows application I access it using - Application.StartupPath & "/ini.xml" During development this resides in the Bin folder, it appears...
8
5448
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
5
1255
by: DEWright_CA | last post by:
I have a app that I built for a client. I was able to deploy it to a test server without any real issue. I copied the bin folder to my server, copied over the aspx pages and made the virtual...
5
9368
by: Grumpy Aero Guy | last post by:
I have a project with a deployment project. All works GREAT !!! Is there a system variable (maybe via the dot net framework I'm assuming) that stores the installation path of the app, assuming...
4
656
by: Vincenzo Davi | last post by:
I have created a dll with several classes in C#. One of the classes references image files in the subdirectories of the bin/Release folder (basically where the dll resides). Now, I want to use...
1
2755
by: moondaddy | last post by:
I need to have multiple deployment profiles for a .net 2.0 winforms project. This is my requirement: 1) Re-use same project for multiple ClickOnce deployment profiles. 2) Each profile will...
1
1861
by: Gene | last post by:
I would like to know if the following is even possible with the visual studio.net Setup and Deployment project. 1. During the deployment after creation of application directory the setup needs...
2
1175
by: SAL | last post by:
Hello, I've created a setup and deployment project for my application. VS2005 automatically included a launch condition for the .net framework 2.0. I changed the InstallUrl path Property to just...
0
1957
by: =?Utf-8?B?VCFN?= | last post by:
Hi All, I've been successfully deploying clickOnce successfully through the 2.0 and 3.X frameworks, but now have a problem with ClickOnce updates in 3.5 SP1. The scenario is this: I want to...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.