Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by OriginalPoster · Feb 23, 2011 at 10:33 AM · webplayeraccessmethodrestrictionsemulation

Unity 3.1 Webplayer: access method failed

Hi all,

I'm running a C# script in Unity 3.1.0f4, connecting to a remote server. The web-player build run from a browser generates the following error message -

MethodAccessException: Attempt to access a private/protected method failed.

at System.Security.SecurityManager.ThrowException (System.Exception ex) [0x00000] in <filename unknown>:0 at [Some constructor in my code]

The code looks like this:

Socket.Connect(hostname, port); //works
NetworkStream netStream = Socket.GetStream();//works
BufferedStream bStream = new BufferedStream(netStream);//seems to fail

When I, however, start the same project in the Editor, (with platform switched to web player, of course) it works without problems. It only occurs using the browser-plugin.

Even if I replace the NetworkStream with a MemoryStream, it fails when constructing the BufferedStream:

Socket.Connect(hostname, port); //works
NetworkStream netStream = Socket.GetStream();//works
MemoryStream test = new MemoryStream();//works as well
BufferedStream bStream = new BufferedStream(test);// also fails

As far as I could read from the documentation, both classes MemoryStream and BufferedStream are fully supported by the web player. NetworkStream is accessible as well, just the close(timeout) method is not - which I'm not using anyway.

Thanks for all hints :)

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Martin.n.stauber · May 29, 2012 at 11:09 PM 0
Share

I'm encountering a similar error

 $$anonymous$$ethodAccessException: Attempt to access a private/protected method failed.
   at System.Security.Security$$anonymous$$anager.ThrowException (System.Exception ex) [0x00000] in <filename unknown>:0 
 
   at System.Xml.Xsl.XslTransform..cctor () [0x00000] in <filename unknown>:0 
 Rethrow as TypeInitializationException: An exception was thrown by the type initializer for System.Xml.Xsl.XslTransform
   at $$anonymous$$ono.Xml.Xsl.XslTemplate.Evaluate ($$anonymous$$ono.Xml.Xsl.XslTransformProcessor p, System.Collections.Hashtable withParams) [0x00000] in <filename unknown>:0 
 
   at $$anonymous$$ono.Xml.Xsl.XslTransformProcessor.ApplyTemplates (System.Xml.XPath.XPathNodeIterator nodes, System.Xml.XmlQualifiedName mode, System.Collections.ArrayList withParams) [0x00000] in <filename unknown>:0 
 
   at $$anonymous$$ono.Xml.Xsl.XslTransformProcessor.Process (System.Xml.XPath.XPathNavigator root, $$anonymous$$ono.Xml.Xsl.Outputter outputtter, System.Xml.Xsl.XsltArgumentList args, System.Xml.XmlResolver resolver) [0x00000] in <filename unknown>:0 
 
   at System.Xml.Xsl.XslCompiledTransform.Transform (System.Xml.XPath.XPathNavigator input, System.Xml.Xsl.XsltArgumentList args, System.IO.TextWriter output) [0x00000] in <filename unknown>:0 
 
   at System.Xml.Xsl.XslCompiledTransform.Transform (IXPathNavigable input, System.Xml.Xsl.XsltArgumentList args, System.IO.TextWriter output) [0x00000] in <filename unknown>:0 
 
   at System.Xml.Xsl.XslCompiledTransform.Transform (System.Xml.XmlReader reader, System.Xml.Xsl.XsltArgumentList args, System.IO.TextWriter output) [0x00000] in <filename unknown>:0


It seems to be the same issue with the constructor not being accessible...

Notice the interesting switch in namespace from System.Xml.Xsl to $$anonymous$$ono.Xml.Xsl, then re-switch to System.Xml.Xsl.

It's worth noting that XslTransform is a deprecated class, and is not accessible through the the mono intellisense either. HOWEVER, this error doesn't occur when ran through the editor, just the webplayer...

avatar image Bunny83 · May 29, 2012 at 11:10 PM 0
Share

@martinnstauber: this is not an answer, so use comments. Answers should answer the question.

avatar image Sephiroth74 · Dec 09, 2012 at 12:28 PM 0
Share

Did you find a solution for this problem ?

avatar image angelcaf · Jul 13, 2013 at 01:59 PM 0
Share

Had the same issue, see here: http://forum.unity3d.com/threads/190219-Unity3D-WebPlayer-$$anonymous$$ethodAccessException-for-XslTransform

@martinnstauber and @Sephiroth74 any solution?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by coeing · Jun 06, 2011 at 09:48 AM

Hi,

Don't know if you still need help. Today we also had a MethodAccessException in our logs. It only occured on a Windows Vista PC, on all PCs with Windows 7 it just worked fine.

In the end it was a Hashtable deserialization that was made in the web player. It turns out that the Hashtable deserialization constructor

Hashtable(System.Runtime.Serialization.SerializationInfo > info, > System.Runtime.Serialization.StreamingContext > context)

is protected, so it can't be called during deserialization.

Our workaround was to just derive our own class from the Hashtable:

 [Serializable]
  public class SerializableHashtable : Hashtable
  {
      public SerializableHashtable()
      {
      }
      public SerializableHashtable(SerializationInfo info, StreamingContext context)
          : base(info, context)
      {
      }
  }

Strange behaviour, but it works for now.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Web player file access 1 Answer

Webplayer exception when using BufferedStream 0 Answers

Unity 3.0 Webplayer Editor Restrictions vs Webplayer Build Restrictions 0 Answers

Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers

Webplayer functionality limitations 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges