❔ How can i acces to a Method that is internal?
Hello i use a Framework called Easel, and i try to acces to the
Time.Initialize()
Method to create a Timer on the Server side too.
If anyone has a idea todo it let me pls know!37 Replies
Is there a way to get acces?
Internal means only that assembly can access it.
So only the framework 'Easel' can access it.
And you are not recommended to use it any other way.
You can probably just use reflection to call it
Not sure if it works for internal methods
This probably works:
Using reflection, gets method
Initialize
from type Time
, which must be static and non public (so internal works), and then invokes it without an instance reference, nor any arguments.
Just keep in mind private or internal probably means whatever library you use probably does not intent for you to use it
Might even break in the futurethe method get not called
❓
It's a horrible thing to do anyway
i tried it with a brake point
it get not called
Do not call unavailable members with reflection, things will break because they don't expect it
Well idk
Like I said, if it's accessor is private, internal, file, whatever, it probably is not supposed to be called anyway.
they just did it because the framework thought not about the server
Isn't there some source code somewhere?
Perhaps you can copy the method, make your own, and do whatever it's supposed to yourself
Assuming whatever it's supposed to do is not call more non public stuff
but then i need everytime when it updates
make a own update too...
Also I have no idea what you mean with this. If you get an error, share the error.
i got no error
its just like the method get not called
Well, then considering it's active, perhaps suggest the devs to make the method publicly available.
Then it might not be found. You should check that.
the dev want to add in generel a support for servers
but
the prority of other things are higher
:/
Then perhaps you can make a pull request yourself and turn it public
I assume a simple change will be looked at quickly if it's so important
If not, it would probably have a good reason
nah its not just this
everything works like that
by him
SceneManager
UpdateManager...
Noo idea what you mean
nvm
but do you know why it does not call the method with the reflection?
No, reflection can be unreliable
Might be the compiler inlining the method or simply something happening the the method which causes it to not exist
Might be the call itself not being done properly
Maybe the method is actually public, or maybe it's not static and you simply need to change the bindingflags
If you have no idea how it works or how to fix it, maybe don't use it
ok i got it work
thxx
How did you fix it?
no you one did work but C# disable the debugger on this methods
so
it get called
but the debugger does not print things or something out from this method
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Things are usually internal or private for a reason. Using reflection to circumvent that should mean that you fully understand that you're going against the intention of the person who implemented the original members, like the guys above said, things break when touched incorrectly. If you do choose to go further into reflection, you can cache method calls by creating a delegate (it cuts down on the time needed for executing that method / property info at the small expense of a heap allocation)
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
It's internal for a reason, the library contributors / owner does not want people to use said thing.
Don't do it any other way but the official way.
Unexpected things can happen.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Your framework you use seems to be calling that method here: https://github.com/piegfx/Easel/blob/db37e800faa9eeecf9e93eb51c8d432d56f7d590/Easel/EaselGame.cs#L173 which is public
if field is null in that, wouldnt the NRE trigger at the if statement?
there's the null check further down inside of the if check inside
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
lmao
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
i not wanna start the graphic things
but what ever
the owner of it made it for me
so its now splited 🙂
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.