Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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:04System.MissingMethodExceptionDla tego obiektu nie zdefiniowano konstruktora bez parametrw.

   
w System.RuntimeTypeHandle.CreateInstance(RuntimeType typeBoolean publicOnlyBoolean noCheckBooleancanBeCachedRuntimeMethodHandlectorBooleanbNeedSecurityCheck)

   
w System.RuntimeType.CreateInstanceSlow(Boolean publicOnlyBoolean fillCache)

   
w System.RuntimeType.CreateInstanceImpl(Boolean publicOnlyBoolean skipVisibilityChecksBoolean fillCache)

   
w System.Activator.CreateInstance(Type typeBoolean nonPublic)

   
w Addon.PluginCode.LoadAssembly(Assembly assembly)
[
11:07:04System.MissingMethodExceptionDla tego obiektu nie zdefiniowano konstruktora bez parametrw.

   
w System.RuntimeTypeHandle.CreateInstance(RuntimeType typeBoolean publicOnlyBoolean noCheckBooleancanBeCachedRuntimeMethodHandlectorBooleanbNeedSecurityCheck)

   
w System.RuntimeType.CreateInstanceSlow(Boolean publicOnlyBoolean fillCache)

   
w System.RuntimeType.CreateInstanceImpl(Boolean publicOnlyBoolean skipVisibilityChecksBoolean fillCache)

   
w System.Activator.CreateInstance(Type typeBoolean nonPublic)

   
w Addon.PluginCode.LoadAssembly(Assembly assembly)
[
11:07:04] ------------------------------------------------------------
[
11:07:04Server startup
[11:07:05mw3-pc-auth.prod.demonware.net resolved to 209.170.124.209
[11:07:06mw3-pc-lobby.prod.demonware.net resolved to 209.170.124.211
[11:07:06mw3-stun.us.demonware.net resolved to 209.170.124.113
[11:07:06mw3-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:12System.Reflection.TargetInvocationExceptionObiekt docelowy wywoania zgosi wyjtek. ---> System.AccessViolationExceptionNastpia prba odczytu lub zapisu pamici chronionejCzsto wskazuje toe 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 typeBoolean publicOnlyBoolean noCheckBooleancanBeCachedRuntimeMethodHandlectorBooleanbNeedSecurityCheck)

   
w System.RuntimeType.CreateInstanceSlow(Boolean publicOnlyBoolean fillCache)

   
w System.RuntimeType.CreateInstanceImpl(Boolean publicOnlyBoolean skipVisibilityChecksBoolean fillCache)

   
w System.Activator.CreateInstance(Type typeBoolean nonPublic)

   
w Addon.PluginCode.LoadAssembly(Assembly assembly)
[
12:20:12] ------------------------------------------------------------
[
12:20:12Server startup
[12:20:13mw3-pc-auth.prod.demonware.net resolved to 209.170.124.209
[12:20:13mw3-pc-lobby.prod.demonware.net resolved to 209.170.124.211
[12:20:14mw3-stun.us.demonware.net resolved to 209.170.124.113
[12:20:14mw3-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 3,054 08-18-2013, 11:28
Last Post: hillbilly
  why permissions dont work. ? ExoGamer* 4 3,275 07-21-2013, 13:46
Last Post: X-Track
  Bunker Plugin Won't work OBJAY 4 4,506 06-03-2013, 15:48
Last Post: X-Track
  Help prefix doesnt work with shop koro35 2 2,889 05-18-2013, 10:51
Last Post: koro35
  Help Perks do not work (( x1412 6 4,404 04-06-2013, 18:09
Last Post: x1412
  liberation dont work? puistis 7 7,794 02-18-2013, 09:17
Last Post: JariZ
  Weapon dont work?? Erik The Born 3 2,851 02-05-2013, 19:53
Last Post: Yamato
  private match maps won't work with mods! leereef 1 2,503 01-13-2013, 12:01
Last Post: surtek
  Some images do not work with SetShader xplosiff 8 5,096 01-05-2013, 07:19
Last Post: mw2killer
  Help !giveammo Plugin doesnt work [solved] Hallla 3 3,559 12-29-2012, 20:53
Last Post: Hallla

Forum Jump:


Users browsing this thread:
5 Guest(s)

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