Loading control from assembly 
Author Message
 Loading control from assembly

I'm trying to write code to load controls at runtime.
The line 'asm = System.Reflection....' always throws a FileNotFound
exception. Do I have to specify a path or what is wrong here?

Thomas

Private Sub LoadControl(strName as string)
        Dim c As Control
        Dim controlType As String
        Dim controlName As String
        Dim asm As System.Reflection.Assembly
        controlType = strname
        controlName = "MyNewControl"
        asm = System.Reflection.Assembly.Load("System.Windows.Forms,")
        c = asm.CreateInstance(controlType)
        c.Name = controlName
        c.Location = New Point(342, 100)
        c.Visible = True
        c.Text = "I'm new'"
End Sub



Sun, 06 Feb 2005 16:23:09 GMT  
 Loading control from assembly
I believe you need to provide a path, thought not if dll is in a set of
searchable directories (including the GAC and local directory)?? [ By
memory ].

But what is puzzling is that you seem be trying to load something from
System.Windows.Forms ( , at end??) but supplying a "MyNewControl", which
would not be in the System.Windows.Forms.dll.
Also you should provide the full name (including namespace) of the control
you want.


Quote:
> I'm trying to write code to load controls at runtime.
> The line 'asm = System.Reflection....' always throws a FileNotFound
> exception. Do I have to specify a path or what is wrong here?

> Thomas

> Private Sub LoadControl(strName as string)
>         Dim c As Control
>         Dim controlType As String
>         Dim controlName As String
>         Dim asm As System.Reflection.Assembly
>         controlType = strname
>         controlName = "MyNewControl"
>         asm = System.Reflection.Assembly.Load("System.Windows.Forms,")
>         c = asm.CreateInstance(controlType)
>         c.Name = controlName
>         c.Location = New Point(342, 100)
>         c.Visible = True
>         c.Text = "I'm new'"
> End Sub

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 02/08/2002


Mon, 07 Feb 2005 03:29:35 GMT  
 Loading control from assembly
I have tried using a path but no luck so far.
"MyNewControl" is only the name of the control, the type (Textbox,
Combobox etc) is passed to the sub in strName.

On Wed, 21 Aug 2002 20:29:35 +0100, "DragonNoSpam"

Quote:

>I believe you need to provide a path, thought not if dll is in a set of
>searchable directories (including the GAC and local directory)?? [ By
>memory ].

>But what is puzzling is that you seem be trying to load something from
>System.Windows.Forms ( , at end??) but supplying a "MyNewControl", which
>would not be in the System.Windows.Forms.dll.
>Also you should provide the full name (including namespace) of the control
>you want.



>> I'm trying to write code to load controls at runtime.
>> The line 'asm = System.Reflection....' always throws a FileNotFound
>> exception. Do I have to specify a path or what is wrong here?

>> Thomas

>> Private Sub LoadControl(strName as string)
>>         Dim c As Control
>>         Dim controlType As String
>>         Dim controlName As String
>>         Dim asm As System.Reflection.Assembly
>>         controlType = strname
>>         controlName = "MyNewControl"
>>         asm = System.Reflection.Assembly.Load("System.Windows.Forms,")
>>         c = asm.CreateInstance(controlType)
>>         c.Name = controlName
>>         c.Location = New Point(342, 100)
>>         c.Visible = True
>>         c.Text = "I'm new'"
>> End Sub

>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.381 / Virus Database: 214 - Release Date: 02/08/2002



Mon, 07 Feb 2005 14:19:21 GMT  
 Loading control from assembly
I'm sure you guys can help a bit...

I have a very simple app. into which I "include" a number of images...
I want to get to these images using the following:

Dim ImageStream as Stream =
[Assemby].GetExecutingAssembly.GetManifestResourceStream("MyApp.MyImage.bmp"
)

I know NOTHING about assemblies. I find the documentation talking in circles
and need a VERY simple example. All I want to do is retrieve the images that
are
compiled into the exe.

Please give a simple example/explanation on editing the AssemblyInfo.vb file
AND/OR any code that will ultimately allow me to use my above code sample
... unless
you have another way of extracting an "included" image from the compiled
exe...

Thanks,

LM


Quote:
> I believe you need to provide a path, thought not if dll is in a set of
> searchable directories (including the GAC and local directory)?? [ By
> memory ].

> But what is puzzling is that you seem be trying to load something from
> System.Windows.Forms ( , at end??) but supplying a "MyNewControl", which
> would not be in the System.Windows.Forms.dll.
> Also you should provide the full name (including namespace) of the control
> you want.



> > I'm trying to write code to load controls at runtime.
> > The line 'asm = System.Reflection....' always throws a FileNotFound
> > exception. Do I have to specify a path or what is wrong here?

> > Thomas

> > Private Sub LoadControl(strName as string)
> >         Dim c As Control
> >         Dim controlType As String
> >         Dim controlName As String
> >         Dim asm As System.Reflection.Assembly
> >         controlType = strname
> >         controlName = "MyNewControl"
> >         asm = System.Reflection.Assembly.Load("System.Windows.Forms,")
> >         c = asm.CreateInstance(controlType)
> >         c.Name = controlName
> >         c.Location = New Point(342, 100)
> >         c.Visible = True
> >         c.Text = "I'm new'"
> > End Sub

> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.381 / Virus Database: 214 - Release Date: 02/08/2002



Wed, 09 Feb 2005 02:24:09 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Load Assembly /CreateInstance

2. Load Assembly

3. One or more of the types in the assembly unable to load

4. How do I load and run assemblies dynamically

5. Dynamically loading an assembly?

6. Trying to Dunamically Load Assembly via Reflection

7. Loading an assembly at runtime

8. Types in the assembly failed to load

9. Can not load file or assembly

10. could not load file or assembly

11. Could not load file or assembly

12. Assembly and Global Assembly Cache

 

 
Powered by phpBB® Forum Software