473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Deriving a sealed class

Is there any way to either derive a sealed class, or access private
members of a sealed class? Either that, or is there a way to run
internal methods in a sealed class outside the current assembly? I
don't mind if the solution is hackish, the dll i'm writing is already
full of code hacks. =p

Jun 11 '06 #1
8 2624
shawnz <zi*******@gmail.com> wrote:
Is there any way to either derive a sealed class, or access private
members of a sealed class? Either that, or is there a way to run
internal methods in a sealed class outside the current assembly? I
don't mind if the solution is hackish, the dll i'm writing is already
full of code hacks. =p


You can't derive from a sealed class, but you can access members you're
not supposed to using reflection *if* you've got sufficient
permissions.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 11 '06 #2
Thanks for the advice! I didn't think to use reflection on them... This
will work on types outside the current assembly (in a reference) right?
Also, could you give me a function to point me in the right direction
doc-wise?

Jun 11 '06 #3
Probably the best thing to do instead is to take a hard look at your
design and refactor it until you get rid of the hacks. If your code is
already "full of hacks" you're just digging your grave deeper.

~justin

shawnz wrote:
Thanks for the advice! I didn't think to use reflection on them... This
will work on types outside the current assembly (in a reference) right?
Also, could you give me a function to point me in the right direction
doc-wise?


Jun 11 '06 #4
To be honest, the reason behind this is i'm trying to get around the
Internet wlm add-in sandbox without patching MessengerClient.dll. So,
using dodgy code hacks is almost my only line of defense before I
resort to doing something that can't be distributed. :p

justncase80 wrote:
Probably the best thing to do instead is to take a hard look at your
design and refactor it until you get rid of the hacks. If your code is
already "full of hacks" you're just digging your grave deeper.

~justin

shawnz wrote:
Thanks for the advice! I didn't think to use reflection on them... This
will work on types outside the current assembly (in a reference) right?
Also, could you give me a function to point me in the right direction
doc-wise?


Jun 11 '06 #5
Maybe DotMsn can help you:

http://www.xihsolutions.net/dotmsn/

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"shawnz" wrote:
To be honest, the reason behind this is i'm trying to get around the
Internet wlm add-in sandbox without patching MessengerClient.dll. So,
using dodgy code hacks is almost my only line of defense before I
resort to doing something that can't be distributed. :p

justncase80 wrote:
Probably the best thing to do instead is to take a hard look at your
design and refactor it until you get rid of the hacks. If your code is
already "full of hacks" you're just digging your grave deeper.

~justin

shawnz wrote:
Thanks for the advice! I didn't think to use reflection on them... This
will work on types outside the current assembly (in a reference) right?
Also, could you give me a function to point me in the right direction
doc-wise?


Jun 12 '06 #6
You could put an instance of the class in your class and expose all the
properties and then either call the sealed class or do your own stuff.

shawnz wrote:
Is there any way to either derive a sealed class, or access private
members of a sealed class? Either that, or is there a way to run
internal methods in a sealed class outside the current assembly? I
don't mind if the solution is hackish, the dll i'm writing is already
full of code hacks. =p

Jun 12 '06 #7

"shawnz" <zi*******@gmail.com> wrote in message
news:11**********************@m38g2000cwc.googlegr oups.com...
Thanks for the advice! I didn't think to use reflection on them... This
will work on types outside the current assembly (in a reference) right?
Yes.
Also, could you give me a function to point me in the right direction
doc-wise?


Look at System.Reflection.FieldInfo and System.Reflection.MethodInfo.
Jun 12 '06 #8

shawnz wrote:
Thanks for the advice! I didn't think to use reflection on them... This
will work on types outside the current assembly (in a reference) right?
Also, could you give me a function to point me in the right direction
doc-wise?


Also, another quick question, I realized I can't set the variables
myself because their types depend on to many other internal things. Is
there a way to just call the internal "Startup()" function from my dll?
Could I possibly inject a function into my instance of the class and
run that to run "Startup()"?

Jun 13 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Steven T. Hatton | last post by:
This may be another question having an obvious answer, but I'm not seeing it. I'm trying to create a class that derives from std::valarray<std::string>. I don't need a template, and I haven't come...
14
by: Zeng | last post by:
Would somebody know when we should seal a class? Shouldn't all classes be open up for inheritance? Thanks!
5
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to...
13
by: Mark Rae | last post by:
Hi, Since sealed classes can't be instantiated with the new keyword e.g. CClass objClass = new CClass(), does this mean that they don't have constructors / deconstructors or, if they do, that...
9
by: Kylin | last post by:
any better reason ? -- FireCrow Studio Kylin Garden EMail:gaotianpu@gmail.com ICQ:156134382
18
by: Vedo | last post by:
ref struct XXX abstract sealed { literal int A = 5; }; The definition above gives me the compiler warning "C4693: a sealed abstract class cannot have any instance members 'A'". The equivalent...
7
by: Zytan | last post by:
I know you cannot have a sealed static class, but why not? Why must static classes be left open to inheritance? This article: http://msdn.microsoft.com/msdnmag/issues/03/07/NET/ recommends to...
12
by: Shraddha | last post by:
Can I stop people by deriving my class? I mean I don't want my class to be as a base class... Can I do that?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
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,...
0
Oralloy
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.