Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 15825 [details]
Android project fails, Windows project works. (Same code)
I am attempting to search a file without loading it into memory. When I try to call Marshal.PtrToStructure(), I am getting a null reference exception.
The same call works under windows. I have included a sample solution which demonstrates the problem.
The issue no longer occurs with XA/master (to be released in Cycle 9). You can test the latest XA/master on Mac using this build: https://bosstoragemirror.blob.core.windows.net/wrench/monodroid-mavericks-master/cf/cf2beeaf61722a06763b2935ca84a81365c8e6b7/xamarin.android-7.0.99-121.pkg
I'm still seeing this issue for various structs on cycle 9 release (Alpha) for both XS and VS.
Created attachment 18644 [details]
Example that stills generates this error on Cycle 9
This shows the issue is still present in Cycle 9. It appears connected to the packing of the structs, as if i remove those it works.
I have also seen some strange bugs, where the PtrToStructure succeeds and the values of the generated structure look OK in the debugger, but when i assign them to another variable or pass them to a function they get corrupted, e.g. a float in the struct may look like 354.6475 in the debugger, but when assigned to another float it would get 4.853315E+11. That related issue I've not managed to replicate in a separate project.
Some extra info, this works ok on the simulator, fails on device (armabi-v7a)