|
Yes you have to compile it that way.
But you can use a IDE such as Visual C# Express which is free (search Microsoft's webpage). You only press F5 there and everything is done for you.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Thx,
If we thing i use to use VC#.net 2003 for diplay small message like "Hello World",hw can i do that,should i use windows application or just library file?
If i use windows application frm vc# there we dont have namespace and directive & all no then hw do we do that?
|
|
|
|
|
CWIZO wrote: Standard question #1: what's the error?
That is standard question #2:
Standard question #2:
What error message do you get?
---
b { font-weight: normal; }
|
|
|
|
|
My bad
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
You sound a little lost at sea. Download VC2005 Express. You will still have an error, most likely, but the IDE will tell you what it is. I have no idea what your comment on namespaces means, all C# code has namespaces.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Im using vs.net 2003.pls tel me if i want display message like "Hello World",hw can i do it in vc#.net 2003.
|
|
|
|
|
If you have VS2003, why on earth are you compiling on the command line ? Create a new project in the IDE, and press F5 to compile and run it. As I said, you'll probably get the same error, but more meaningful info on what you're doing wrong.
And if you're at the 'how do I make 'hello world'' stage, I strongly recommend buying a book and working through it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thx Sir,I got my answer myself and im thx to u as wel.I did some programme using vc# created some COM+ programme also but sometimes it getting more errors.
|
|
|
|
|
Hi all.
I have a picture box that stretches over my entire form, as I use the an image for the background of the form. On top of the form I have labels, I need to set the back color of the labels to transparent, when I do this via the properties of the label it makes the backcolor of the label gray, I asume it is because that is the color of the form, but i need it to so the image through the label.
What must I do?
Is there some way that I can copy the image of the picturebox at the location of the label and then set that as the backcolor for the label??
Any help will be much appreciated
Thanx in advance
He who laughs last is a bit on the slow side
|
|
|
|
|
Why not set the Form.BackgroundImage to the background image and then set the label.BackColor = Color.Transparent?
ChrisB
|
|
|
|
|
Have absolutly no idea..
Thanks, exactly what I needed to do, only having some trouble with the image now, I see that its semi transparent, gives it that sort of vista look
He who laughs last is a bit on the slow side
|
|
|
|
|
I have a class inheriting another class. Im using the property grid to let the user modify data in that second class. the base class has an enum I dont want displayed in the property grid. Ive used attributes to hide and document items int the base class. what can be done to hide things when viewing the property grid from the inherited class?
|
|
|
|
|
I'm not sure if you poorly wrote your question for brevity or if you have problems using English. But I will try to answer your question as I understand it. I suggest you try to be as verbose in your future questions as possible.
An object, whether it is a base object or an inherited object, when placed into a property grid will be processed based on the attributes defined for each public field. If there is a value in an object that you do not want visible, use the [Browsable] attribute to control visibility. If you have elements in the base class that should never be seen, then just make them non-browsable. If, on the other hand, you want the base class visible when it is in the property grid, but not visible when an inherited object is used is a way different problem.
One possible way (which will be a big pain, but will solve your problem) is to have the inherited object be a delegate of the base class. This requires making all public elements in your base class virtual, and in the inherited class you must inherit all elements. The ones that you do not want to polymorph you have the overriden object do nothing else but call the base method.
With all public elements inherited, change the visibility scope with their attributes and see if that does the job of controlling things.
|
|
|
|
|
Hi all! I'm using following code
string[] arrWords;
StreamReader objSr;
StreamWriter objSw;
try
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
txtFileName.Text = openFileDialog1.FileName;
objSr = new StreamReader(txtFileName.Text);
string strFile = objSr.ReadToEnd();
arrWords = strFile.Split('\n');
objSr.Close();
objSw = new StreamWriter(txtFileName.Text, false);
for (int i = 0; i < arrWords.Length; i++)
{
arrWords[i] = arrWords[i].ToLower();
objSw.WriteLine(arrWords[i]);
}
objSw.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
if (objSr != null)
{
objSr.Dispose();
}
if (objSw != null)
{
objSw.Dispose();
}
}
1. Now I want to check in finally block if file is opened (due to any exception it did not get closed) and close it(like we do with a Connection object in ADO.net) over there. How can I do this?
2. Also a warning comes if I use code like this that objSr and objSw is used before it has been assigned a value how to overcome it.?
Thanks
|
|
|
|
|
I would move the call to objSw.Close() into the finally block, as it will always be executed there and then you don't have to worry about any exceptions that may or may not have occured. You should do this on most occasions to make sure that the connection gets closed correctly no matter what happens.
To overcome the warning, set the objects to null on declaration. This means they are explicity set to null, and you're not inferring anything.
|
|
|
|
|
Thanks Steve! the second warning haunted me for a long time. Now I got at it.
Regards
Nitin
|
|
|
|
|
You could do away with the try/finally blocks and use the using statement instead.
using (StreamReader objSr = new StreamReader(...))
{
using (StreamWriter objSW = new StreamWriter(...))
{
...
}
}
|
|
|
|
|
I'm looking for a way in C#.NET 2.0 to not allow my application from being closed by Task Manager by doing an End Task. Was thinking about displaying an error message saying you can't close this task. Any Ideas?
Also I'm looking for a way to detect certain applications are started and not allow them to start with a message box that says something like "Not aloud to run this app".
|
|
|
|
|
Major_A398 wrote: I'm looking for a way in C#.NET 2.0 to not allow my application from being closed by Task Manager by doing an End Task. Was thinking about displaying an error message saying you can't close this task. Any Ideas?
On your parent form, implement a handler for the Closing event. The Closing EventArg allows you to set e.Cancel = true;
Major_A398 wrote: Also I'm looking for a way to detect certain applications are started and not allow them to start with a message box that says something like "Not aloud to run this app".
This would require unsafe code hooked into the WinAPI. Can't help you there. An alternative is to have all applications as MDI children and the controller is the MDIParent. In this scenario you can do your security handling for each child application within you.
|
|
|
|
|
I already have a Closing Event:
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
this.Hide();
e.Cancel = true;
}
and when I do a Ctrl + Alt + Del then select the EXE and click end task it allows me to do this.
As for the alternative what you are saying is have like a control panel / menu that has all the applications and they can launch them from there? What prevents someone from just going to c:\windows\system32\notepad.exe from the start --> run, or start --> Programs doing it this way?
|
|
|
|
|
You can use ACL's to disallow users from running Task Manager to kill your application. When task manager kills a process, it KILLS the process.
Major_A398 wrote: As for the alternative what you are saying is have like a control panel / menu that has all the applications and they can launch them from there?
Well...actually you would have a controller for you application which is written as a Form and defined as an MDIParent. (Properties in the Windows.Form properties)
It would present a menu or panel that lists application (actually you can control what gets listed in the menu by rights!!!) When the application is chosen from the menu it runs inside the MDIParent as one of its' children. This is similar to running the document editor instances in Word....except you are running all of the application instances.
You would probably have to have each application implement an interface so that you can easily create an instance of each application and a consistant naming standard for the form that starts the application (like Main).
A user would switch between the applications via the Window option in the Menu or would just tile the applications and pick the one they want. This also has an added benefit in that you can easily control which applications can be run as a single instance or multiple instances.
Your application just changes by being defined as an MDIParent. And as I said in an earlier post, you would create an instance of each object, set yourself as the MDIParent, and then call the Show() method. The application is now an independant child inside your frame.
All your applications get compiled as classes instead of as Windows applications. So they exist as DLL's in your library folder which prevents anyone from randomly running whatever they want. Use an external config file or a Resource file that defines an ID for each application and the namespace:assembly for each library. Then your code for launching is something like this: (I'm writing this by memory at home so don't take it as perfect, ready-to-compile:
IApplication instance = (IApplication)Application.CreateInstance( manager.GetResource(appID) );
runList.Add(instance);
instance.MDIParent = this;
instance.Show();
Have fun with it.
|
|
|
|
|
theRealCondor wrote: You can use ACL's to disallow users from running Task Manager to kill your application. When task manager kills a process, it KILLS the process.
There has to be another way to do this, as I have seen this with some other apps where you can't end task on the exe.
theRealCondor wrote: Well...actually you would have a controller for you application which is written as a Form and defined as an MDIParent. (Properties in the Windows.Form properties)
It would present a menu or panel that lists application (actually you can control what gets listed in the menu by rights!!!) When the application is chosen from the menu it runs inside the MDIParent as one of its' children. This is similar to running the document editor instances in Word....except you are running all of the application instances.
You would probably have to have each application implement an interface so that you can easily create an instance of each application and a consistant naming standard for the form that starts the application (like Main).
A user would switch between the applications via the Window option in the Menu or would just tile the applications and pick the one they want. This also has an added benefit in that you can easily control which applications can be run as a single instance or multiple instances.
Your application just changes by being defined as an MDIParent. And as I said in an earlier post, you would create an instance of each object, set yourself as the MDIParent, and then call the Show() method. The application is now an independant child inside your frame.
All your applications get compiled as classes instead of as Windows applications. So they exist as DLL's in your library folder which prevents anyone from randomly running whatever they want. Use an external config file or a Resource file that defines an ID for each application and the namespace:assembly for each library. Then your code for launching is something like this: (I'm writing this by memory at home so don't take it as perfect, ready-to-compile:
IApplication instance = (IApplication)Application.CreateInstance( manager.GetResource(appID) ); runList.Add(instance); // make sure it does not get disposed instance.MDIParent = this; instance.Show();
Have fun with it.
This isn't what I want to do at all. If someone launches Notepad.exe from where ever, start --> run notepad.exe, start --> programs --> accessories --> notepad.exe it doesn't allow them to do this. I don't want my application calling notepad
|
|
|
|
|
MSDN gives this code as an example to create a callback function for
UdpClient.BeginReceive. It doesn't compile because the compiler does
not recognize "UdpState". I can't find any info on it either. Does
anyone know what "UdpState" is or could you point me to some sample
code on how to properly implement a ReceiveCallback function for a UdpClient? Any help would be appreciated.
public static bool messageReceived = false;
public static void ReceiveCallback(IAsyncResult ar)
{
UdpClient u = (UdpClient)((UdpState)(ar.AsyncState)).u;
IPEndPoint e = (IPEndPoint)((UdpState)(ar.AsyncState)).e;
Byte[] receiveBytes = u.EndReceive(ar, ref e);
string receiveString = Encoding.ASCII.GetString(receiveBytes);
Console.WriteLine("Received: {0}", receiveString);
messageReceived = true;
}
MSDN link:
ms-help://MS.MSDN.vAug06.en/cpref10/html/M_System_Net_Sockets_UdpClient_BeginReceive_1_2bb042b2.htm
Craig
|
|
|
|
|
It's a custom class they created for this example (unfortunetaly didn't include it) that simply encapsulates a UdpClient and IPEndpoint object so they can be passed to the callback method as state parameter of BeginReceive (becomes IAsyncResult.AsyncState in the callback).
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks for clearing that up. I know Microsoft has the resources to produce good documentation, too bad they don't have the talent.
Thanks again.
Craig
|
|
|
|