I have some C# code that loads an assembly from a certain path like so:
assembly = System.Reflection.Assembly.LoadFrom(assemblyPath);
When I compile, Visual Studio Code Analysis throws this warning:
warning : CA2001 : Microsoft.Reliability : Remove the call to Assembly.LoadFrom ...
I'm looking for a way to resolve this warning (without suppressing it). Is there an alternative to LoadFrom that'll do that for me (I know LoadFile isn't it)?
If your code works and does what you expect, then overrule the warning. The warning is there to bring your attention to things that might have edge-cases. If you have read what it says about CA 1009, and you understand the caveats, then: move on.
For loading from a specific path, LoadFrom may be the correct call. The only ways to totally remove that would be to:
AppDomain with different probing-paths, and use MarshalByRefObject to chat between themIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With