issus / AltiumSharp

C# .NET Standard library to read Altium library files and render them
Apache License 2.0
65 stars 37 forks source link

IndexOutOfRangeException: Read past the end of the block #19

Open hfahimi-git opened 1 year ago

hfahimi-git commented 1 year ago

Hi @issus Thanks a lot in advanced for your effort to develop such a usefull library. I'm using it to read PcbLib files and get footprint data. But I have a problem that backs to some PcbLib files. When I want to read some of them, I get "IndexOutOfRangeException: Read past the end of the block" error. I will send some of files that generate the error. Best Regards

some of the PcbLib files:

https://mega.nz/file/PtgS0DbA#ofp-oE-v18lkyyYgY03K13Z5M84yj0XUUUKnCXiKUXo https://mega.nz/file/D14XxTrD#kP_rl4B0LWp_uDNa2zcc11IBV2RnmYBlW0N6ultHfPA https://mega.nz/file/G8wmCKDC#6v5ZkirAvwHgRYj_9CIbjO-tpjI_0vbvLGy3vbEd8KQ https://mega.nz/file/XhBRQTiI#a_abZWu6RFgE0Zx_F3mmzCB_LmSFr0_Q1ksnDQ-9eZc

Stack Trace:

System.IndexOutOfRangeException: Read past the end of the block at AltiumSharp.CompoundFileReader1.ReadBlock[T](BinaryReader reader, Func2 interpreter, Func1 onEmpty, Int32 emptySize) in C:\AltiumSharp\AltiumSharp\CompoundFileReader.cs:line 371 at AltiumSharp.CompoundFileReader1.ReadBlock(BinaryReader reader, Action1 interpreter, Action onEmpty, Int32 emptySize) in C:\AltiumSharp\AltiumSharp\CompoundFileReader.cs:line 322 at AltiumSharp.PcbLibReader.ReadFootprintPad(BinaryReader reader) in C:\AltiumSharp\AltiumSharp\PcbLibReader.cs:line 282 at AltiumSharp.PcbLibReader.ReadFootprint(String sectionKey) in C:\AltiumSharp\AltiumSharp\PcbLibReader.cs:line 104 at AltiumSharp.PcbLibReader.ReadLibraryData(CFStorage library) in C:\AltiumSharp\AltiumSharp\PcbLibReader.cs:line 643 at AltiumSharp.PcbLibReader.ReadLibrary() in C:\AltiumSharp\AltiumSharp\PcbLibReader.cs:line 676 at AltiumSharp.PcbLibReader.DoRead() in C:\AltiumSharp\AltiumSharp\PcbLibReader.cs:line 26 at AltiumSharp.CompoundFileReader1.Read(String fileName) in C:\AltiumSharp\AltiumSharp\CompoundFileReader.cs:line 90 at AltiuService.Server.Controllers.FileReaderController.Get(String file) in C:\altium\altium\FileReader.cs:line 25 at lambda_method1(Closure, Object, Object[]) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

yanchiuvip commented 9 months ago

I've encountered the same issue, did you solve this error later on?

hfahimi-git commented 9 months ago

I've encountered the same issue, did you solve this error later on?

No. But when I open the file in newer versions of altiumsharp and save the file, the problem solve!

yanchiuvip commented 9 months ago

I've encountered the same issue, did you solve this error later on?

No. But when I open the file in newer versions of altiumsharp and save the file, the problem solve!

Could you let me know which specific version was used to open and then save? Thank you.

yanchiuvip commented 9 months ago

I've encountered the same issue, did you solve this error later on?

No. But when I open the file in newer versions of altiumsharp and save the file, the problem solve!

I can now access the data through your method,thank you