|
As the method in question isn't accessing instance data it should not be part of an interface anyway.
MSDN[^] says:
It is safe to suppress a warning from this rule for previously shipped code for which the fix would be a breaking change.
|
|
|
|
|
Yes , those are unused methods which are kept for the future usage.
Thank You
|
|
|
|
|
Don't worry too much about that, it's only a warning.
If a non-static method don't use any instance-level method or property, FxCop tells you that there are no reasons that method should not be static, and suggest you to make it static.
But, if that method is part of an interface implementation (or exposed publicly and alraedy used from other methods), there ARE reasons that should not be static, so you should ignore the warning.
If you want, you can use the SuppressMessage attribute to avoid getting the warning for specific methods.
|
|
|
|
|
If your app compiles without errors and runs without crashing, you can safely ignore pretty much any warnings FXCop generates. It just provides suggestions on "best practice for coding style. It is not intended to be an omnipotent oracle of "how to code". Throw away the crutch, and learn to stand on your own two feet.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
I agree with this answer.
I am *SUPER* anal about my code formatting. I mean, really, super duper anal. So I thought FxCop would be my new BFF. Sadly no. I found most of its demands to be too pretentious for my tastes and quickly uninstalled it.
|
|
|
|
|
Hi. I want to change the function of each keyboard key.I want my application to listen to key press events globally and change key value. for example when i press 'A' while writing in notepad, my Application should see the key press event before Notepad and send Letter B to the active application. I've managed to listen the key press event globally, what i want is to block other applications from getting key press events?
|
|
|
|
|
Which one of the suggestions in response to your earlier question[^] did you try?
At what point did you get stuck?
What code caused which error message?
Ciao,
luker
|
|
|
|
|
Hi,
I've been searching for days for a way to find the exchange mailstore on any exchange server given only it's name.
For e.g I have an exchange server EXSRV01, I have nothing to tell me if it is running exchange 2000,2003, 2007 etc. All I need to find is the size of the mailstore.
I was thinking I could just get the edb (and slv if it exists) file sizes, but then I don't know where they are stored because it could be stored in it's default location, or on a specific partition etc.
Is there a 'using' directive that would give me access to anything that will help?
If not, am I on a goose chase?
Thank you for any help
|
|
|
|
|
|
I have the following class:
public class WebServer
{
private readonly TcpListener _listener;
private readonly Thread _listenerThread;
public WebServer()
{
_listener = new TcpListener(IPAddress.Parse("127.0.0.1"), 80);
_listenerThread = new Thread(ListenForClients);
}
public void StartListening()
{
_listenerThread.Start();
}
private void ListenForClients()
{
_listener.Start();
while (true)
{
TcpClient client = _listener.AcceptTcpClient();
var clientThread = new Thread(HandleClient);
clientThread.Start(client);
}
_listener.Stop();
}
private void HandleClient(object client)
{
var tcpClient = client as TcpClient;
var clientStream = tcpClient.GetStream();
var encoder = new ASCIIEncoding();
var message = new byte[4096];
while (true)
{
int bytesRead = 0;
string fileToGrab;
try
{
bytesRead = clientStream.Read(message, 0, 4096);
string msg = encoder.GetString(message);
Console.WriteLine("Client {0} connected", tcpClient.Client.LocalEndPoint);
Console.WriteLine(msg);
string[] parts = msg.Split(' ');
fileToGrab = parts[1];
}
catch
{
break;
}
if (bytesRead != 0)
{
if (fileToGrab == "/") fileToGrab = @"/index.html";
else if (!File.Exists(Environment.CurrentDirectory + fileToGrab))
{
fileToGrab = @"/error.html";
}
byte[] buffer = File.ReadAllBytes(Environment.CurrentDirectory + fileToGrab);
clientStream.Write(buffer, 0, buffer.Length);
clientStream.Flush();
string serverIp = "From server " + _listener.LocalEndpoint;
clientStream.Write(encoder.GetBytes(serverIp), 0, serverIp.Length);
clientStream.Flush();
break;
}
}
Console.WriteLine("Client {0} closed",tcpClient.Client.LocalEndPoint);
tcpClient.Close();
}
}
That is used to host a small web-server for the browser to connect to and receive data.
It works fine in a console application:
static void Main()
{
WebServer server = new WebServer();
server.StartListening();
}
But in a windows forms app:
public partial class Form1 : Form
{
private readonly WebServer _server;
public Form1(WebServer server)
{
_server = server;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
_server.StartListening();
}
}
...When the button is pressed to turn it on, when connecting it only receives the client data, but the client does not receive the server data.
I dont know why, something to do with "[STAThread]" ?
Thanks
|
|
|
|
|
There's a simple way to test that: put [STAThread] on your console app. However, I'm fairly sure I've served TCP from within a WinForms app without problems in the past.
I don't immediately see the problem.
You should put some logging in the socket error catch block, as well as breaking out of the loop.
Actually never mind that, you should use the asynchronous socket methods (BeginReceive and BeginAccept), instead of creating a thread for each client. (Also, your accept thread will never terminate.) Take a look at my Sockets library[^] for an example if the MSDN docs don't make it clear enough (specifically the ClientInfo class which uses asynchronous receive, and the Server class which uses asynchronous accept).
|
|
|
|
|
Hi. I've created a click event to my windows notify icon. but when i click the icon on the task bar, i lose focus from my current window. for example i am writing something on note pad. then when i click the notify icon i dont want to lose focus from my notepad window, just like windows language bar. does anyone know how to do that? TNX in advance
|
|
|
|
|
le client va envoyer un demande et le serveur répond par confirmation ou refus.s'il vous aidez moi pour trouver les codes nécessaire de cette application avec c#
|
|
|
|
|
C'est un anglophone site. Plus votre question n'a aucun détail. Français ou anglais, nous ne pouvons pas aider.
"You get that on the big jobs."
|
|
|
|
|
There must be a plethora of sites detailing how to do this. Seriously, google for this - it's basic stuff.
|
|
|
|
|
even if i translate what you said in french to English, question is still unclear!
Please write in language understood by all.
In English: the client will send a request and the server responds by confirming or refus.s it you help me find the codes needed for this application with c #
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|
|
Dear members,
I'm in search for a Visual Studio 2010 Photo Gallery website or project I can customize to my needs. It does not need to be free. I would be most grateful for any links/hints/etc leading to sites offering such contents.
My C# knowledge is limited.
thnx
|
|
|
|
|
It depends on the features you want but this could be very easy to build yourself. Do you want to use ASP.NET, MVC, HTML5, Silverlight?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
i have project that need to reference a mathlab dll, but this dll is wroking only on 64 bit systems, because i build the dll in my 64 bit pc, when i try to run this project in 32 bit pc i get an error, but when i run the project with the dll which is built in 32 pc it works fine. so my problem is how can i add the reference at run time depending on the system(32/64), so then i don't want to keep two separate projects.
and is there any way that i can add the reference that can be selected at runtime, but the doubt i'm having is i need a reference (one of them 32 dll or 64 dll) to build the project.
appreciate your ideas.
thanx in advance.
|
|
|
|
|
Assuming you have two native code DLLs, one with 32-bit code, the other 64-bit code, there are basically two ways AFAIK:
1.
force your app to always run in 32-bit mode using shortcut properties. Or build your managed app for "x86"; it will always require the 32-bit DLL.
2.
build your managed app for "Any CPU". It will get launched as 64-bit whenever possible, and then it will need all-64-bit DLLs. As you normally don't explicitly load native DLLs from managed code, the best way to cope would be to have two prototypes and a stub for every native method, like so (note different DLL names!):
static class mathlabStub {
private static bool use64bit;
[DllImport("mathlab32.dll", EntryPoint=someFunction)] public static extern int someFunction32(...);
[DllImport("mathlab64.dll", EntryPoint=someFunction)] public static extern int someFunction64(...);
public static int someFunction(...) {
if (use64bit) return someFunction64(...);
return someFunction32(...);
}
and then you have to set use64bit once, maybe like so: use64bit=sizeof(IntPtr)==8;
use64bit=Marshal.SizeOf(typeof(IntPtr))==8;
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Sunday, April 17, 2011 11:51 AM
|
|
|
|
|
I am using C# 2010 and I have an access database that connects to my form and I have 7 tables in it, all tables have the same fields but show different information (its an front end user application that connects to a database that has information on shellfish and each table is a different family but contains same field headings such as common name, size of shell, shape of shell, distribution etc...).
What I would like to is have two list boxes on my form, one to choose the table and second to choose information on the first column of the table as the first column is the common name of the species you are looking for, which is different depending on the table chosen, and when you choose one, it loads the information into the correct textboxes. How would I do this? Haven't worked with creating front end database applications for about 4 years and getting a little rusty. Thanks in advance.
In the end we're all just the same
|
|
|
|
|
You can still do it the same way you did it 4 years ago using ADO.NET.
If this is not legacy data, by that I mean you can change the structure without breaking other applications, merging this data into one table will make life a lot easier. Create a Family table with Id and Name fields. Then create another table called Shellfish with all the same fields and include a FamilyId field. Then insert the records from the other tables. You can do this by creating queries in Access. The reason I suggest this is because it will make developing your UI a lot easier. Normalising the data schema will make a huge difference.
Also is there any requirement for the data to be stored in Access? Access has an upgrade wizard which will make it easy to convert to a SQL Express database. This will enable you to use Entity Framework which will make development quicker if you don't include the learning curve.
Once you have done that, filling your ComboBoxes, ListBoxes, TextBoxes etc., will be a piece of cake.
If it is a legacy system you are probably resigned to cutting a lot of code in your Data Access Layer to replicate what I have mentioned above using ADO.NET.
FamilyListBox.DataSource = myData.GetFamilies();
...
private void FamilyListBox_SelectedValueChanged(object sender, EventArgs e)
{
CommonNameListBox.DataSource = MyData.GetShellFish();
}
private void CommonNameListBox_SelectedValueChanged(object sender, EventArgs e)
{
ShellFish shellFish = CommonNameListBox.SelectedItem as ShellFish;
CommonNameTextBox.Text = shellFish.CommonName;
...
}
You will also need to set the DisplayName property for the ListBoxes.
Hope that helps but it is a hard question to answer in a few words.
"You get that on the big jobs."
|
|
|
|
|
I have a progress bar on my first form (first form you see when application loads). What I want to happen is when the form opens for the progress bar to go up 10 every second until it gets to its maximum value of 100, stop and stay at maximum value then enable a button which is disabled.
Code on form load:
Timer time1 = new Timer();
time1.Interval = 10;
time1.Tick += new EventHandler(timer1_Tick);
time1.Start();
Code on timer tick:
progressBar1.Value += 1;
timer1.Stop();
Now the problem with this code, I get an error because the progress bar tries to go 1 higher than its maximum value and I can't figure how to get the progress bar to stop trying to go higher when its at its maximum value. I am not sure where to put the button enable code since there is something I am doing wrong here.
Next I have another button that when clicked I want it to close the form and open another form. I don't want the form to hide when closed but exit the form completly, but putting form1.close (); it won't work as its my first form, the whole app just exits. What should I do?
In the end we're all just the same
|
|
|
|
|
Dave McCool wrote: time1.Interval = 10;
that is 10 milliseconds.
Dave McCool wrote: progressBar1.Value += 1; timer1.Stop();
so it will increment once, then the timer stops?
You need some conditional code. Maybe test whether incrementing the progress bar would overflow, and if so stop the timer and change the button state.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|