|
Hello everyone,
Suppose my C# application is pure managed code (C#), for such types of application, CLSCompliantAttribute should be always true?
Are there any other points to be considered to consider whether or not it is complaint?
http://msdn.microsoft.com/en-us/ms182156.aspx
thanks in advance,
George
|
|
|
|
|
Hi, I am getting the compile error and cannot see why it is wrong. I am learning C# so I am pretty new to this. Here is the code I am trying to compile
using System;
using System.Windows.Forms;
namespace MyForm
{
public class MyForm : Form
{
private TextBox txtEnter;
private Label lblDisplay;
private Button btnOk;
public MyForm ()
{
this.txtEnter = new TextBox();
this.lblDisplay = new Label();
this.btnOk = new Button();
this.Text = "My HelloWin App!";
// txtEnter
this.txtEnter.Location = new System.Drawing.Point(16, 32);
this.txtEnter.Size = new System.Drawing.Size(264, 20);
//lblDisplay
this.lblDisplay.Location = new System.Drawing.Point(16, 72);
this.lblDisplay.Size = new System.Drawing.Size(264, 20);
//btnOk
this.btnOk.Location = new System.Drawing.Point(88, 224);
this.btnOk.Text = "OK";
this.btnOk.Click += new System.EventHandler(this.btnOK_Click);
//MyForm
this.Controls.AddRange(new Control[] { this.txtEnter, this.lblDisplay, this.btnOk});
}
static void Main ()
{
Application.Run(new MyForm());
}
private void btnOk_Click(object sender, System.EventArgs e)
{
lblDisplay.Text = txtEnter.Text + "\n" + lblDisplay.Text;
}
}
}
But I am getting error The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?) (CS0234)
Any help is greatly appreciated. Thanks
|
|
|
|
|
I think the clue is in the error message:
ash poxon wrote: are you missing an assembly reference?
Do you have the correct set of assemblies in your project's References? If you created a Windows Forms application project then Visual Studio should have set this up for you. But you may have accidentally deleted the reference.
Right click the References section in the Solution Explorer for your project, then "Add Reference" and then pick from the first tab the assembly called (I think) System.Windows.Forms. If that doesn't exist, open a second instance of VS and create a blank Windows Forms assembly and see what its references are.
|
|
|
|
|
Hi,
Thanks for the reply. I have using SharpDevelop application, and yes it does have the System reference in. I think that maybe I need to use Visual Studio and then it would be easier. you agree??
|
|
|
|
|
ash poxon wrote: yes it does have the System reference in
It's system.windows.forms you need as well. Check for that.
ash poxon wrote: maybe I need to use Visual Studio and then it would be easier. you agree??
Visual Studio does help with some stuff, (Like the LINQ and WPF designers are useful if you do that kind of work, which sharp develop doesn't have) but to be honest, the error message in this case is coming from the compiler so is exactly the same as what you would get with VS.
I've used sharp develop in the past and found it generally fine, just not as polished as VS.
You can get express versions of VS 2008 for free. just google it.
Simon
|
|
|
|
|
brilliant. thanks for that. will give that a try. much appreciated
|
|
|
|
|
Hi,
I need to write something to the command line and i don't know how to do it.
I try to use "Console.WriteLine(...)" but i cant get the result that i need.
I want to give some path ( for example C:\SomeFolder) and this folder will be open ( like enter same line to the Start->Run line ).
|
|
|
|
|
Your question is vague and confusing.
Yanshof wrote: I need to write something to the command line and i don't know how to do it.
I try to use "Console.WriteLine(...)" but i cant get the result that i need.
I want to give some path ( for example C:\SomeFolder) and this folder will be open ( like enter same line to the Start->Run line ).
Do you want to open an explorer window to that path? Using Console.WriteLine?
|
|
|
|
|
No,
I dont need any explorer or opening file.
I need to send some command to the command line - and by this to turn on some DOS application with some parameters.
I dont know how to do it.
|
|
|
|
|
Yanshof wrote: I need to send some command to the command line
Do you mean you need to start a new process?
Look at the Process class, it allows you to create new processes and send them command line arguments.
|
|
|
|
|
No, Its not a new process...
But Thanks any way.
|
|
|
|
|
Well what then?
Once your application is running you have no command line. If you want to run something "at the command line" then you have to start a new process. That is what running something at the command line does. It starts a new process.
|
|
|
|
|
Hi Friends how to change image formate from jpeg,gif etc to bitmap type in c#. I have to change color of image from one color to another color for that i req. bitmap file formate image only so how i can convert image to .bmp ?
thanks in advance.
|
|
|
|
|
If you read the bitmap into a System.Drawing.Bitmap, then save it to a file name with a ".bmp" extension, it will be converted to a bitmap type.
|
|
|
|
|
Hi,
I have a problem if I read CPU ID and HD serial number with P/Invoce.
It possible read this property with .NET 2.0 class?
Help me please ( possible with example )
Thanks a lot!
Alex
|
|
|
|
|
Yes
try this
Public Class Processor_ID
Public Function Get_CPU_ID() As String
Try
Dim objMOS As ManagementObjectSearcher
Dim objMOC As Management.ManagementObjectCollection
Dim objMO As Management.ManagementObject
objMOS = New ManagementObjectSearcher("Select * From Win32_Processor")
objMOC = objMOS.Get
For Each objMO In objMOC
MessageBox.Show("CPU ID = " & objMO("ProcessorID"))
Next
objMOS.Dispose()
objMOS = Nothing
objMO.Dispose()
objMO = Nothing
Catch ex As ApplicationException
MessageBox.Show(ex.Message)
End Try
End Function
End Class
and Call the Function like this
in your Form
Dim strId As String
Try
Dim objID As New Processor_ID
strId = objID.Get_CPU_ID()
MessageBox.Show(strId)
Catch ex As ApplicationException
MessageBox.Show(ex.Message)
End Try
And that is in vb, its easy to convert it to C#
Hope it Helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
|
Hi I am adding several labels and textboxes at runtime in a panel. How can i get only the text present in the textboxes? That is i need to identify the textboxes only. thanks
|
|
|
|
|
Iterate through each controls in panel and check it is a textbox.
foreach(Control control in panel.Controls)
{
if(control is TextBox)
{
(control as TextBox).Text;
}
}
|
|
|
|
|
|
HI,
Any one who can help me. how can i get a file icon, all i have are a filenames. I read about SHFILEINFO, but is there other way of retrieving the icons with out using that one?]
I'm doing a 'windows explorer'-like application in c#,web application.
Thanks!
|
|
|
|
|
I dont think so. SHFILEINFO seems to be the best way, otherwise you could analyse the registry and try to retrieve the values from there.
Der Staat mit der niedrigsten Geburtenrate ist nicht die Bundesrepublik, sondern der Vatikan.
|
|
|
|
|
|
hai,
how to do vote rating concept in .net with c#.if you know the concept or link send to me..
thank you.
|
|
|
|
|
If we understood the question it would help.
Bob
Ashfield Consultants Ltd
|
|
|
|