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);
} 2 1058
CannonFodder <ga****@sol-tec.com> wrote: 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?
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi,
Are all the classes in the same project ( assembly) ?
Both the WMIScanner, Rules , aRule and the class that use them?
Maybe you are defining the same class in two different places.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"CannonFodder" <ga****@sol-tec.com> wrote in message
news:7f**************************@posting.google.c om... 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); } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rob Ristroph |
last post by:
Hi,
It's pretty unhelpful to post "I have a huge piece of code that
crashes in strange places, what's the problem?" but that's basically
my problem and I really am at my wit's end.
The piece...
|
by: CHRISTOF WARLICH |
last post by:
Hi,
the following few lines of code are showing a quite
strange and unexpected behaviour of namespaces that
makes me worry wheater I should rely on namespaces in
the future at all.
The...
|
by: Alfonso Morra |
last post by:
I have some code that I am porting over from C. It is full of static
functions and global variables. I have got around this by wrapping most
of the code in a singleton object.
However, I am...
|
by: cody |
last post by:
I have a very funny/strange effect here.
if I let the delegate do "return
prop.GetGetMethod().Invoke(info.AudioHeader, null);"
then I get wrong results, that is, a wrong method is called and I...
|
by: Kevin Prichard |
last post by:
Hi all,
I've recently been following the object-oriented techiques discussed
here and have been testing them for use in a web application. There is
problem that I'd like to discuss with you...
|
by: yb |
last post by:
Hi,
Is there a standard for the global 'window' object in browsers? For
example, it supports methods such as setInterval and clearInterval, and
several others.
I know that w3c standardized...
|
by: siddharth.munshi |
last post by:
union something
{
float a;
int b;
} u;
int main()
{
printf("%d %d\n",&u.a,&u.b);
u.a = 200;
|
by: emailscotta |
last post by:
Below I declared a basic object literal with 2 methods. The
"doSomething" method is call from the "useDoSomething" method but the
call is only sucessful if I use the "this" keyword or qualify the...
|
by: alex |
last post by:
I am so confused with these three concept,who can explained it?thanks
so much?
e.g.
var f= new Function("x", "y", "return x * y");
function f(x,y){
return x*y
}
var f=function(x,y){
|
by: Ralph |
last post by:
Hi
I don't understand why it's not working:
function schedule(imTop){
this.tdImagesTop = imTop;
}
schedule.prototype.selectEl = function() {
alert(this.tdImagesTop);
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |