471,089 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 software developers and data experts.

Correct way to use Assembly.Load(byte())?

I'm struggling with an odd problem and I want to validate something.

What is the right way to load an assembly from bytes?

Is this code correct? :

....
Private Function loadBytes(filename as string) as Byte()
Dim fs As New FileStream(filename, FileMode.Open)
Dim buffer(CInt(fs.Length)) As Byte
fs.Read(buffer, 0, buffer.Length)
fs.Close()
return buffer
End Function

Dim rawAssembly() as Byte = loadBytes("aWellFormatedPath&FileName")

[Assembly].Load(rawAssembly)
....

Nov 19 '05 #1
1 1676
sure. but because you are loading an assembly from memory, if that assembly
references another assembly, you should load that one first (as you have a
rather restricted search path).

-- bruce (sqlwork.com)
"mathlec" <ma*****@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I'm struggling with an odd problem and I want to validate something.

What is the right way to load an assembly from bytes?

Is this code correct? :

...
Private Function loadBytes(filename as string) as Byte()
Dim fs As New FileStream(filename, FileMode.Open)
Dim buffer(CInt(fs.Length)) As Byte
fs.Read(buffer, 0, buffer.Length)
fs.Close()
return buffer
End Function

Dim rawAssembly() as Byte = loadBytes("aWellFormatedPath&FileName")

[Assembly].Load(rawAssembly)
...

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Russell Stevens | last post: by
4 posts views Thread by Arnaud Debaene | last post: by
7 posts views Thread by Oldman | last post: by
2 posts views Thread by Tim B├╝cker | last post: by
12 posts views Thread by TC | last post: by

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.