473,378 Members | 1,355 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,378 software developers and data experts.

IsAssembly( )

Is there a capability in the Assembly class to verify that the file being
process actually contains Assemblies prior to processing them?

Currently I do an Assembly.LoadFrom( ) followed by a GetTypes( ) and trap
the exception that is thrown. This works but the performance is of course
suboptimal.

What I am holing for is something like IsAssembly( ) can be called to
validate the file prior to processing.

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Nov 15 '05 #1
2 1591
Thom,

An assembly can not contain another assembly. =)

What you could try and do is get the modules in the assembly (through a
call to GetModules), iterate through those, and call the IsResource method
on the module. If the module is not a resource, then I would think it
contains types of some kind. Hopefully, this will not throw an exception.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Thom Little" <th**@tlanet.net> wrote in message
news:uy**************@TK2MSFTNGP10.phx.gbl...
Is there a capability in the Assembly class to verify that the file being
process actually contains Assemblies prior to processing them?

Currently I do an Assembly.LoadFrom( ) followed by a GetTypes( ) and trap
the exception that is thrown. This works but the performance is of course
suboptimal.

What I am holing for is something like IsAssembly( ) can be called to
validate the file prior to processing.

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Nov 15 '05 #2
I think I was mumbling ... what I am doing is ...

private void btnLoadAssembly_Click( object sender, System.EventArgs e )
{
if ( dlgOpen.ShowDialog( ) == DialogResult.OK )
{
txtAssemblyName.Text = dlgOpen.FileName ;
Assembly oAssembly = Assembly.LoadFrom( txtAssemblyName.Text );
Type[] types = oAssembly.GetTypes( );
lbTypes.Items.Clear( );
foreach( Type oType in types )
lbTypes.Items.Add( oType.FullName );
}
}

If the module does not contain assemblies an exception is thrown on the
LoadFrom( ) that I handle. I would like to trap this condition before the
LoadFrom( ) is issued instead of waiting until the exception is thrown.

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--
Nov 15 '05 #3

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

Similar topics

2
by: Abdessamad Belangour | last post by:
Hi, I want to get the visiblity kind of a FieldInfo object. The "IsPublic" ans "IsPrivate" properties give the required information for public and private visibilities. My questions are: 1. What...
1
by: Charles Herring | last post by:
In my asp.net application I upload a video file and then need to get the duration and other properties. I get "Attempted to access an unloaded AppDomain" when I instanciate the Video object. I am...
10
by: Ger | last post by:
I am having problems using VB.Net's Management base object on a machine hosting Windows Server 2003. I am trying to set file permissions from a Windows Service. These files may be loacted on a...
7
by: brett.estabrook | last post by:
I have written a multi-threaded c# windows service in .net 1.1 (Visual Studio .net 2003). The service has several threads that poll a Sql 6.5 database on another machine. Each thread will execute a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.