Skip to content

Commit 97bfab3

Browse files
authored
Add note about timing of type loader exceptions (dotnet#7468)
1 parent 0f9193b commit 97bfab3

File tree

6 files changed

+10
-13
lines changed

6 files changed

+10
-13
lines changed

xml/System.IO/DirectoryNotFoundException.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@
5555
## Remarks
5656
`DirectoryNotFoundException` uses the HRESULT COR_E_DIRECTORYNOTFOUND which has the value 0x80070003. Note that `DirectoryNotFoundException` is also thrown when COM interop programs see the HRESULT STG_E_PATHNOTFOUND, which has the value 0x80030003.
5757
58-
If your code does not have <xref:System.Security.Permissions.FileIOPermissionAttribute.PathDiscovery%2A> permission, the error message for this exception may only contain file or directory names instead of fully qualified paths.
59-
60-
61-
6258
## Examples
6359
The following example shows how to force and recover from a <xref:System.IO.DirectoryNotFoundException>.
6460

xml/System.IO/FileLoadException.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
<Docs>
5151
<summary>The exception that is thrown when a managed assembly is found but cannot be loaded.</summary>
5252
<remarks>
53-
<format type="text/markdown"><![CDATA[
53+
<format type="text/markdown">
54+
<![CDATA[
5455
5556
## Remarks
5657
Represents the error that occurs when a <xref:System.Reflection.Assembly> file is found but cannot be loaded.
@@ -59,15 +60,15 @@
5960
6061
`FileLoadException` has the default HRESULT of COR_E_FILELOAD, which has the value 0x80131621, but this is not the only possible HRESULT.
6162
62-
If your code does not have <xref:System.Security.Permissions.FileIOPermissionAttribute.PathDiscovery%2A> permission, the error message for this exception may only contain file or directory names instead of fully qualified paths.
63+
The exact timing of when static assembly references are loaded is unspecified. This exception may be thrown before the method that statically references the assembly that failed to load starts executing.
6364
6465
> [!NOTE]
6566
> This exception is not included in the [.NET for Windows Store apps](https://go.microsoft.com/fwlink/?LinkID=247912) or the [Portable Class Library](/dotnet/standard/cross-platform/cross-platform-development-with-the-portable-class-library), but it is thrown by some members that are. To catch the exception in that case, write a `catch` statement for <xref:System.IO.IOException> instead.
6667
6768
**Associated Tips**
6869
69-
**Make sure that the file is a valid .NET Framework assembly.**
70-
This exception is thrown if the file is not a valid .NET Framework assembly. For more information, see <xref:System.Reflection.Assembly>.
70+
**Make sure that the file is a valid .NET assembly.**
71+
This exception is thrown if the file is not a valid .NET assembly. For more information, see <xref:System.Reflection.Assembly>.
7172
7273
**Check to make sure an assembly or module was not loaded twice with two different evidences.**
7374
Evidence is the set of information that constitutes input to security policy decisions, such as what permissions can be granted to code. For more information, see <xref:System.EnterpriseServices.Internal.Publish.GacRemove%2A> and <xref:System.Reflection.Assembly.Evidence%2A>

xml/System.IO/FileNotFoundException.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666
## Remarks
6767
`FileNotFoundException` uses the HRESULT COR_E_FILENOTFOUND which has the value 0x80070002.
6868
69-
If your code does not have <xref:System.Security.Permissions.FileIOPermissionAttribute.PathDiscovery%2A> permission, the error message for this exception may only contain file or directory names instead of fully qualified paths.
70-
7169
]]></format>
7270
</remarks>
7371
<altmember cref="T:System.Exception" />

xml/System.IO/PathTooLongException.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
<format type="text/markdown"><![CDATA[
5454
5555
## Remarks
56-
If your code does not have <xref:System.Security.Permissions.FileIOPermissionAttribute.PathDiscovery%2A?displayProperty=nameWithType> permission, the error message for this exception may contain only file or directory names instead of full paths.
57-
5856
In apps that run under versions of the .NET Framework prior to the .NET Framework 4.6.2, full paths must not exceed 260 characters to maintain compatibility with Windows operating systems. Any path in excess of 260 characters automatically throws a <xref:System.IO.PathTooLongException>. For more information about this restriction, see the entry [Long Paths in .NET](https://go.microsoft.com/fwlink/?LinkID=163666) in the BCL Team blog.
5957
6058
> [!NOTE]

xml/System/MissingMethodException.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
<xref:System.MissingMethodException> uses the HRESULT COR_E_MISSINGMETHOD, that has the value 0x80131513.
6565
6666
For a list of initial property values for an instance of <xref:System.MissingMethodException>, see the <xref:System.MissingMethodException.%23ctor%2A> constructors.
67-
67+
68+
The exact timing of when statically referenced methods are loaded is unspecified. This exception may be thrown before the method that references the missing method starts executing.
69+
6870
> [!NOTE]
6971
> This exception is not included in [.NET for Windows Store apps](https://go.microsoft.com/fwlink/?LinkID=247912) or the [Portable Class Library](/dotnet/standard/cross-platform/cross-platform-development-with-the-portable-class-library), but it is thrown by some members that are. To catch the exception in that case, write a `catch` statement for <xref:System.MissingMemberException> instead.
7072

xml/System/TypeLoadException.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
7272
For a list of initial property values for an instance of <xref:System.TypeLoadException>, see the <xref:System.TypeLoadException.%23ctor%2A> constructors.
7373
74+
The exact timing of when statically referenced types are loaded is unspecified. This exception may be thrown before the method that references the missing type starts executing.
75+
7476
]]></format>
7577
</remarks>
7678
<altmember cref="T:System.Exception" />

0 commit comments

Comments
 (0)