473,396 Members | 1,814 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,396 software developers and data experts.

Loading Assemblies or Classes in C#

Hey All,
I posted something similar in the .NET forums, but am unsure where it belongs, so forgive me if this is the wrong place.

I have a client application, and a folder containing dll's that the application will need to use. In java, if I put jars in the classpath, the JVM loads them automatically.

Is there something similar in .NET or am I stuck calling Assembly.Load on all the dll's in the folder?

Thanks!
Dec 17 '08 #1
2 2284
Frinavale
9,735 Expert Mod 8TB
I have a feeling that you're stuck calling the Load() method for each assembly that you want to load dynamically.

If you don't need to load the assemblies dynamically you could just add a reference to the assemblies to your application.

Have you tried any of the other solution ideas offered in your other thread?

Since this question is about assemblies rather than C#, I would have said your question belongs in the .NET forum; however, since your implementation will be in C# I'm going to leave your thread here.

-Frinny
Dec 18 '08 #2
mldisibio
190 Expert 100+
This is a common issue, where developers have some directory that stores their dlls and want their applications to reference that directory.
Assembly.Load is not really your answer, because when you compile your application, the compiler needs all the metadata of referenced libraries in order to use any of their methods. So when you compile, you would need to reference the dlls anyways, and the reference process makes a copy of the library in your local output directory.
The CLR documentation clearly stipulates:
At run time, a reference must exist in either the Global Assembly Cache (GAC) or the output path of the project.
Dynamically loading and unloading assemblies is an odd construct of Reflection. From an application standpoint, even if you got it to work, I would not recommend it as the solution just so that you can reference a common library. I believe its intent is geared towards memory management and the ability for a process to load/unload an (already referenced) assembly to/from memory as needed.

Is this just for one client, or for an application that will be distributed? If distributed, that gets complex, so I won't list all the scenarios here.

If just for one client, I would recommend one of two options (the GAC option was already posted)
- export your common library to the GAC.
- in your project, add the path to your common library to the Project properties: How to: Set the Reference Path (C# , J#) - It will still copy those dlls to your output directory on each compile, but it will always retrieve the latest version from that common directory on each compile.
Dec 19 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Foehammer | last post by:
Hello, I'm trying to load an assembly dynamically using an app domain. This is a proof-of-concept for a larger project, so please excuse the lame class names. TestLib is the dll where all the...
1
by: Robert Vasquez | last post by:
I would like my application to be able to load modules dynamically and release them once they aren't needed. For example in c++ I would load a dll containing the required function, run it, then...
9
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the...
6
by: Pete Davis | last post by:
I'm confused about what precisely the limitations are on loading plugins in separate app domains. In all my previous apps that supported plugins, I've loaded them into the same domain as the app,...
8
by: Jason | last post by:
In my ASP.NET 1.1 solutions, I created several web projects and compiled them each into an assembly. The assembly names reflected the functionality of the feature (Membership.dll, Dues.dll, etc)....
0
by: npthomson | last post by:
Hi all, This could get a bit complicated but I'll try to be as clear as possible. I've written an application that discovers plugins at runtime using reflection from a subdirectory of the...
2
by: wzhao2000 | last post by:
Back in COM time, it's possible to use #import statement in cpp to load COM object type info and use it at coding time. When the application is started, the underlying COM DLL will not be loaded...
1
by: icfai | last post by:
hi friends.... I have got a problem regarding loading of multiple assemblies, actually its required for an editor which implements the intellisenseas in vb or dotnet. for that it is required to...
1
by: =?Windows-1252?Q?Tor_B=E5dshaug?= | last post by:
BlankHi, I am having trouble loading assemblies from the database in my ASP.NET app. I have a default.aspx in my app that is served from a database via a custom virtual path provider. This works...
8
by: =?Utf-8?B?TWFyaw==?= | last post by:
We've got a wierd failure happening on just one machine. One part of our product uses a 3rd party search implementation (dtSearch). DtSearch has a native core (dten600.dll), late-bound, and a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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...

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.