473,854 Members | 1,433 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Assemblies and loading type using reflection

If I use Assembly.LoadFi le("name.dll") and then I want to create instace of
class inside the assembly using reflection Type.GetType("c lass.name")
doesn't work unless I do

Assembly asm = Assembly.LoadFi le("name.dll") ;
Type t = asm.GetType("cl ass.name");

Is there a way to expose the new Assembly globally dynamically so I can use
the standard Type.GetType()? I don't want to keep track of which assembly I
loaded and where each class is store. In my code, I only know at runtime how
many new assemblies I have to load
Tks.
Nov 15 '05 #1
1 1720
"Sacha" <sa***@severus. org> wrote in message
news:#V******** *****@tk2msftng p13.phx.gbl...
If I use Assembly.LoadFi le("name.dll") and then I want to create instace of class inside the assembly using reflection Type.GetType("c lass.name")
doesn't work unless I do

Assembly asm = Assembly.LoadFi le("name.dll") ;
Type t = asm.GetType("cl ass.name");

Is there a way to expose the new Assembly globally dynamically so I can use the standard Type.GetType()? I don't want to keep track of which assembly I loaded and where each class is store. In my code, I only know at runtime how many new assemblies I have to load


Type.GetType allows you to specify the assembly name, which you can
incorporate at runtime. See the documentation for Type.GetType(st ring) on
MSDN. Without specifying the assembly name, Type.GetType only looks in the
calling assembly and in mscorlib.
Nov 15 '05 #2

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

Similar topics

4
14495
by: Jimi | last post by:
Given a C# project file path, can I use reflection to get all the assemblies referenced by the project? e.g., I know the path of a C# project, say, "c:\SomeProject.csproj", and I want to load its referenced assemblies to construct a list of their members for display. Note that "c:\SomeProject.csproj" is not the current project, it's just a project we're displaying information about in the utility I'm trying to construct.
9
4499
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 "Let Users Add Functionality to Your .NET Applications with Macros and Plug-Ins" article at MSDN for the dynamic loading of DLLs http://msdn.microsoft.com/msdnmag/issues/03/10/Plug-Ins/default.aspx
6
1229
by: JonS. | last post by:
Hi, I'm trying to create a Windows Forms portal application and need some help. What I currently have is a main application (.exe) containing an MDI form. The idea is that this main application loads forms from packages (i.e. DLLs containing one or more forms). The trick is that I'd like the form packages and forms loaded to be dynamic. Therefore the main application should be able to "discover" all the form packages, then allow those...
1
1864
by: John F | last post by:
Hello all, When dynamically loading classes through reflection using Assembly.LoadFrom I have the following questions: 1) Once you load an assembly it doesn't appear you can unload it. If you try to load an assembly multiple times does this cause any type of memory issues? 2) If you load an assembly and later you try to load a newer version of the
2
2648
by: jnick | last post by:
I have the predicament of having to load several assemblies on the fly and when I do so, I get an exception stating that one of the referenced assemblies cannot be found. Is there any way to recurse into an assembly to discover the referenced assemblies without actually loading the root assembly where I start the load? For example: assembly 1 contains references to assembly 1_1 and assembly 1_2 assembly 1_1 contains reference to...
0
2318
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 application, eg: In the directory the application is installed to: \application.exe \plugins\plugin1.dll
19
1599
by: Larry Smith | last post by:
Hi there, When I run the following on my app's primary thread: System.Type.GetType("System.Windows.Forms.Form") It works as expected. If I then launch a thread via the "BackgroundWorker" class immediately after the above call, and invoke the above again as soon as the thread starts, it now returns null instead. Can anyone explain this. Thanks.
2
1855
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 until that part of code is called. Is there a similar thing in .Net (C#) application ? When I create C# application, I need to add reference to another assembly if I want to use its classes (I don't want to use reflection here). But this will...
1
2246
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 fine, until this default.aspx uses code in a dependent assembly (say CustomAssembly). Then ASP.NET cannot find the class "CustomAssembly.MyClass" and files to compile the default.aspx. I've tried to do a AppDomain.CurrentDomain.Load(byte...
0
9901
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
9751
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11024
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10679
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
10756
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
7081
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
5941
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4560
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 we have to send another system
3
3186
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.