473,385 Members | 2,044 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,385 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 1776
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Russell Stevens | last post by:
Should be trivial - I want to detect the program version so that I can take steps to update things to the current version. Pretty simple - just use Application.ProductVersion So I install the...
4
by: Arnaud Debaene | last post by:
Hello group. I have an app which can load "plugins" assemblies that are described in the registry (each registry entry gives the full path to the plugin ..dll file). The plugins may be anywhere...
1
by: Abdessamad Belangour | last post by:
Hi all, An assembly is composed of a set of modules. An Assembly and a Module classes have a GetTypes() methods. Moreover, an Assembly class has a GetExportedTypes() method. 1. This means that if...
7
by: Oldman | last post by:
How do you conditionally reference an assembly based off of the build configuration? Imagine a scenario where I want to have an Sql Release Server build and an Oracle Release Build and the only...
2
by: Tim Bücker | last post by:
Hello. How can I inform the user that he is not using the correct assembly? Something like: "You have version 1.1 installed but you need version 1.2! Good Bye" Is the question too stupid -...
12
by: TC | last post by:
I'm trying to figure out what the "Friend" keyword does. I know it specifies that "elements are accessible from within the same assembly", but that doesn't help because I don't know what an...
0
by: Achim Domma | last post by:
Hi, I try to develop a localized Asp.Net 1.1 application. I have added two resource files to my app, which are called 'Labels.resx' and 'Labels.de.resx'. If I compile the app, I see a 'de'...
0
by: dodger_web | last post by:
hi, i need to load a config file from my code. this config file is supposed to be in the same directory of the assembly (a dll). i've tried many ways like this one, but when i run nunit...
0
by: savajx1 | last post by:
I am loading signed assemblies from a network share. The assemblies are NOT INSTALLED in the GAC as they are part of an enterprise distributed application implemented as a windows service that...
2
by: Beemer Biker | last post by:
I have some demo code that came with a 3rd party product. This is what it looks like (I remove html braces in case it does not print right) Register TagPrefix="pin"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...

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.