Help inheritance does not work, why?
#1
Sad 
Hi I created two example libraries.
A parent, after which the child class inherits.
Why such a solution does not work where I do wrong?

Parent:
PHP Code:
using System; using Addon; namespace Parent { public class parent : CPlugin { public parent(string Name) { ServerPrint("Plugin " + Name + " loaded"); } public override void OnPlayerSpawned(Addon.ServerClient Client) { ServerPrint("#1 Player: " + Client.Name + " spawned"); } } }

Child:
PHP Code:
using System; using Parent; namespace Child { public class child : parent { child() : base("Test Child Plugin") { } public override void OnPlayerSpawned(Addon.ServerClient Client) { ServerPrint("#2 Player: " + Client.Name + " spawned"); } } }
The more functionality of the application the greater the chance of errors.
Reply

#2
Does it not compile at all or does it give an error?

When I inherited Cplugin in 2 different classes I got "System.MissingMethodException" for some reason.
[Image: MaEIQ.png]
Reply

#3
(05-05-2012, 09:35)Pozzuh Wrote: Does it not compile at all or does it give an error?

When I inherited Cplugin in 2 different classes I got "System.MissingMethodException" for some reason.

I use the inheritance to the two libraries, each class is a library.
I don't have errors, when delete Constructors from code, plugin work properly.
A strange thing.
The more functionality of the application the greater the chance of errors.
Reply

#4
(05-05-2012, 09:59)Nerus Wrote:
(05-05-2012, 09:35)Pozzuh Wrote: Does it not compile at all or does it give an error?

When I inherited Cplugin in 2 different classes I got "System.MissingMethodException" for some reason.

I use the inheritance to the two libraries, each class is a library.
I don't have errors, when delete Constructors from code, plugin work properly.
A strange thing.

Is there anything in the logs?
[Image: MaEIQ.png]
Reply

#5
(05-05-2012, 09:35)Pozzuh Wrote: Is there anything in the logs?

OMFG

PHP Code:
[11:07:04] System.MissingMethodException: Dla tego obiektu nie zdefiniowano konstruktora bez parametrw. w System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) w System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) w System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) w System.Activator.CreateInstance(Type type, Boolean nonPublic) w Addon.PluginCode.LoadAssembly(Assembly assembly) [11:07:04] System.MissingMethodException: Dla tego obiektu nie zdefiniowano konstruktora bez parametrw. w System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) w System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) w System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) w System.Activator.CreateInstance(Type type, Boolean nonPublic) w Addon.PluginCode.LoadAssembly(Assembly assembly) [11:07:04] ------------------------------------------------------------ [11:07:04] Server startup [11:07:05] mw3-pc-auth.prod.demonware.net resolved to 209.170.124.209 [11:07:06] mw3-pc-lobby.prod.demonware.net resolved to 209.170.124.211 [11:07:06] mw3-stun.us.demonware.net resolved to 209.170.124.113 [11:07:06] mw3-stun.eu.demonware.net resolved to 209.170.122.204

Code:
[11:07:04] System.MissingMethodException: For this object does not define a constructor without parameters.
why ?!
The more functionality of the application the greater the chance of errors.
Reply

#6
That's the same exception I get.. must be a problem with the addon or something.
[Image: MaEIQ.png]
Reply

#7
(05-05-2012, 10:31)Pozzuh Wrote: That's the same exception I get.. must be a problem with the addon or something.

Yep its problem witch a Addon.

Nukem can You fix it, in next version, PLEASE ?
The more functionality of the application the greater the chance of errors.
Reply

#8
(05-05-2012, 10:40)Nerus Wrote:
(05-05-2012, 10:31)Pozzuh Wrote: That's the same exception I get.. must be a problem with the addon or something.

Yep its problem witch a Addon.

Nukem can You fix it, in next version, PLEASE ?

Already asked Nukem about this, he didn't know what was causing it.
[Image: MaEIQ.png]
Reply

#9
Crap, I had such a cool idea.

This is a problem :
PHP Code:
[12:20:12] System.Reflection.TargetInvocationException: Obiekt docelowy wywoania zgosi wyjtek. ---> System.AccessViolationException: Nastpia prba odczytu lub zapisu pamici chronionej. Czsto wskazuje to, e inna pami jest uszkodzona. w Server.CConsole.Printf(SByte* ) w Addon.CPlugin.ServerPrint(String Message) w TestProblem.TestProblem..ctor() w c:\users\nerus\documents\visual studio 2010\Projects\TestProblem\TestProblem\TestProblem.cs:wiersz 11 --- Koniec ladu stosu wyjtkw wewntrznych --- w System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) w System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) w System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) w System.Activator.CreateInstance(Type type, Boolean nonPublic) w Addon.PluginCode.LoadAssembly(Assembly assembly) [12:20:12] ------------------------------------------------------------ [12:20:12] Server startup [12:20:13] mw3-pc-auth.prod.demonware.net resolved to 209.170.124.209 [12:20:13] mw3-pc-lobby.prod.demonware.net resolved to 209.170.124.211 [12:20:14] mw3-stun.us.demonware.net resolved to 209.170.124.113 [12:20:14] mw3-stun.eu.demonware.net resolved to 209.170.122.204

Code:
[12:20:12] System.Reflection.TargetInvocationException: the target of invocation exception. ---> System.AccessViolationException: Attempted to read or write protected memory. Often, this indicates that other memory is corrupt.

for this code

PHP Code:
using System; using Addon; namespace TestProblem { public class TestProblem : CPlugin { public TestProblem() { ServerPrint("Test Object Load !!!"); // <- this is problem, do not use CPlugin in constructor. // Always create public constructor if You use second constructor or create instances. } public override void OnServerLoad() { base.OnServerLoad(); ServerPrint("Start !!!"); } } }
The more functionality of the application the greater the chance of errors.
Reply

#10
A class that inherits CPlugin cannot have an instance constructor, it's a static class. Use the friggin OnServerLoad override or define the constructor as static. Dodgy Note that static constructors cannot accept parameters.

http://msdn.microsoft.com/en-us/library/...80%29.aspx

eg:
Code:
using System; using Addon; namespace TestPlugin { public class Test: CPlugin { static Test() { // Do crap here. } } }
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Permissions DOESNT work Hallla 2 4,011 08-18-2013, 11:28
Last Post: hillbilly
  why permissions dont work. ? ExoGamer* 4 4,811 07-21-2013, 13:46
Last Post: X-Track
  Bunker Plugin Won't work OBJAY 4 6,040 06-03-2013, 15:48
Last Post: X-Track
  Help prefix doesnt work with shop koro35 2 4,129 05-18-2013, 10:51
Last Post: koro35
  Help Perks do not work (( x1412 6 6,240 04-06-2013, 18:09
Last Post: x1412
  liberation dont work? puistis 7 10,015 02-18-2013, 09:17
Last Post: JariZ
  Weapon dont work?? Erik The Born 3 4,127 02-05-2013, 19:53
Last Post: Yamato
  private match maps won't work with mods! leereef 1 3,536 01-13-2013, 12:01
Last Post: surtek
  Some images do not work with SetShader xplosiff 8 7,341 01-05-2013, 07:19
Last Post: mw2killer
  Help !giveammo Plugin doesnt work [solved] Hallla 3 4,941 12-29-2012, 20:53
Last Post: Hallla

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.