Posts: 38
Threads: 11
Joined: Mar 2012
Reputation:
0
05-05-2012, 09:30
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.
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
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.
Posts: 38
Threads: 11
Joined: Mar 2012
Reputation:
0
05-05-2012, 09:59
(This post was last modified: 05-05-2012, 09:59 by Nerus.)
(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.
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
(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?
Posts: 38
Threads: 11
Joined: Mar 2012
Reputation:
0
05-05-2012, 10:12
(This post was last modified: 05-05-2012, 10:19 by Nerus.)
(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.
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
That's the same exception I get.. must be a problem with the addon or something.
Posts: 38
Threads: 11
Joined: Mar 2012
Reputation:
0
(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.
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
(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.
Posts: 38
Threads: 11
Joined: Mar 2012
Reputation:
0
05-05-2012, 10:55
(This post was last modified: 05-05-2012, 11:40 by Nerus.)
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.
Posts: 719
Threads: 69
Joined: Nov 2010
Reputation:
76
05-06-2012, 13:24
(This post was last modified: 05-06-2012, 13:29 by master131.)
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. 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.
}
}
}
A casual conversation between barata and I about Nukem.
|