|
Presumably there is some shared functionality which is then implemented by the Concrete class (the ones defined in the config) so the abstract class (or interface) should be sufficient:
class MyBaseClass
{
abstract void DoSomething();
}
class MyConcreeteClass1 : MyBaseClass
{
override coid DoSomething()
{
Console.WriteLine("From 1");
}
}
class MyConcreeteClass2 : MyBaseClass
{
override coid DoSomething()
{
Console.WriteLine("From 2");
}
}
now, notice the only time I specify the class name is in a string - same as your config:
Type t1 = Type.GetType("MyConcreteClass1");<br />
Type t2 = Type.GetType("MyConcreteClass2");<br />
MyBaseClass o1 = (MyBaseClass)Activator.CreateInstance(t1);<br />
MyBaseClass o2 = (MyBaseClass)Activator.CreateInstance(t2);<br />
o1.DoSomething();<br />
o2.DoSomething();
-- modified at 10:48 Thursday 23rd March, 2006
|
|
|
|
|
Exactly. I'm kicking myself now. I don't know why I was trying to cast it!
thank you both for your quick responses!
greg
|
|
|
|
|
As far as i know it's not possible to make such a "dynamic cast".
Can't you create the object as instance of the subBase class needed?
In your example o will have type mytest.subBase so why cast to subBase afterwards.?
www.troschuetz.de
|
|
|
|
|
hello everybody in this forum.
iam currently implementing chat server application that must connect to the outside world from windows xp sp1 or sp2.
i tried to add my application ports programmatically to the internet connection firewall in windows xp sp1 but i couldn't cause i see the com file "hnetcfg.dll" in my windows operating system doesn't have "INetFwMgr" class that i must interlop to add the ports to the current running service of my application in the firewall.
i asked some friends and they told me it is impossible to add these ports cause your windows xp is SP1 not SP2 but what i see strange ???
is that hotmail messenger currently do that in my windows xp Sp1 ? when i try to connect to the internet it adds two UDP ports to the current dial up connection used to connect to the internet.
my question is :
i want to know how to add these ports in the windows xp if it is sp1 or sp2 as hotmail messenger does ?
is there any com file i can take from hotmail messenger for doing that ???
and if there is a com file for doing that ? if i interlopped that .Dll com into my application and i registered that com in the target pc that will run my application it will work or it needs msn messenger to be installed first (this is in case i took dll from the com files of the msn msgr).
how can i add these ports ? Please help me.
Human knowledge belongs to the world.
|
|
|
|
|
|
I have a requirement to create a hyperlink in Outlook using C#. The Hyperlink will point to some .exe file. When I create hyperlink manually in Outlook 2003, it executes the exe file on clicking it. Now I have to do this programmatically. How can it be done??
One more thing how can I pass arguments to this exe file. Any Idea??
|
|
|
|
|
|
Ya, I am talking about a hyperlink inside a composed email in outlook
|
|
|
|
|
Maybe this helps: http://forums.devshed.com/html-programming-1/adding-link-in-body-of-mailto-333922.html
|
|
|
|
|
i made control to open PPT application but i am getting a problem that when i close the form on which i am using that control the following error occurs
"Microsoft occurs a problem to close this application"
and after that a new ppt window is opened..
i Am defineing the following code to defien events....
wd.CommandBars.AdaptiveMenus = false;
wd.PresentationOpen += new ppt.EApplication_PresentationOpenEventHandler(OnOpenDoc);
wd.EApplication_Event_NewPresentation += new ppt.EApplication_NewPresentationEventHandler(OnNewDoc);
If anybody have any solution please let me know...
Thanks...
|
|
|
|
|
where is the code for closing your application?
This code always open a new application!
"wd.PresentationOpen += new ppt.EApplication_PresentationOpenEventHandler(OnOpenDoc);"
With the "+=" you open a new ppt without closing the old one!
best regard
Adiphe
"...all is simple, but there is always simpler ..."
|
|
|
|
|
hi Adiphe
thanks for response...
i am using this code for close but its giving me error i have mentioned the error in end..
wd.PresentationClose += new ppt.EApplication_PresentationCloseEventHandler(OnClose);
and the onClose function is
private void OnClose(ppt.Presentation pt, ref bool cancel)
{
if (!deactivateevents)
{
cancel = true;
}
}
I wrote this code for colse but its giving the following build error
"No overload for 'OnClose' matches delegate 'Microsoft.Office.Interop.PowerPoint.EApplication_PresentationCloseEventHandler'"
please tell me the solution
|
|
|
|
|
Hi
I want to know how to open an executable for reading
like those hexeditors out there
and how then i can jumb to specific offset and change it
any help please !!
Ahmad Shaban
|
|
|
|
|
Hi!
Try this code:
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite);
BinaryReader br = new BinaryReader(fs);
BinaryWriter bw = new BinaryWriter(fs);
fs.Seek(123, SeekOrigin.Begin);
byte[] buf = br.ReadBytes(16);
for (int i=0; i<buf.Length; i++)
buf[i] ^= 128;
fs.Seek(123, SeekOrigin.Begin);
bw.Write(buf);
bw.Close();
MessageBox.Show("Congratulations, you have ruined '"+filePath+"'!");
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Requirement :
VC++ dll ==> Exports a class which contains few functions.
I need to create a C# Application that consumes the function in
VC++ dll.
Looking forward ur Help
for thendral
|
|
|
|
|
Hi there
use :
using System.Runtime.InteropServices;
and in the class (propably a static helper class)
[DllImport ("user32.dll")]
public static extern long DestroyWindow (long hWnd);
and from your program call :
MyStaticHelper.DestroyWindow (this.Handle);
Hope that helped
Nassos
GanDad
|
|
|
|
|
Add the dll into ur project,
add a reference to that dll,
Create an object of the class in the dll,
and call the methods of that class.
Regards,
Pramod
|
|
|
|
|
I suggest you read the question more carefully next before you give wrong advise.
|
|
|
|
|
But that is how i have used a dll created in VC++.
I knew that method, so i adviced.
May be that is wrong for him,
but no one perfect here,
This is an open forum and everyone is here
to help each other, whatever they can.
it's not necessary that the answer has to be the perfect one
There are many ways to do one single thing.
Hope u get it.
If you can't give solutions u r not supposed to
say wrong to anyone.
Got it!!!
Pramod
|
|
|
|
|
Your methods will work for COM dll's only. VS just writes a COM Wrapper for you.
|
|
|
|
|
That is certainly true, but his point was that he's not supposed to be afraid to post a reply to someone's question just cause his answer might not be 100% correct.
This is not medical advice being given here. There is no law being broken if someone gives mistaken advice.
This is a community forum where people are encouraged to contribute. There is no rule that tells people that their contributions are not welcome unless they are perfect.
|
|
|
|
|
I agree wholeheartidly, I responded because he seemed surprised that his answer was taken as incorrect without explaination as to the problem!
Notice i didnt chastise him for responding with what he thought was a good answer - that was somebody else!
|
|
|
|
|
I've seen many applications that create a dump file when a crash occurs. The file can later be analysed by the developers to diagnose the reason for the crash. Is there a way I could create a crash dump from my application using a third pary library of a .NET class?
|
|
|
|
|
Hi,
i thing, in any .Net language you can create a "Tracing" class
to report all crash.
So you can use try{your code}catch{... get the error crash write and save it in a .log file} in C# or VB .Net.
best regard
Adiphe
"...all is simple, but there is always simpler ..."
-- modified at 6:53 Thursday 23rd March, 2006
|
|
|
|
|
Like the other reply said, tracing is normally ok, with an exception stack trace. If you want more, you can search for info on the SOS.dll for windbg that allows you to inspect crash dump files (not that I know how to create them, but im sure the docs will tell you).
|
|
|
|