-
Notifications
You must be signed in to change notification settings - Fork 3
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
FieldAccessException
when trying to access publicized fields.
#12
Comments
Thanks for an exemplary ticket. Couldn't ask for more details :) The FieldAccessException should have been suppressed by Publicizer setting AllowUnsafeBlocks = true behind the scenes in your project. I see you do that explicitly too. Basically: Mono + AllowUnsafeBlocks + accessing publicized member = OK In your case, Monogame is using .NET5, and using the CoreCLR runtime, which doesn't seem to work. Unfortunately, I don't know if there is a way to do the same thing in other runtimes than Mono. This means that you probably won't be able to use Publicizer for your use case. I'll make sure to add a disclaimer about this in the Readme. |
I found another NuGet library that works for my use case: IgnoresAccessChecksToGenerator. I believe that it largely does the same thing as yours, but also emits You can see their implementation here. I'd still prefer to use yours, since it's more flexible. It should be plausible to adopt similar functionality. |
I remember seeing that project before. It's remarkable how similar some code segments are to this. Unfortunately I don't have the time to dig into this at the moment. I appreciate you preferring Publicizer, but if you need something functional soon, that project is probably better. |
Interestingly, I actually end up presently having to use both. The package that adds the attribute opens up the assembly, but it doesn't actually publicize everything - yours has better support for doing that. |
Closed by #28. |
I'm getting FieldAccessException using Publicizer towards a .dll using .NET Framework (v4.0.30319), I'm trying to use:
|
Whenever a publicized field is accessed, I am getting a
FieldAccessException
. I have not yet tested it, but I expect that all accesses will likely result in access exceptions.An example:
the code in MonoGame looks like this:
This is what my project file looks like: SpriteMaster.csproj
And this is the properties file it imports: SpriteMasterCommon.props
And all assembly attributes and such are here: Assembly.cs (I should note that removing the security-related attributes changes nothing)
The only unusual thing is that the game (this is a Stardew Valley mod) is loaded through SMAPI, and runs on .NET 5. Mod assemblies are imported dynamically by SMAPI.
The text was updated successfully, but these errors were encountered: