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

DryIoc fails to object reference not set to instance of an object #134

Closed
Havunen opened this issue Jun 6, 2019 · 6 comments
Closed

DryIoc fails to object reference not set to instance of an object #134

Havunen opened this issue Jun 6, 2019 · 6 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Havunen
Copy link
Contributor

Havunen commented Jun 6, 2019

Inside DryIoc/Container.vs there is method

public static bool IsStatic(this MemberInfo member)
{
	var method = member as MethodInfo;
	if (method != null)
		return method.IsStatic;

	var field = member as FieldInfo;
	if (field != null)
		return field.IsStatic;

	var prop = member as PropertyInfo;
	if (prop == null || prop.IsExplicitlyImplemented())
		return false;

	var propAccessor =
		prop.GetGetMethodOrNull(includeNonPublic: true) ??
		prop.GetSetMethodOrNull(includeNonPublic: true);

        // Failure happens here when propAccessor is null
	return propAccessor.IsStatic;
}

Call stack:

App.Ioc.dll!DryIoc.ReflectionTools.IsStatic(System.Reflection.MemberInfo member) Line 11128	C#
App.Ioc.dll!DryIoc.FactoryMethod.Of(System.Reflection.MemberInfo ctorOrMethodOrMember, DryIoc.ServiceInfo factoryInfo) Line 4602	C#
App.Ioc.dll!DryIoc.Made.Of.AnonymousMethod__1(DryIoc.Request _) Line 4888	C#
App.Ioc.dll!DryIoc.ReflectionFactory.CreateExpressionOrDefault(DryIoc.Request request) Line 8302	C#
App.Ioc.dll!DryIoc.Factory.GetExpressionOrDefault(DryIoc.Request request) Line 7827	C#
App.Ioc.dll!DryIoc.ContainerTools.GenerateResolutionExpressions(DryIoc.IContainer container, System.Func<System.Collections.Generic.IEnumerable<DryIoc.ServiceRegistrationInfo>, System.Collections.Generic.IEnumerable<DryIoc.ServiceInfo>> getRoots, bool allowRuntimeState) Line 3111	C#
App.Ioc.dll!DryIoc.ContainerTools.Validate(DryIoc.IContainer container, System.Func<DryIoc.ServiceRegistrationInfo, bool> condition) Line 3150	C#
App.Ioc.dll!App.Ioc.ValidateIocRegistrations.Validate(DryIoc.IContainer container) Line 23	C#
App3.dll!App3.ErrorWithMasterPage.OnInit(System.EventArgs e) Line 25	Basic
[External Code]	
@dadhi dadhi self-assigned this Jun 6, 2019
@dadhi dadhi added the bug Something isn't working label Jun 6, 2019
@dadhi dadhi added this to the v4.0.5 milestone Jun 6, 2019
@dadhi
Copy link
Owner

dadhi commented Jun 6, 2019

How could it be - a property with no accessors?
Could you provide a snippet of the property code.

@Havunen
Copy link
Contributor Author

Havunen commented Jun 6, 2019

    Public Shared ReadOnly Property Current() As SessionData
        Get
            Return Current(DefaultStorageIdentifier)
        End Get
    End Property

@Havunen
Copy link
Contributor Author

Havunen commented Jun 6, 2019

I think it fails there

@dadhi
Copy link
Owner

dadhi commented Jun 6, 2019

@Havunen Thanks, I have an idea how to fix it. I need also to check if the property an indexer.
Note for me: that the property accessors and indexer are marked with SpecialNameAttribute or MethodInfo.IsSpecial

@Havunen
Copy link
Contributor Author

Havunen commented Jun 6, 2019

Good to hear! 👍

@Havunen
Copy link
Contributor Author

Havunen commented Jun 8, 2019

Its no longer crashing, I think its fixed

Leszek-Kowalski pushed a commit to Leszek-Kowalski/DryIoc that referenced this issue Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants