Sorry for the crossposting guys. I figured this one might be a little
tricky, so I'm calling upon the C# brains out there to help out this poor VB
developer. I know enough C# to translate any code you can offer, if
necessary.
I have a very loosely coupled WinForms app written in VB.Net, Framework v1.1
I need to take a string value which contains the unqualified name of a
class, find the assembly that contains such a class, and instantiate the
class.
Here is my code to find the correct assembly.
Private Function GetAssembly(ByV al ForeignTable As String) As
Reflection.Asse mbly
Dim Assems() As Reflection.Asse mbly
Dim intLCV As Integer
Assems = AppDomain.Curre ntDomain.GetAss emblies
For intLCV = 0 To Assems.Length - 1
If Not Assems(intLCV). GetType(Foreign Table, False, True) Is Nothing
Then
Return Assems(intLCV)
End If
Next
Return Nothing
End Function
It works fine, except my IF statement always returns Nothing because the
ForeignTable value is unqualified. If I hardcode it to
"BookWorks.Inve ntoryBO.Invento ryItems", it works just fine, but it fails on
"InventoryItems ". It appears that I need find the namespace that covers the
assembly and concatenate that to ForeignTable. I can't find any
documentation on how to do this.
Any ideas?
Thanks everyone! 1 2602
Nevermind, I found a workaround. I added the following function and reworked
the GetAssembly() function to instantiate the return value.
Private Function AssemblyHasType (ByRef Assem As Reflection.Asse mbly,
ByVal ForeignTable As String) As String
Dim x As Type
For Each x In Assem.GetTypes
If x.Name = ForeignTable Then
Return x.FullName
End If
Next
Return ""
End Function
"Jeff Molby" <JeffMolby@C_mc _st.n_t> wrote in message
news:Oe******** ******@tk2msftn gp13.phx.gbl... Sorry for the crossposting guys. I figured this one might be a little tricky, so I'm calling upon the C# brains out there to help out this poor
VB developer. I know enough C# to translate any code you can offer, if necessary.
I have a very loosely coupled WinForms app written in VB.Net, Framework
v1.1 I need to take a string value which contains the unqualified name of a class, find the assembly that contains such a class, and instantiate the class.
Here is my code to find the correct assembly.
Private Function GetAssembly(ByV al ForeignTable As String) As Reflection.Asse mbly Dim Assems() As Reflection.Asse mbly Dim intLCV As Integer
Assems = AppDomain.Curre ntDomain.GetAss emblies
For intLCV = 0 To Assems.Length - 1 If Not Assems(intLCV). GetType(Foreign Table, False, True) Is
Nothing Then Return Assems(intLCV) End If Next
Return Nothing End Function
It works fine, except my IF statement always returns Nothing because the ForeignTable value is unqualified. If I hardcode it to "BookWorks.Inve ntoryBO.Invento ryItems", it works just fine, but it fails
on "InventoryItems ". It appears that I need find the namespace that covers
the assembly and concatenate that to ForeignTable. I can't find any documentation on how to do this.
Any ideas?
Thanks everyone!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: BH |
last post by:
Is there a performance difference between importing (keyword "using") a
namespace for an entire class file and using the classes from that namespace
with the fully qualified name? Particularly when only one class from the
namespace is needed once? For example:
Option 1:
.....
using System.Text;
......
StringBuilder sb = new StringBuilder();
|
by: Jeff Molby |
last post by:
Sorry for the crossposting guys. I figured this one might be a little
tricky, so I'm calling upon the C# brains out there to help out this poor VB
developer. I know enough C# to translate any code you can offer, if
necessary.
I have a very loosely coupled WinForms app written in VB.Net, Framework v1.1
I need to take a string value which contains the unqualified name of a
class, find the assembly that contains such a class, and...
|
by: Simon King |
last post by:
I have created a service which uses the FileSystemWatcher to monitor folders
for file changes. I have a app.config file which specifies which folders to
watch and what to do when a change occurs.
What I would like to do is specify a class and a method which can be invoked
when that file change occurs. I can specify the name of the class/method in
the config file but the app will see it as a string.
Therefore my question is, can I...
|
by: Aashish Patil |
last post by:
Hello,
Is it possible to obtain the fully qualified name of a
class in c#. What I am looking for is something analogous
to Box.class.getName() that exists in Java.
Its possible to get this by calling GetType() on an
instance but I need to do this in a static method of the
same object whose fully qualified name is needed. Thus,
there is no instance available on which the GetType()
|
by: fc2 |
last post by:
Hi
I have a problem with fully qualified names. According to the C#
language specification:
"Every namespace and type has a fully qualified name, which uniquely
identifies the namespace or type amongst all others."
However, I have problems compiling the following:
| |
by: Mark Kamoski |
last post by:
Hi Everyone--
Please help.
How can one get the name of the current project and the current class?
This is the situation.
Suppose there is a project called "P1".
|
by: Brian |
last post by:
I have many similar classes in a project, one for each type of report
my app can create. I want to instantiate them based on a value passed
in by a scheduler module.
Right now I have
Sub RunReports(sReport)
Select Case sReport
Case "CRByDistrict"
oReport = New CRByDistrict
|
by: Rene Mansveld |
last post by:
Hi,
how can I create an instance (object) of a class (form) if I only know the
classname (VB.NET 1.0)?
I need to do this in a complex app where jobs consist of parts. Each part's
data is saved in a separate database table. For the parts, the form's class
name is saved in a data table, so that I know which form to use. As this is
a string, I need to be able to create the form by it's name (like
CreateObject() does for COM objects).
|
by: Erland |
last post by:
Hi all,
As per my understanding in order to load an assembly using
Assembly.Load() you have to provide fully qualified name of the
assembly you are trying to load e.g.
Assembly
asmb=Assembly.Load("System.Windows.Forms,Version=1.0.5000.0,Culture=neutral,PublicKeyToken=b77a5c561934e089");
In this case i will have to provide the whole big string in
|
by: Jack |
last post by:
Hi,
I have a single class XXX residing in a namspace with the same name:
XXX.
I can access my class in my code just fine with:
XXX.XXX.MySub() '(Note: shared sub!)
But I don't want to clutter the code with the namespace every time I
access my class.
|
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...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
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...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |