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

Failing to load a reference causes 'Invalid pointer', this seems to be alternative behavior #345

Open
patroza opened this issue Nov 7, 2015 · 1 comment

Comments

@patroza
Copy link

patroza commented Nov 7, 2015

It breaks e.g Type.GetType(typeString, throwOnError: false); where callers rely on FileNotFoundException to cause GetType to return null, however because of the Invalid Pointer, the call suddenly ends in exception instead of null.

Usage example in https://github.com/akavache/Akavache/blob/master/Akavache/Portable/DependencyResolverMixin.cs#L42

Throws FileLoadException, probably expected would be: FileNotFoundException
(I found this info: dotnet/coreclr#516 to be slightly related in coreclr)

  InnerException:
   { [System.TypeInitializationException: The type initializer for 'Akavache.BlobCache' threw an exception.]
     TypeName: 'Akavache.BlobCache',
     Message: 'The type initializer for \'Akavache.BlobCache\' threw an exception.',
     Data: {},
     InnerException:
      { [System.IO.FileLoadException: Could not load file or assembly 'Akavache.Mac, Version=4.1.2.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))]
        Message: 'Could not load file or assembly \'Akavache.Mac, Version=4.1.2.0, Culture=neutral, PublicKeyToken=null\' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))',
        FileName: 'Akavache.Mac, Version=4.1.2.0, Culture=neutral, PublicKeyToken=null',
        FusionLog: '',
        Data: {},
        InnerException: [Object],
        TargetSite: {},
        StackTrace: '   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)\r\n   at System.RuntimeTypeHandle.GetTypeByName(String na
me, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)\r\n   at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)\r\n   at System.T
ype.GetType(String typeName, Boolean throwOnError)\r\n   at Akavache.DependencyResolverMixin.InitializeAkavache(IMutableDependencyResolver This)\r\n   at Splat.Locator.RegisterResolverCallbackChanged(Action callback) in y:\\code\\paulcbetts\\splat\\Splat\\ServiceLocation.cs:line 89\r\n   at Akavache.BlobCache..cctor
()',
        HelpLink: null,
        Source: 'mscorlib',
        HResult: -2147467261,
        message: 'Could not load file or assembly \'Akavache.Mac, Version=4.1.2.0, Culture=neutral, PublicKeyToken=null\' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))',
        name: 'System.IO.FileLoadException' },
     TargetSite: {},
     StackTrace: '   at Akavache.BlobCache.EnsureInitialized()\r\n   at Akavache.Sqlite3.SQLitePersistentBlobCache..ctor(String databaseFile, IScheduler scheduler)\r\n   at SN.withSIX.Core.Infra.Cache.LocalCache..ctor(String databaseFile, IScheduler scheduler) in E:\\Projects\\SN\\withSIX.Desktop\\src\\SN.withSIX.Co
re.Infra\\Cache\\LocalCache.cs:line 12\r\n   at SN.withSIX.Mini.Presentation.Wpf.AppBootstrapper.<RegisterLocalCaches>b__34_0() in E:\\Projects\\SN\\withSIX.Desktop\\src\\SN.withSIX.Mini.Presentation.Wpf\\AppBootstrapper.cs:line 337\r\n   at lambda_method(Closure )\r\n   at SimpleInjector.Lifestyles.SingletonLifesty
le.SingletonLifestyleRegistrationBase`1.CreateInstanceWithNullCheck()\r\n   at System.Lazy`1.CreateValue()\r\n   at System.Lazy`1.LazyInitValue()\r\n   at SimpleInjector.Lifestyles.SingletonLifestyle.SingletonLifestyleRegistrationBase`1.BuildExpression()\r\n   at SimpleInjector.Registration.BuildExpression(InstanceP
roducer producer)\r\n   at SimpleInjector.InstanceProducer.BuildExpressionInternal()\r\n   at System.Lazy`1.CreateValue()\r\n   at System.Lazy`1.LazyInitValue()\r\n   at SimpleInjector.InstanceProducer.BuildExpression()',
     HelpLink: null,
     Source: 'Akavache',
     HResult: -2146233036,
     message: 'The type initializer for \'Akavache.BlobCache\' threw an exception.',
     name: 'System.TypeInitializationException' },

On a related note, assembly redirection seems to fail also with invalid pointer:

  InnerException:
   { [System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))]
     Message: 'Could not load file or assembly \'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))',
     FileName: 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed',
     FusionLog: '',
     Data: {},
     InnerException:
      { [System.NullReferenceException: Object reference not set to an instance of an object.]
        Message: 'Object reference not set to an instance of an object.',
        Data: {},
        InnerException: null,
        TargetSite: {},
        StackTrace: '   at EdgeCompiler.CurrentDomain_AssemblyResolve(Object sender, ResolveEventArgs args)\r\n   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)',
        HelpLink: null,
        Source: 'edge-cs',
        HResult: -2147467261,
        message: 'Object reference not set to an instance of an object.',
        name: 'System.NullReferenceException' },
     TargetSite: {},
     StackTrace: '   at Microsoft.AspNet.SignalR.DefaultDependencyResolver.RegisterDefaultServices()\r\n   at Microsoft.AspNet.SignalR.DefaultDependencyResolver..ctor()\r\n   at Microsoft.AspNet.SignalR.GlobalHost.<.cctor>b__0()\r\n   at System.Lazy`1.CreateValue()\r\n   at System.Lazy`1.LazyInitValue()\r\n   at Mic
rosoft.AspNet.SignalR.GlobalHost.get_DependencyResolver()\r\n   at SN.withSIX.Mini.Infra.Api.Startup.Configuration(IAppBuilder app) in E:\\Projects\\SN\\withSIX.Desktop\\src\\SN.withSIX.Mini.Infra.Api\\Startup.cs:line 36',
     HelpLink: null,
     Source: 'Microsoft.AspNet.SignalR.Core',
     HResult: -2147467261,
     message: 'Could not load file or assembly \'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\' or one of its dependencies. Invalid pointer (Exception from HRESULT: 0x80004003 (E_POINTER))',
     name: 'System.IO.FileLoadException' },
  TargetSite: {},
@patroza
Copy link
Author

patroza commented Nov 7, 2015

Hmm, this seems to be the fix?
tjanczuk/edge-cs#7

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

1 participant