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
0
Question by t1 · Nov 20, 2012 at 01:02 PM · webplayerruntimesocketdeployment

How can I resolve System.MethodAccessException: Attempt to access a private/protected method failed. in Unity WebPlayer Deployment?

Hi,

I have the following run-time problem only with the webplayer in deployment. I am using Unity 3.5.5f3 on Windows 7 64bit with IE 9.0.8112.16421(32-bit)(both dev & deployment environments are this environment). I have also tested deployment in Firefox/Palemoon 3.6.3 (32-bit Mozilla based) with the same results.

I attempt the deployment via the File-->Build Settings console window. When running as a PC and Mac Standalone and as a Web Player in the IDE my app works ok. It is only on deployment (via the Web Player Build and Run) I have this issue.

I have found a similar issue here, but it is not exactly the same & its contents did not help me: http://answers.unity3d.com/questions/49048/unity-31-webplayer-access-method-failed.html

I have a series of C# files included in my Unity project based on the RabbitMQ 2.8.7 Client. A newer version (3.0.0) can be found here: https://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v3.0.0/rabbitmq-dotnet-client-3.0.0.zip

Again, everything works fine in the PC and Mac Standalone and as a Web Player in the IDE. My Start() method sets up the ConnectionFactory parameters, then tests the prefetch and attempts to create a connection shown below:

//////////////START CODE///////////////////////////////////////

     void Start () {
         ConnectionFactory cf = new ConnectionFactory();
         
         cf.UserName = "admin";
         cf.Password = "admin";
         cf.VirtualHost = "/carbon";
         cf.Protocol = Protocols.FromEnvironment();
         cf.HostName = "192.168.111.12";
         cf.Port = 5672;
         //cf.Uri = serverAddress;
 
         bool isOpen = Security.PrefetchSocketPolicy(sHostName, iPort, 500);
         if (isOpen) 
             sPrefetchMsg = "Prefetch on " + sHostName + ":" + iPort.ToString() + " success!";
         else
             sPrefetchMsg = "Prefetch on " + sHostName + ":" + iPort.ToString() + " failed.";
         
         Debug.LogWarning(sPrefetchMsg);        
         
     
         try{
         conn = cf.CreateConnection();}
         catch (Exception ex){
             sEMsg = ex.ToString();
             Debug.LogWarning(sEMsg);
         }
         
         ch = conn.CreateModel();
         string queueName = ensureQueue(ch);
         sub = new Subscription(ch, queueName);
         
         messageThread = new Thread(new ThreadStart(receiveMessages));
         
         messageThread.Start();
     }


//////////////END CODE////////////////////////////////////////

In the WebPlayer deployment environment where things do not work, the prefetch still works, but the resulting error I print to the screen as is as follows:

 //////////////BEGIN RUN-TIME OUTPUT//////////////////////////////////
 None of the specified endpoints were reachable Endpoints attempted:
 --------------------------------------------
 endpoint=amqp-0-9://192.168.111.12:5672, attempts=1
 System.MethodAccessException: Attempt to access a private/protected method failed.
 at System.Security.SecurityManager.ThrowException (System Exception ex)[0x00000] in <filename unknown>:0
 at ManagedCodeSubscriber.SocketFrameHandler_0_9..ctor (ManagedCodeSubscriber.AmqpTcpEndpoint endpoint)[0x00000] in <filename unknown>:0
 at ManagedCodeSubscriber.Framing.Impl.v0_9.ProtocolBase.CreateFrameHandler (ManagedCodeSubscriber.AmqpTcpEndpoint endpoint)[0x00000] in <filename unknown>:0...
 ======================================
 Stack trace:
 at ManagedCodeSubscriber.ConnectionFactory.CreateConnection(Int32 maxRedirects)[0x00000] in <filename unknown>:0
 at ManagedCodeSubscriber.ConnectionFactory.CreateConnection()[0x00000] in <filename unknown>:0
 at Subscriber.Start()[0x00000] in <filename unknown>:0
 //////////////END RUN-TIME OUTPUT//////////////////////////////////

Any help in resolving this WebPlayer specific issue or suggested work-arounds is much appreciated!

Thanks

Comment
Add comment · Show 6
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 t1 · Nov 20, 2012 at 02:23 PM 0
Share

The same result occurs when using Unity 4.0.0f7

avatar image t1 · Nov 20, 2012 at 02:44 PM 0
Share

in the above mentioned setup the external service I was interacting with was on a physically separate system. i attempted running the app on the same system as the service & received the same error again.

avatar image t1 · Nov 20, 2012 at 05:49 PM 0
Share

Also tried some examples here: https://github.com/AngryAnt/Unity--Network-Code-and-You ... still no dice.

avatar image Eric5h5 · Nov 20, 2012 at 06:47 PM 0
Share

Format code when posting; that's unreadable.

avatar image t1 · Nov 20, 2012 at 06:57 PM 0
Share

Formatted...my bad.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Democre · Nov 20, 2012 at 07:06 PM

Edit: You CANNOT open your own sockets when running within the web player due to the security sandbox

I would recommend finding and using a javascript MQ client on the web page wrapper for your player and access that through external calls in Unity. Or set up an MQ server with an http client and then you can interact with it from inside Unity using the WWW class.

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
avatar image
0

Answer by Sephiroth74 · Dec 09, 2012 at 08:54 PM

Hello,

I find a "solution" : in your file SocketFrameHandler_0_9, line ~120 (constructor), you can remove Buffered Stream :

  //BufferedStream stream = new BufferedStream(netstream);
  // m_reader = new NetworkBinaryReader(stream);
  m_reader = new NetworkBinaryReader(netstream);
             
 //m_writer = new NetworkBinaryWriter(new BufferedStream(netstream));
 m_writer = new NetworkBinaryWriter(netstream);

it seems an error to do that but it's not a problem, BufferedStream is strange in this case, it don't increase performance so I removed it :) and my app works fine. (I'm working in Online team from a big videogames company and I debated from it with colleagues).

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

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Failed to Create Unity Loader 1 Answer

IP Scope/Domain Rules for SocketPolicyServer connections? 0 Answers

Export objects to a .3DS file at runtime 1 Answer

How to recognize I'm in Unity Webbuild Editor, without precompiler 1 Answer

GetThreadContext failed error, happens only in play mode, only on one single project? 1 Answer


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