-
Assembly class
In one of my project (Assembly ProjectA) i have created a class clsP1 where
in i have defined an overridable function OF1 which
returns a string. I'm inheriting this class to clsNC1 which is in a
different project (ASSEMBLY ProjectB) and using this newly
inherited class (clsNC1) i'm creating the final class clsFC in a new project
(Assembly ProjectC) in which i have written the code for
the overridable function.
the sample code is as follows
In projectA (output type is Class Library)
-----------------
Public Class clsP1
..
..
Public Overridable Function OF1() As String
End Function
..
..
End Class
in projectB (output type is Class Library)
----------------
Public Class clsNC1
Inherits ProjectA.clsP1
End Class
in ProjectC (output type is Windows Application)
-----------------
Public Class clsFC
Inherits ProjectB.clsNC1
Public Overrides Function OF1() As String
Return "Hello"
End Function
End Class
Project B has reference of Project A
Project C has a reference of Project A,B
Problem.
When i call the function OF1 of clsFC at times it returns "Hello" and at
times it does not return any value. On debugging it was
learned that it is refering to function OF1 in class clsP1.
I have used reflection to create the instance of the class clsFC. ie The
instance is being created by the CreateInstance method of the
Assembly class.
How do i solve this problem.
-
Re: Assembly class
You're going to have to provide some sample code on how you are using CreateObject,
handling the reference, and calling the function.
Otherwise, I can't imagine why this would fail.
-Rob
"Shailesh C.Rathod" <shailesh@suviinfo.com> wrote:
>In one of my project (Assembly ProjectA) i have created a class clsP1 where
>in i have defined an overridable function OF1 which
>
>returns a string. I'm inheriting this class to clsNC1 which is in a
>different project (ASSEMBLY ProjectB) and using this newly
>
>inherited class (clsNC1) i'm creating the final class clsFC in a new project
>(Assembly ProjectC) in which i have written the code for
>
>the overridable function.
>
>the sample code is as follows
>
>In projectA (output type is Class Library)
>-----------------
>Public Class clsP1
>..
>..
>Public Overridable Function OF1() As String
>End Function
>..
>..
>End Class
>
>in projectB (output type is Class Library)
>----------------
>Public Class clsNC1
> Inherits ProjectA.clsP1
>
>End Class
>
>in ProjectC (output type is Windows Application)
>-----------------
>Public Class clsFC
> Inherits ProjectB.clsNC1
>
> Public Overrides Function OF1() As String
> Return "Hello"
> End Function
>
>End Class
>
>Project B has reference of Project A
>Project C has a reference of Project A,B
>
>Problem.
>When i call the function OF1 of clsFC at times it returns "Hello" and at
>times it does not return any value. On debugging it was
>
>learned that it is refering to function OF1 in class clsP1.
>
>I have used reflection to create the instance of the class clsFC. ie The
>instance is being created by the CreateInstance method of the
>
>Assembly class.
>
>How do i solve this problem.
>
>
>
>
>
>
-
Re: Assembly class
G'day.
>>Problem.
>>When i call the function OF1 of clsFC at times it returns "Hello" and at
>>times it does not return any value. On debugging it was
>>learned that it is refering to function OF1 in class clsP1.
The only way I can see this happening is if the clsFC1 variable is being
cast to clsP1.
>>I have used reflection to create the instance of the class clsFC. ie The
>>instance is being created by the CreateInstance method of the
If you are using CreateInstance (of System.Activator?) then which overload
are you using? Are you using a string TypeName? If so, is the string hardcoded
or variable?
I think that we need to see the code that creates the instance to see what
is going on, however, it seems to me that there must be a mixup in the Type...
Cheers,
Paul
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks