-
XNA Studio Express (Beta) released
Date: 08/31/06
Keywords: no keywords
Just in case somebody missed it:
Readme: http://msdn.com/directx/XNA/gse/readme/
Download (about 90 MB and you need Visual C# Express): http://msdn.com/directx/XNA/gse/
Source: http://community.livejournal.com/csharp/75052.html
-
Out of range exception.
Date: 08/31/06
Keywords: no keywords
Okay, I know I'm missing something blissfully obvious, but that is my lot in life.
Code:
ib = new IndexBuffer(typeof(short), (WIDTH - 1) * (HEIGHT - 1) * 6, device, Usage.WriteOnly, Pool.Default);
indices = new short[(WIDTH - 1) * (HEIGHT - 1) * 6];
for (int x = 0; x < WIDTH - 1; x++)
{
for (int y = 0; y < HEIGHT - 1; y++)
{
indices[(x + y * (WIDTH - 1)) * 6] = (short)((x + 1) + (y + 1) * WIDTH);
indices[(x + y * (WIDTH - 1)) * 6 + 1] = (short)((x + 1) + y * WIDTH);
indices[(x + y * (WIDTH - 1)) * 6 + 2] = (short)(x + y * WIDTH);
indices[(x + y * (WIDTH - 1)) * 6 + 3] = (short)((x + 1) + (y + 1) * WIDTH);
indices[(x + y * (WIDTH - 1)) * 6 + 4] = (short)(x + y * WIDTH);
indices[(x + y * (WIDTH - 1)) * 6 + 5] = (short)(x + (y + 1) * WIDTH);
}
}
On the second iteration through, on the first line in the FOR block, I get this error: "Make sure that the maximum index on a list is less than the list size."
I've stared at it until I'm blue in the face, and can't see where the index would be larger. (WIDTH is hardcoded to 4 and HEIGHT to 3 in the variable declaration block.) Especially when x=0 and y=1.
Ideas? Thankee much. (This is using VS 2005 standard, by the by. I'm using SHORTs instead of INTs thanks to an old vidcard that doesn't support INT-size index buffers. grumble.)
Source: http://community.livejournal.com/csharp/74841.html
-
Working with pieces of XML.
Date: 08/24/06
Keywords: xml
What is(are) the best class(es) to store pieces of xml for latter creation of XmlDataDocument out of them?
You know how you usually make Xml Schema-defined types into C# classes? Well, I want each one of those to be able to output its own piece of XML. This way I can build the class hierarchy corresponding to the schema hierarchy, and one line of code would output the complete xml of some specific schema type, or the whole XML page.
For example:
class Phone
{
public string id;
public string phone;
public Phone()
{}
public INSERT_SOME_CLASS_HERE getXml()
{
INSERT_SOME_CLASS_HERE myObject = new INSERT_SOME_CLASS_HERE();
// Building xml elements
return myObject;
}
}
Any example what class should I use? Manipulate with XmlElement? XmlNode? Or should I just use XmlDataDocuments, and keep merge them together somehow?
Thanks.
Source: http://community.livejournal.com/csharp/74707.html
-
Attach class to a Session in ASP.NET
Date: 08/23/06
Keywords: asp, web
Say, I have two classes:
Buyer
Seller
Say, I also have a class
User
which can be either Buyer or Seller, or both, or anonymous. In fact, I want User to represent the current session, and have the following member variables:
(i wrote self-explanatory members' names)
User.the_page_Im_on_right_now
User.the_page_I_wanned_to_visit_but_got_redirected_to_login
User.class_seller_or_null_if_im_not_seller
User.class_buyer_or_null_if_im_not_buyer
As you see, the User class only makes sense to keep during a session. How can I connect this kind of class with a session, so that the object of the User class gets created when a user goes to the website, it disappears when user leaves; and it stays available as the user goes from page to page?
Maybe there are built in functions for this whole thing, and I'm inventing a wheel?
(I'm using ASP.NET 2.0 with C#)
Source: http://community.livejournal.com/csharp/74435.html
-
Static, and non-static method (simultaneously).
Date: 08/21/06
Keywords: no keywords
Is it possible to make such a method that you can use like a static or like a non-static method?
class Class
{
public static void method()
{
// ...
}
}
and then use it as follows:
Class instance = new Class();
instance.method();
and also be able to use it like this:
Class.method();
Probably simple question, but too awkward for a search engine.
Source: http://community.livejournal.com/csharp/74021.html
-
Problem connecting to a java webservice
Date: 08/19/06
Keywords: java, security, web
I am writing a simple c# app in Visual C# 2005 Express to connect to a java webservice. I am basing my code off of an Visual Basic 2003 app that someone else wrote that doesn't do all that I want. My problem is I keep getting the following error messages when I try to use the service.
A first chance exception of type 'System.Net.WebException' occurred in System.Web.Services.dll
The request failed with HTTP status 404: Not Found.
public bool Work(string request, string response, string environment)
{
StreamReader fileStream = new StreamReader(request);
string content = fileStream.ReadToEnd();
VitalWS.WebServiceFacadeService webService = new VitalWS.WebServiceFacadeService();
string cmdLine;
if (environment != "veasm" || environment != "veasm2")
{
cmdLine = "https://" + environment + ".mreports.com/ws/services/webServiceFacade";
}
else
{
cmdLine = "http://" + environment + ".mreports.com/ws/services/webServiceFacade";
}
webService.Url = cmdLine;
X509Certificate privateKeyCertificate = null;
X509CertificateStore store = new
X509CertificateStore(X509CertificateStore.StoreProvider.System,
X509CertificateStore.StoreLocation.CurrentUser,"My");
bool open = store.OpenRead();
foreach (X509Certificate certificate in store.Certificates)
{
if (certificate.Subject.IndexOf("wamueast") > 1)
{
privateKeyCertificate = certificate;
}
}
if (store != null)
{
store.Close();
}
Console.WriteLine("Certificate CN:" + privateKeyCertificate.Subject);
webService.RequestSoapContext.Path.MustUnderstand = false;
X509SecurityToken digitalSignatureSecurityToken = new X509SecurityToken(privateKeyCertificate);
webService.RequestSoapContext.Security.Tokens.Add(digitalSignatureSecurityToken);
Signature digitalSignature = new Signature(digitalSignatureSecurityToken);
digitalSignature.SignatureOptions = SignatureOptions.IncludeNone;
digitalSignature.SignatureOptions = SignatureOptions.IncludeSoapBody;
webService.RequestSoapContext.Security.Elements.Add(digitalSignature);
string webResponse = null;
bool result = false;
try
{
webResponse = webService.executeService(content);
return result;
}
catch (System.Net.WebException we)
{
Console.WriteLine(we.Message);
return result;
}
}
Can anyone offer a suggestion why this does not seem to work? I know that the url for the webservice is correct because I can use the buggy VB.Net app to get a response.
Thanks
Source: http://community.livejournal.com/csharp/73666.html
-
VS.NET - change project's directory
Date: 08/16/06
Keywords: sql, web
In Visual Studio.NET Pro, my solution has two projects -- one WebSite project, and one SQL Server project. I want to move the two projects into different physical directories on my HDD, and preserve the same solution. When I do that, the Solution complains that it can't find the projects (duh). If I try to "Add Existing Items", then I am able to add the SQL Server project, but Website project does not have a file like ".csproj", therefore adding them again after moving them doesn't seem to work. Could someone suggest how can I move the projects into different folder while preserving my solution?
(This annoying stuff has to be done, because AnkhSVN does not work unless projects are in the solution directory, grrr).
Follow-up: I moved the projects, and edited the addresses in the .sln file. Now AnkhSVN is able to export the SQL Server project to the Subversion repository, but it still refuses to export the WebSite project, complaining that it is not under the solution root directory. I've already put it in the same folder as the sln file, it still complains. Do you know why?
Source: http://community.livejournal.com/csharp/73369.html
-
ADO.Net vNext
Date: 08/16/06
Keywords: asp, sql
I recently got to see a demo of the next version of ADO.Net by Shyam Pather introducing some pretty drastic changes from the current version. They are maintaining backwards compatibility, however they are adding a lot of new features which I think will alter the way data-access with .Net is done in pretty significant ways. There's a fairly well integrated support for more of an ORM approach using a tweaked SQL dialect, for example. Also, there's upcoming support for LINQ...
Shyam does a better job of introducing it...check it out here: http://blogs.msdn.com/dataaccess/archive/2006/06/22/642260.aspx
Source: http://community.livejournal.com/csharp/73026.html
-
More Performance Counters
Date: 08/14/06
Keywords: no keywords
Could anyone please help me with .NET performance counters? I am trying to read the % Processor Time of all of the currently running processes on the system. Here is my code. Assume that thisInstances is a string array containing elements, each of which is one process running on the system (I checked this myself using the debugger):
foreach (string thisInstance in thisInstances)
{
thisPerfCounter = new PerformanceCounter();
thisPerfCounter.CategoryName = "Process";
thisPerfCounter.CounterName = "% Processor Time";
thisPerfCounter.InstanceName = thisInstance;
thisPerfCounter.NextValue();
System.Windows.Forms.MessageBox.Show(thisInstance + ": " + thisPerfCounter.NextValue().ToString());
thisPerfCounter.Dispose();
thisPerfCounter = null;
thisProcess = null;
}
I see a messagebox for every process on the system, but each and every one has a value of 0. What gives? I've read articles, copied code from console applications that actually work, etc. I'm not sure what I'm doing wrong.
Any suggestions?
Source: http://community.livejournal.com/csharp/72874.html
-
I hope this isn't considered flamebait/off topic.
Date: 08/04/06
Keywords: programming
I may have a few development projects to undertake in the next while which I will be using to build up my work experience to acquire a programming job in the future. By education, I'm primarily a C++ programmer. But in this day and age, I find that a lot of the jobs at my level (entry-level) are looking for everything but C++.
My question is whether or not C# has enough of a following to make it a good language to gain experience in, (as in, are there a reasonable number of jobs out there for entry level C# programmers), or if I should be turning my focuses elsewhere?
The applications I'd be writing as part of my job will involve standard business practices (scheduling, POS, etc).
Any insight people can offer is much appreciated :)
Source: http://community.livejournal.com/csharp/72540.html
-
First IRC client
Date: 08/03/06
Keywords: no keywords
I'm self-learning C# and last night I felt that I had learned enough to try and make a very simple IRC connection client. And so far it seems to be working fairly well except for the minor fact that you can't really see any of the incoming data. I know this because I've yet to program a way to get it. Why? Because I'm not entirely sure how I should continually get all of the incoming data. This is where I could really use some help. I'd also like some comments or advice on the code itself. It's split up into two files, the Program class which is just the main method, and the IRC class which handles all of the IRC information and commands.
using System;
using System.Collections.Generic;
using System.Text;
namespace IRCtesting
{
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("Starting the client..\n");
IRC irc;
if (args.Length == 0)
{
// Create a new IRC connection using the default constructor
irc = new IRC();
}
else
{
// Code to seperate and get the arguments later
irc = new IRC();
}
while (irc.canQuit == false)
{
irc.getCommand();
}
System.Console.WriteLine("Press any key to close the client...\n");
System.Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace IRCtesting
{
class IRC
{
#region variables
// Public variables
public bool canQuit = false;
public bool connected = false;
public static StreamWriter writer;
public static StreamReader reader;
// Private variables
private int ircPort = 6667;
private string ircServer = "irc.magicstar.net";
private string nickNameMain = "CSharpIRC";
private string nickNameBckup = "CSharpIRCbck";
private string user = "USER CSharp 1 * :Dont look at me !!!";
private string channel = "";
private TcpClient ircClient;
private NetworkStream stream;
private Thread pingSender;
// Private constants
private const string CRLF = "\r\n";
private const string PING = "PING :";
#endregion
#region constructors
////////////////////////////////////////////////
//////////////CONSTRUCTORS//////////////////////
// There are six constructors which allow you //
// to specify some or all the information //
// necessary to connecting. //
////////////////////////////////////////////////
public IRC()
{
// Connect to IRC
connect();
}
public IRC(string server)
{
ircServer = server;
// Connect to IRC
connect();
}
public IRC(int port)
{
ircPort = port;
}
public IRC(string server, int port)
{
ircServer = server;
ircPort = port;
// Connect
connect();
}
public IRC(string server, int port, string mainNick)
{
ircServer = server;
ircPort = port;
nickNameMain = mainNick;
}
public IRC(string server, int port, string mainNick, string backupNick)
{
ircServer = server;
ircPort = port;
nickNameMain = mainNick;
nickNameBckup = backupNick;
// Connect to IRC using the settings
connect();
}
#endregion
private void connect()
{
// Tell people we're going to connect
System.Console.WriteLine("Connecting to " + ircServer + ":" + ircPort + " ...\n");
try
{
// Try to make a connection to the server
ircClient = new TcpClient(ircServer, ircPort);
stream = ircClient.GetStream();
reader = new StreamReader(stream);
writer = new StreamWriter(stream);
// Start up our ping handler
PingControl();
// Send the ident information to the server (i.e. our user and who we are)
writer.WriteLine(user);
writer.Flush();
writer.WriteLine("NICK " + nickNameMain);
writer.Flush();
// We're connected, so let's set our bool to true.
connected = true;
}
catch (Exception e)
{
// Show the exception
Console.WriteLine(e.ToString() + CRLF);
// Sleep, before we try again
Thread.Sleep(5000);
connect();
}
}
private void quit()
{
// Message that we're quitting
writer.WriteLine("QUIT ");
writer.Flush();
// Exit out of the program.
quit_program();
}
private void quit(string message)
{
// Message that we're quitting
writer.WriteLine("QUIT " + ":" + message);
writer.Flush();
// Exit out of the program.
quit_program();
}
private void quit_program()
{
// Close everything down
stream.Close();
writer.Close();
reader.Close();
ircClient.Close();
// Tell the console that we can quit and release control
connected = false;
canQuit = true;
}
// Join a channel, no key
private void join(string chan)
{
if (channel == "")
{
channel = chan;
writer.WriteLine("JOIN " + channel);
writer.Flush();
}
else
{
Console.WriteLine("This client only supports one channel right now.\n");
}
}
// Join a channel with a key
private void join(string channel, string key)
{
}
// Send something to the channel
private void sendToChannel(string message)
{
writer.WriteLine("PRIVMSG " + channel + " :" + message);
writer.Flush();
}
////////////////////////////////////////////////
///////////////COMMAND PARSER///////////////////
// The command parser takes the incoming text //
// from the console and splits it up into //
// tokens as well as determines what command //
// has been used and what function should be //
// called. //
////////////////////////////////////////////////
public void getCommand()
{
// Get the command string from the console
string rawCommandString = Console.ReadLine();
// Break the command into their tokenized parts so we can determine what to do
string[] commandString;
commandString = rawCommandString.Split(new char[] { ' ' });
// Get the first element of the command string and convert it to upper case
string command = commandString[0].ToString();
command = command.ToUpper();
///////////////////////////////////////////////////
// The QUIT command. Used to disconnect from the//
// server. It'll also cause our console to stop.//
///////////////////////////////////////////////////
if ((command == "QUIT") || (command == "/QUIT"))
{
// We need to check to see if the person has typed a quit message
int commandLength = commandString.Length;
if (commandLength >= 2)
{
// Determine what the message is.
commandLength = commandString.Length - 1;
string message = "";
for (int i = 1; i <= commandLength; i++)
{
message = message + commandString[i] + " ";
}
// Let's quit with our message
quit(message);
}
else
quit(); // Quit with a default message of your nick.
}
///////////////////////////////////////////////////
// The JOIN command. Used to join an IRC channel//
// and may have a key (if the channel is locked) //
///////////////////////////////////////////////////
if (((command == "JOIN") || (command == "/JOIN") || (command == "/J")))
{
// Set our channel
string chan = commandString[1].ToString();
// Does the channel have the necessary #?
if (!chan.StartsWith("#"))
{
// We'll add it here.
chan = "#" + commandString[1].ToString();
}
// Does this join command have a key for the channel?
// Check for the max number of words in the array first.
int commandLength = commandString.Length;
if (commandLength >= 3)
{
// Is the next word a space or null?
if (commandString[2].ToString() != "")
{
// We have a key! Let's get the key and join the channel.
string key = commandString[2].ToString();
join(chan, key);
}
}
// No, it doesn't, so just join a regular channel
else
join(chan);
}
///////////////////////////////////////////////////
// The "Say" command to send a message to the //
// active channel. //
///////////////////////////////////////////////////
if ((command == "SAY") || (command == "/SAY"))
{
if (channel != "")
{
// Determine what the message is.
int commandLength = commandString.Length -1;
string message = "";
for (int i = 1; i <= commandLength; i++)
{
message = message + commandString[i] + " ";
}
// Send the message to the command
sendToChannel(message);
}
else
{
Console.WriteLine("You must first join a channel.\n");
}
}
}
////////////////////////////////////////////////
////////////////PING CONROL/////////////////////
////////////////////////////////////////////////
// PING control is a set of two functions that//
// will ping the server every 15 seconds on a //
// seperate thread until we are no longer //
// connected to the server. //
////////////////////////////////////////////////
private void PingControl()
{
// Start a new thread for the Ping Control
pingSender = new Thread (new ThreadStart(PingRun));
pingSender.Start();
// Begin running the control
PingRun();
}
// Send PING to irc server every 15 seconds
private void PingRun()
{
// Is the client still running? If so, we need to ping the server
while ((canQuit == false) && (connected == true))
{
writer.WriteLine(PING + ircServer);
writer.Flush();
Thread.Sleep(15000);
}
}
}
}
I'm also not entirely sure how to go about splitting up the args[] and determining which constructor to use based on that. However, once I get the incoming information working and displaying correctly I more or less plan to scrap the console version and move onto a more GUI-based client so I'm not too worried about that.
Source: http://community.livejournal.com/csharp/72373.html
-
Free\Open Source Reporting?
Date: 08/03/06
Keywords: software, google
Can anyone recommend a reasonably decent free (preferably open source) reporting package (think crystal reports) that I can use with C#?
My google-fu doesn't seem to be getting me anywhere with this.
Failing that, can anyone recommend some other reporting software that is reasonably priced? I am using an Express Edition of Visual Studio, and unless I'm missing something, it doesn't include Crystal Reports.
Source: http://community.livejournal.com/csharp/71990.html
-
Passing ArrayLists to managed stored procedures.
Date: 08/02/06
Keywords: sql
Hi guys,
I create stored procedures in the following way:
[SqlProcedure]
public static void addrow(string blah1, string blah2)
{
// the code
}
and this works fine.
However, now I'm trying to pass an ArrayList instead of a string.
[SqlProcedure]
public static void addrow(ArrayList blah1, ArrayList blah2)
{
// the code
}
and when I deploy the server project, visual studio yells at me saying that it doesn't know such thing as an ArrayList.
But the following line is present:
using System.Collections;
Still it doesn't work.
Is there no way to pass an ArrayList into a managed stored procedure?
Source: http://community.livejournal.com/csharp/71812.html
-
job opening
Date: 08/02/06
Keywords: programming, java, spam
A little off topic:
Anyone in the Houston area, or know anyone in the Houston area, looking for a Java or C# programming job? Experienced programmers only, please. This is not spam, my company works with both C# and Java, we need programmers with knowledge in either, or preferably both. If you are interested or know of someone who is please comment and I will send you my email address.
Thanks!
Source: http://community.livejournal.com/csharp/71578.html
-
Performance counters in .NET
Date: 07/30/06
Keywords: no keywords
I was wondering if PerformanceCounter classes in .NET (specifically those monitoring processor time) would return samples based upon a possible max value of 100, or a possible max value of (100 * number of logical processors)? On a multithreaded Pentium IV I am seeing Idle values of 193 - 198, which I assume is simply the total of the Idle processes on logical processor 0 and logical processor 1.
Is there a better way to get the true average Idle process time than to simply divide this sample by the number of logical processors in the system? Is there a performance counter that will give me a normalized figure on a set scale (e.g. 0-1, 0-100, etc.) per process?
Thanks for any information.
Source: http://community.livejournal.com/csharp/71311.html
-
System.Collections
Date: 07/20/06
Keywords: microsoft
Hi all. I'm at it again and this time I'm trying to use the ArrayList class that's found within the System.Collections namespace. However, I don't seem to HAVE this namespace. I've added System, and I've tried to manually add System.Collections into the references but I don't see it. So I type it in manually, and try to do an ArrayList but it says "The type or namespace 'ArrayList' could not be found (are you missing a using directive or an assembly reference?)" and I'm at a loss of how to fix this.
I'm using version 2.0.50727 of the .NET Framework, which if I'm not mistaken is the newer version (at least Microsoft's Update doesn't show any newer versions). I'm using Visual C# 2005, as well.
Anyone have any ideas on how to fix this? I really need this ArrayList to finish this project.
Source: http://community.livejournal.com/csharp/70714.html
-
Database Binary Conversion
Date: 07/17/06
Keywords: database, web
Hello, long time lurker, first time poster here. :)
I'm currently working with your typical sandbox Northwind Database and C# .NET. I have set up a Datagrid class to spit out the contents of a certain table in the database (Employees). However, one of the fields in the database, "Photo", currently takes a Binary representation of an image.
My goal is to take the binary and convert it into a relevant image for display on a website, all in a Datagrid control.
Would anybody know of a way to go about doing this, or at least point me in the right direction?
Thanks!
Source: http://community.livejournal.com/csharp/70616.html
-
VC# 2003 and listBox woes
Date: 07/14/06
Keywords: no keywords
Visual C# 2003, with latest .NET 1.1 SDK patch.
I've created a simple test app containing a list box and a button. When the button is clicked on, it adds three items to the listBox and refreshes. I can see the refresh, but no text is viewable. Yes, the text is black on white. I've highlighted an entry to show that the text just isn't showing up.
Anyone have any idea? I've tried with and without the Refresh() - which should be called automatically by EndUpdate() anyways.
private void button1_Click(object sender, System.EventArgs e)
{
listBox1.Items.Clear();
listBox1.BeginUpdate();
listBox1.Items.Add("test1");
listBox1.Items.Add("test2");
listBox1.Items.Add("test3");
listBox1.EndUpdate();
listBox1.Refresh();
}
Source: http://community.livejournal.com/csharp/70385.html
-
SmartPhone 2003/Windows Mobile 5 Programming
Date: 07/12/06
Keywords: programming
I recently got a Cingular 2125 that has WM 5 Smartphone Edition on it. I want to learn how to do some programming for it. Thing is though there's alot of literature online about SP 2003 programming, but not alot on WM 5. I did do some reading on SP 2003, but is all that basically useless given the new WM5? Or are the programming styles similar, akin more to .Net 1.0 - 1.1 vs 1.1 - 2.0?
Basically can I take 2003 knowledge and apply it to developing programs for WM5? Or are the two of them completely separate beasts? Thanks.
Source: http://community.livejournal.com/csharp/69855.html
-
Collections question
Date: 07/12/06
Keywords: no keywords
If I have ArrayList G and its object is also ArrayList H, how can I get the information stored in the ArrayList H? A year ago I was doing the following:
IEnumerator enumerator = G.GetEnumerator();
enumerator.MoveNext();
string h=enumerator.Current.ToString();
now this operation gives me the following g="System.Collections.ArrayList", which is a type of object Н but not its content.
How can I get the content? I've searched the MSDN but they do not consider ArrayList as an object of another ArrayList.
Source: http://community.livejournal.com/csharp/69570.html