473,624 Members | 2,191 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.Cur rentDirectory

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\myWinA pp.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 4347
Have you tried Assembly.GetExe cutingAssembly( ).CodeBase?

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

"Vincenzo Davi" <da***@hotmail. com> wrote in message
news:7d******** *************** ***@posting.goo gle.com...
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.Cur rentDirectory

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\myWinA pp.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(AppBas e) 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.Cu rrentDirectory

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\bi n\Release\mydll .dll

My Windows app is
C:\MyWinApp\bi n\Release\myWin App.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
1988
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 this is where the application is being run from when debug. But when I build the project, install it (using a deployment project) and then run it, I get a FileNotFound exception, because the XML file
8
5462
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 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
5
1266
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 directory under IIS/5 executable. Everything worked great! Now I am trying to deploy the same app on a Windows 2003 server using the same methodology and I can't get it to function. I followed the same steps above and the basic pages load fine, but...
5
9382
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 the end-user changes the default path that I set up in the deployment project? Thank you in advance!
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 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
1
2775
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 have it's own custom deployment properties such as Publish Version Number, Start Menu and application Name in start menu. For example, in the past (before ClickOnce deployment) I had to build Setup.exe files and distribute them to various...
1
1880
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 to prompt user to select another location to send a data file elsewhere on target machine (with ability to create this directory). 2. After that this secondary location selected/created by the user,
2
1181
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 the name of the redistributable (dotnetfx.exe), which is in the same folder as my setup.exe and setup.msi. However, when I go to install on my test box, which does not have 2.0 of the framework installed, it tries to download the framework from...
0
1964
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 deploy an *offline* application that can only be installed from behind our organizational firewall (a Win2k3 domain), but can be updated from anywhere (hotels, etc). To do this, the publishing folder location is set to a UNC share path:
0
8234
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8620
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8335
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5563
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4079
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1482
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.