Forum C# marshal-by-reference

marshal-by-reference

Postby mulatto401 » August 5th, 2010, 7:31 pm

Hi all,

I'm a Java guy, but learning C# has been interesting. I was wondering if anyone can shed some light about why I have been getting this Warning: "Accessing a member on 'MyGame.Player.index' may cause a runtime exception because it is a field of a marshal-by-reference class"

I get this warning when accessing these variables from my game logic code which is in another package/namespace.

I have added variables in the Player class that extends the BasePlayer class.

Code: Select all
namespace MyGame
{
   public class Player : BasePlayer
   {
      public Player enemy;
      public float money;
      public int index;
                public Cheese cheese;
      
      public Player()
      {
         
      }
   }
}


I am wondering if this is the best approach to have variables on my Player Objects or if having that warning will in any way effect the game. (I have not tested to see if it will work even with these warnings).

Thanks :D
mulatto401
Paid Member
 
Posts: 34
Joined: June 13th, 2010, 11:13 pm

Re: marshal-by-reference

Postby TomatoGG » August 6th, 2010, 9:02 am

Is your Player class and your Game class compiled into the same assembly?
The assembly must also be a DLL and not an EXE.
TomatoGG
 
Posts: 17
Joined: July 3rd, 2010, 11:15 am

Re: marshal-by-reference

Postby Oliver » August 6th, 2010, 11:01 am

Hi,

That warning is, unfortunately, a way of life -- it's because way down the class "BasePlayer" actually inherits from MarshalByRef.

It's however completely harmless.

What you can do is disable the warning in the project file :-)

- oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: marshal-by-reference

Postby mulatto401 » August 6th, 2010, 9:56 pm

Alright great, just wanted to know if it would effect the game in anyway :D
mulatto401
Paid Member
 
Posts: 34
Joined: June 13th, 2010, 11:13 pm


Return to C#



cron