Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Assembly.LoadFile and Code Analysis warning CA2001
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jesse Houwing  
View profile  
 More options Oct 31, 10:32 pm
Newsgroups: microsoft.public.dotnet.framework
From: Jesse Houwing <jesse.houw...@newsgroup.nospam>
Date: Sat, 31 Oct 2009 12:32:10 +0100
Local: Sat, Oct 31 2009 10:32 pm
Subject: Assembly.LoadFile and Code Analysis warning CA2001
Hey all,

I've implemented a simple plug-in based file parser for a customer and
I'm running into CA2001, which I'd like to solve.

The problem is that I cannot find any information on how to solve this
error, other than removing my call to Assembly.LoadFile. There are some
alternatives, but they are either also in the blacklist for CA2001, or
they're deprecated.

What I'm trying to accomplish is to load my file format description
(classes decorated with custom attributes) from a specific directory
(e.g. /bin/formats).

I'm using the following code:

foreach (string dll in
Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(),
"Formats"), "*.dll"))
             {
                 Assembly ass = Assembly.LoadFile(dll);
                 Type[] types = ass.GetTypes();

}

Any other approaches I could use for this? Can I tell the framework to
load all my assemblies by adding a config directive? Or is there a Load*
method in Assembly that I might have missed?

--
Jesse Houwing
jesse.houwing at sogeti.nl


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeroen Mostert  
View profile  
 More options Oct 31, 11:36 pm
Newsgroups: microsoft.public.dotnet.framework
From: Jeroen Mostert <jmost...@xs4all.nl>
Date: Sat, 31 Oct 2009 13:36:22 +0100
Local: Sat, Oct 31 2009 11:36 pm
Subject: Re: Assembly.LoadFile and Code Analysis warning CA2001
Jesse Houwing wrote:
> I've implemented a simple plug-in based file parser for a customer and
> I'm running into CA2001, which I'd like to solve.

It would have behooved you to spell out what CA2001 was. Would've saved me a
trip to Google.

For the rest of us, it's "Avoid calling problematic methods", blacklisting
several methods with problems, including Assembly.LoadFile().

> The problem is that I cannot find any information on how to solve this
> error, other than removing my call to Assembly.LoadFile.

Basically, it's because Microsoft wants you to use the GAC, or else muck
around with a new AppDomain. See
http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx and
http://blogs.msdn.com/suzcook/archive/2003/06/13/57180.aspx.

Personally, I'd just suppress the CA2001 warning. This is one area where
Microsoft's ideas of the perfect world just don't mesh with what people
actually want.

--
J.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google