unoplatform/uno · error · ArgumentNullException
assembly
Error message
assembly
What it means
Thrown by XamlAccessLevel.AssemblyAccessTo(Assembly) when the assembly argument is null. The method extracts assembly.GetName() to build the access level, so a null assembly has no identity to record.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Xaml.Permissions/XamlAccessLevel.cs:38
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using Uno.Xaml;
namespace Uno.Xaml.Permissions
{
[SerializableAttribute]
public class XamlAccessLevel
{
public static XamlAccessLevel AssemblyAccessTo (Assembly assembly)
{
if (assembly == null)
{
throw new ArgumentNullException ("assembly");
}
return new XamlAccessLevel (assembly.GetName ());
}
public static XamlAccessLevel AssemblyAccessTo (AssemblyName assemblyName)
{
if (assemblyName == null)
{
throw new ArgumentNullException ("assemblyName");
}
return new XamlAccessLevel (assemblyName);
}
public static XamlAccessLevel PrivateAccessTo (string assemblyQualifiedTypeName)
{
if (assemblyQualifiedTypeName == null)
{View on GitHub (pinned to 0418340488)
Solutions
- Resolve the assembly via type.Assembly or Assembly.Load and verify non-null before calling.
- Use the AssemblyName overload when you only have identity metadata.
- Guard at the boundary: if (asm == null) throw your own domain error with context.
Example fix
// before var asm = Assembly.Load(name); // may be null var lvl = XamlAccessLevel.AssemblyAccessTo(asm); // throws // after var asm = Assembly.Load(name) ?? throw new FileNotFoundException(name); var lvl = XamlAccessLevel.AssemblyAccessTo(asm);
Defensive patterns
Strategy: validation
Validate before calling
var asm = type.Assembly ?? throw new InvalidOperationException("no assembly");
var lvl = XamlAccessLevel.AssemblyAccessTo(asm); Type guard
static bool IsAssemblyKnown(Assembly a) => a != null;
Prevention
- Resolve assemblies via type.Assembly to guarantee non-null.
- Prefer the AssemblyName overload when only metadata is available.
- Null-check after Assembly.Load and surface a domain-specific error.
When it happens
Trigger: Calling AssemblyAccessTo with a null Assembly, e.g. from a type whose Assembly property resolved to null in a reflection-less/AOT environment, or from a partially-loaded module.
Common situations: Dynamic loading where Assembly.Load returned null; sandboxing code that constructs XamlAccessLevel from caller-supplied assemblies without validation; trimmed binaries where type.Assembly is null.
Related errors
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/83086a37a19790c4.
Report an issue: GitHub.