Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException in ReadExistingAssembly #49

Closed
GeertvanHorrik opened this issue Jan 22, 2014 · 4 comments
Closed

NullReferenceException in ReadExistingAssembly #49

GeertvanHorrik opened this issue Jan 22, 2014 · 4 comments

Comments

@GeertvanHorrik
Copy link
Member

In this code:

public static Assembly ReadExistingAssembly(AssemblyName name)
{
    var currentDomain = AppDomain.CurrentDomain;
    var assemblies = currentDomain.GetAssemblies();
    foreach (var assembly in assemblies)
    {
        var currentName = assembly.GetName();
        if (currentName.Name == name.Name && currentName.CultureInfo.Name == name.CultureInfo.Name)
        {
            return assembly;
        }
    }
    return null;
}

It is possible that name.CultureInfo == null. A fix is pretty easy:

if (string.Equals(currentName.Name, name.Name)
{
    if (name.CultureInfo == null || string.Equals(currentName.CultureInfo.Name, name.CultureInfo.Name))
    {
        return assembly;
    }
}
@GeertvanHorrik
Copy link
Member Author

And since name.CultureInfo can be null, it might be wise to also check currentName.CultureInfo for null as well.

@remcoros
Copy link

I ran into when trying to include the 'EntityFramework.SqlServerCompact' assembly.

Temporary fix was to exclude the assembly. But would be nice if the null check can be added.

@distantcam
Copy link
Member

Fixed in 1.0.

@remcoros
Copy link

remcoros commented Feb 1, 2014

confirmed it's working now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants