C
Curious
Hi,
I have a project "GrabTritonData_HiFreq" that uses some functions that
are frequently used. Therefore, I've created a separate project
"LibraryCommon" that contains these functions. One of the functions in
"LibraryCommon" is "FindInitialLow".
I call the function "FindInitialLow" in "LibraryCommon" from
"GrabTritonData_HiFreq", and it seems that there is an issue with
object casting in "FindInitialLow".
The object type I pass is of type "Bucket". Since it's passed to the
method from "GrabTritonData_HiFreq", it's type is therefore,
"GrabTritonData_HiFreq.Bucket". An assigment is made to a variable
declared as type "Bucket" (interpreted as "LibraryCommon.Bucket") in
the method "FindInitialLow", and that cause an exception at runtime.
Obviously because these two projects ("GrabTritonData_HiFreq" and
"LibraryCommon") use different name spaces, the same object type
"Bucket" are interpreted as different types due to being in different
scopes (name spaces).
The details of this method is below:
// Each item in mHistBucketList is "Bucket" type.
// Since this is called from "GrabTritonData_HiFreq" project,
// it's therefore, "GrabTritonData_HiFreq.Bucket" type
private Bucket FindInitialLow (ArrayList mHistBucketList,
double mThreshold)
{
Bucket mInitialLow = null;
// Exception here -- dp is of type "LibraryCommon.Bucket"
in debugger, while each item
// in mHistBucketList is "GrabTritonData_HiFreq.Bucket"
type
foreach (Bucket dp in mHistBucketList)
{
// Code omitted here
}
return mInitialLow;
}
I have a project "GrabTritonData_HiFreq" that uses some functions that
are frequently used. Therefore, I've created a separate project
"LibraryCommon" that contains these functions. One of the functions in
"LibraryCommon" is "FindInitialLow".
I call the function "FindInitialLow" in "LibraryCommon" from
"GrabTritonData_HiFreq", and it seems that there is an issue with
object casting in "FindInitialLow".
The object type I pass is of type "Bucket". Since it's passed to the
method from "GrabTritonData_HiFreq", it's type is therefore,
"GrabTritonData_HiFreq.Bucket". An assigment is made to a variable
declared as type "Bucket" (interpreted as "LibraryCommon.Bucket") in
the method "FindInitialLow", and that cause an exception at runtime.
Obviously because these two projects ("GrabTritonData_HiFreq" and
"LibraryCommon") use different name spaces, the same object type
"Bucket" are interpreted as different types due to being in different
scopes (name spaces).
The details of this method is below:
// Each item in mHistBucketList is "Bucket" type.
// Since this is called from "GrabTritonData_HiFreq" project,
// it's therefore, "GrabTritonData_HiFreq.Bucket" type
private Bucket FindInitialLow (ArrayList mHistBucketList,
double mThreshold)
{
Bucket mInitialLow = null;
// Exception here -- dp is of type "LibraryCommon.Bucket"
in debugger, while each item
// in mHistBucketList is "GrabTritonData_HiFreq.Bucket"
type
foreach (Bucket dp in mHistBucketList)
{
// Code omitted here
}
return mInitialLow;
}