- Home /
How do I identify the offending method for "attempt to access a private/protected method failed"?
I know that this exception is thrown because I'm calling some method that's prohibited by the webplayer security sandbox. My problem is, the callstack in the exception only tells me in which function the offending call resides (in this case, that's MonoBehaviour.Awake), but not what the offending call actually is. This particular function does rather a lot of stuff, and there's a whole smorgasboard of calls that may or may not be the one in question.
Is there any way to get more information about which particular call is failing? Or do i just need to start binary-searching my way through the function, commenting out chunks and rebuilding the web player eleven million times? :(
No. That question does deal with the same error, but it doesn't deal with identifying the specific function call which is throwing the error.
Answer by invicticide · Dec 12, 2013 at 08:54 AM
I ended up just commenting out most of the function and slowly adding bits back in, rebuilding the web player each time, until the exception occurred. Kind of a silly workflow, but I was able to identify the offending function -- Assembly.GetName(), of all things -- and work around the issue such that the web player build works properly.
It would be really nice if that exception actually listed the method call that threw the exception, rather than just the name of the containing function. Really nice indeed. :|
Answer by Bunny83 · Dec 12, 2013 at 08:47 AM
Well that just tells me that your function just contains too much code. Simply break it up into multiple meaningful sub methods. That way you get a proper stack trace. Without seeing you code it's impossible to say what you do wrong here.
Do you use any plugins / DLLs?
No, see, the problem is that the exception is thrown by a method call, but that method call is not listed in the exception. To put it another way: I'm effectively getting a stack trace where the topmost entry of the stack has been omitted, so the only way to figure out what the topmost entry should've been is by process of eli$$anonymous$$ation.
We're not talking about thousands of lines of code, here. I'm not a total noob. :P I just didn't want to have to binary-search and rebuild the webplayer several times to figure out which specific call was the problem, when (to my $$anonymous$$d) the exception should've just listed that in the first place.
But in any case, I did find it, and will be posting the "answer" (such as it is) presently.
$$anonymous$$y point still stands. If you have small portions of code it shouldn't be that hard to figure out which line is causing the problem. Also when using reflection in the web player you should check compatibility first or at least the moment you get an error like that.
What kind of answers have you expected? That we should guess you use reflection and suggest to check it? You only provided us some symptoms but, like a doctor, we can't say what's wrong without a closer look ;)
I was kinda hoping there was a log file or a debug setting or something that I wasn't previously aware of. Clearly not.
That compatibility link is useful, though. Thanks for that.
Your answer
![](https://koobas.hobune.stream/wayback/20220613124004im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
TCPClient on webplayer crashes. 1 Answer
Webplayer sandbox security policy: When do I prefetch security policy? 1 Answer
is there a way to secure the .unity3d web player file from downloading? 1 Answer
Webplayer ActiveX 3 Answers
How do I protect my webplayer from beeing used from other sites? 2 Answers