Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Development Edition
 Avoid calling problematic methods
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Studio Team System
Avoid calling problematic methods

TypeName

AvoidCallingProblematicMethods

CheckId

CA2001

Category

Microsoft.Reliability

Breaking Change

Non Breaking

A member calls a potentially dangerous or problematic method.

Avoid making unnecessary and potentially dangerous method calls.

This rule fires when a member calls one of the following methods:

Reason for avoiding CoSetProxyBlanket in managed code

By the time the user code starts executing in a managed process, it is too late to reliably call CoSetProxyBlanket. The CLR takes initialization actions that may or may not prevent the users P/Invoke from succeeding.

If you do need to call CoSetProxyBlanket for a managed application, we recommend that you start the process using a native code (C++) executable, call CoSetProxyBlanket in the native code, and then start your managed code application in process. (Be sure to specify a runtime version number.)

To fix a violation of this rule, remove or replace the call to the dangerous or problematic method.

Do not suppress a warning from this rule.

Other Resources

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Never?      CommonGenius.com   |   Edit   |   Show History
Never supress a warning from this rule? Really? So, when I need to call a Win32 function like WSAEventSelect, I'm not supposed to use WaitHandle.Handle because its obsolete, and I'm not supposed to use WaitHandle.SafeWaitHandle.DangerousGetHandle because its "problematic"? What exactly am I supposed to use then? I really wish you would put more effort into making the advice on these pages realistic, instead of saying "We gave you this function, but NEVER use it!"
Tags What's this?: Add a tag
Flag as ContentBug
Re: Never?      rev23dev   |   Edit   |   Show History
Agreed. "Never" doesn't make a lot of sense. Assembly.LoadFile is problematic? Maybe you should fix that? What am I supposed to replace it with exactly?
Tags What's this?: Add a tag
Flag as ContentBug
Why?      Thuter   |   Edit   |   Show History

What exactly is wrong with Assembly.LoadFile? There are no warnings, notes or caveats on the pages describing this function that I could find.

P.

Tags What's this?: Add a tag
Flag as ContentBug
Replace with what?      Brandon H_   |   Edit   |   Show History
I, too, would like to know what exactly we're supposed to replace this call with....
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker