Skip to content

C# Generic constraint in separate library causes BadImageFormatException #1765

Open
@ApocDev

Description

@ApocDev

This one is pretty straightforward, it seems as though placing generic type constraints on methods, where the type exists in a different assembly, causes the original to throw a BadImageFormatException on load.

For example:

OtherLibrary.dll

public interface ISomeType
{
    int Bar { get; set; }
}

ClientResource.net.dll

class Foo
{
    public void Method<T>() where T : OtherLibrary.ISomeType {}
}

The above will throw the BadImageFormatException. However, a simple change to the following allows the assembly to load properly:

ClientResource.net.dll

class Foo
{
    public void Method<T>() where T : class {}
}

Obviously, using the class constraint is "ok" to work around the issue temporarily, but I can only assume whatever assembly resolving is being done at load, also contains other such cross-assembly type issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ScRT: C#Issues/PRs related to either C# scripting runtimes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions