C
CannonFodder
Hi all, i have a bit of a weird problem i'll try and explain what
happens:
I have a class called "Rules" which contains lots of objects of type
"RuleLocator" or "RuleFormatter" (both inheriting from "aRule").
I also have a class called "WMIScanner" which appies "Rules" to data.
When i define my "Rules" object within the constructor of "WMIScanner"
everything runs fine, however if i try and pass a "Rules" object into
"WMIScanner" from another class - called Scanner i get errors.
"Specified Cast is not valid"
this happens even though i am using the exact same code - just
defining the obejct outside of the "WMIScanner" class instead of
inside. The "Rules" object does not contain any references to
anything outside itself.
Does anyone know what might be happening here?
Thanks in advance for any help
Code follows:
This causes errors:
public WMIScanner(string ComputerName, Rules r)
{
strComputerName = ComputerName;
myRules = r;
Connect();
}
This doesnt error - but i dont want to leave it this way:
public WMIScanner(string ComputerName)
{
strComputerName = ComputerName;
Connect();
...
declare individual rules (ruleCapacity etc..)
...
myRules = new Rules();
myRules.addRule(ruleCapacity);
myRules.addRule(ruleSpeed);
myRules.addRule(ruleFreeSpace);
myRules.addRule(myLocatorRule);
myRules.addRule(XPRule);
myRules.addRule(DellRule);
myRules.addRule(CompaqRule);
myRules.addRule(FreeSpaceRule);
myRules.addRule(myFlat);
myRules.addRule(myFlat2);
myRules.addRule(myFlat3);
}
happens:
I have a class called "Rules" which contains lots of objects of type
"RuleLocator" or "RuleFormatter" (both inheriting from "aRule").
I also have a class called "WMIScanner" which appies "Rules" to data.
When i define my "Rules" object within the constructor of "WMIScanner"
everything runs fine, however if i try and pass a "Rules" object into
"WMIScanner" from another class - called Scanner i get errors.
"Specified Cast is not valid"
this happens even though i am using the exact same code - just
defining the obejct outside of the "WMIScanner" class instead of
inside. The "Rules" object does not contain any references to
anything outside itself.
Does anyone know what might be happening here?
Thanks in advance for any help
Code follows:
This causes errors:
public WMIScanner(string ComputerName, Rules r)
{
strComputerName = ComputerName;
myRules = r;
Connect();
}
This doesnt error - but i dont want to leave it this way:
public WMIScanner(string ComputerName)
{
strComputerName = ComputerName;
Connect();
...
declare individual rules (ruleCapacity etc..)
...
myRules = new Rules();
myRules.addRule(ruleCapacity);
myRules.addRule(ruleSpeed);
myRules.addRule(ruleFreeSpace);
myRules.addRule(myLocatorRule);
myRules.addRule(XPRule);
myRules.addRule(DellRule);
myRules.addRule(CompaqRule);
myRules.addRule(FreeSpaceRule);
myRules.addRule(myFlat);
myRules.addRule(myFlat2);
myRules.addRule(myFlat3);
}