Skip to content
New issue

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

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

Already on GitHub? # to your account

NullReferenceException reading Excel: 0.0.6-alpha1 #12

Closed
1100594 opened this issue Mar 8, 2018 · 6 comments · Fixed by #15
Closed

NullReferenceException reading Excel: 0.0.6-alpha1 #12

1100594 opened this issue Mar 8, 2018 · 6 comments · Fixed by #15
Assignees
Labels
Milestone

Comments

@1100594
Copy link

1100594 commented Mar 8, 2018

When detecting a Excel File from a byte array throws a NullReferenceException at MimeDetective.MimeTypes.FindZipType(ReadResult& readResult) in \src\Mime-Detective\MimeTypes.cs:line 314


var fileData = File.ReadAllBytes(filePath);
var type = fileData.GetFileType(); 

test.xlsx

@1100594
Copy link
Author

1100594 commented Mar 8, 2018

@clarkis117, this issue only happens on version 0.0.6-alpha1 (pre-release), unfortunately I need some fixes of this version, so I cannot use the previous one.

Additional information: I think that your new "CreateMemoryStreamIfSourceIsNull" method is not working properly resulting in a null Source prop.

@clarkis117
Copy link
Collaborator

@1100594 Thank you for the report will look into this soon 😀

@clarkis117 clarkis117 self-assigned this Mar 8, 2018
@clarkis117 clarkis117 added the bug label Mar 8, 2018
@clarkis117 clarkis117 added this to the 0.0.6 milestone Mar 8, 2018
@1100594
Copy link
Author

1100594 commented Mar 9, 2018

Thank you @clarkis117,

I have more information for you.

The problem is that you trying to change the value of a in "readResult" parameter (aka. readonly ref parameter), please consider remove the "in" keyword or use another approach to change the value of the "source" prop.
#13

More info: https://blogs.msdn.microsoft.com/mazhou/2018/01/08/c-7-series-part-8-in-parameters/

1100594 pushed a commit to 1100594/Mime-Detective that referenced this issue Mar 9, 2018
Remove commented code
Add unit tests for byte array ext with jpg, docx, zip, xlsx and pptx
clarkis117 added a commit that referenced this issue Mar 9, 2018
Fix NullReferenceException reading Excel: 0.0.6-alpha1 #12
@clarkis117
Copy link
Collaborator

Resolved by #13

@clarkis117
Copy link
Collaborator

@1100594 The new version (alpha2) should be available on nuget now 😁

@1100594
Copy link
Author

1100594 commented Mar 9, 2018

Great! Thank you @clarkis117!

@clarkis117 clarkis117 mentioned this issue Mar 12, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants