Muokkaa

Jaa


IL3001: Avoid accessing Assembly file path when publishing as a single file

Value
Rule ID IL3001
Category SingleFile
Fix is breaking or nonbreaking Nonbreaking

Cause

When you publish an app as a single file (for example, by setting the PublishSingleFile property to true in a project), calling the Assembly.GetFile(s) methods for assemblies embedded inside the single-file bundle always throws an exception, as these methods aren't single-file compatible.

How to fix violations

To embed files in assemblies in single-file bundles, consider using embedded resources and the Assembly.GetManifestResourceStream method.

When to suppress warnings

It's appropriate to silence this warning if the assembly being accessed is definitely not in the single-file bundle. The assembly might not be in the bundle if the assembly is loaded dynamically from a file path.