473,326 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 4320
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
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
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
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
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
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
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
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
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
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.