|
I'm getting a NullReferenceException from the line "notify.SetNotificationPositions(bpnArray,3);" in the code below anyone got any idears.
code:
buffer = new Microsoft.DirectX.DirectSound.Buffer(bufferDescription, playbackDevice);<br />
<br />
bufferHalfEmptyEvent = new AutoResetEvent(false);<br />
<br />
bufferSize = buffer.Caps.BufferBytes;<br />
<br />
sinusBuffer = new MemoryStream(waveFormat.BlockAlign * waveFormat.SamplesPerSecond);<br />
<br />
BufferPositionNotify bufferOneThridPointNotify = new BufferPositionNotify();<br />
bufferOneThridPointNotify.Offset = bufferSize / 3 - 1;<br />
bufferOneThridPointNotify.EventNotifyHandle = bufferHalfEmptyEvent.Handle;<br />
BufferPositionNotify bufferTwoThridPointNotify = new BufferPositionNotify();<br />
bufferTwoThridPointNotify.Offset = (2*bufferSize / 3) - 1;<br />
bufferTwoThridPointNotify.EventNotifyHandle = bufferHalfEmptyEvent.Handle;<br />
BufferPositionNotify bufferEndPointNotify = new BufferPositionNotify();<br />
bufferEndPointNotify.Offset = bufferSize - 1;<br />
bufferEndPointNotify.EventNotifyHandle = bufferHalfEmptyEvent.Handle;<br />
<br />
BufferPositionNotify[] bpnArray = new BufferPositionNotify[3];<br />
bpnArray[0] = bufferOneThridPointNotify;<br />
bpnArray[1] = bufferTwoThridPointNotify;<br />
bpnArray[2] = bufferEndPointNotify;<br />
Notify notify = new Notify(buffer);<br />
notify.SetNotificationPositions(bpnArray, 3);
|
|
|
|
|
The only thing I can see is that maybe your offset calculations are causing a problem during the division process. It may be getting rounded down during. Set a breakpoint before or on SetNotificationPositions and check those values aren't <= 0
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Nope thats not it. Have tried with offset set to 10,20 and 30 same result. buffersize is 0x8000;
But thanks.
|
|
|
|
|
Which object is it saying is null?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
It doesn't say for some reason directX just throw a standard NullReferenceException.
|
|
|
|
|
From my delving into MSDN, the two parameters for SetNotificationPositions are:
dwPositionNotifies
Number of DSBPOSITIONNOTIFY structures.
pcPositionNotifies
Pointer to an array of DSBPOSITIONNOTIFY structures (the maximum array size is DSBNOTIFICATIONS_MAX).
So it looks to me like you have the params reversed.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I found that when I first looked. I think Microsoft.DirectX.DirectSound class wrapps this and provides
public void SetNotificationPositions(BufferPositionNotify[] notify, int numNotificationPositions);
Link[^]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Ain't MS wonderful.
My link is titled 'DirectX and XNA', so must be fairly recent, and yet yours gives a different answer.
I give up!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
When i try to transefer files using socket, the message is sending pary by part, so when in the reciving end the partial byte of the file making exception.
How can i send the byte[] in its full form, not part by part?
Thankyou
YPKI
|
|
|
|
|
Please try this
//Client Socket code
/* Make IP end point same as Server. */
Socket clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
/* Make a client socket to send data to server. */
string filePath = "";
/* File reading operation. */
fileName = fileName.Replace("\\", "/");
while (fileName.IndexOf("/") > -1)
{
filePath += fileName.Substring(0, fileName.IndexOf("/") + 1);
fileName = fileName.Substring(fileName.IndexOf("/") + 1);
}
byte[] fileNameByte = Encoding.ASCII.GetBytes(fileName);
if (fileNameByte.Length > 850 * 1024)
{
curMsg = "File size is more than 850kb, please try with small file.";
return;
}
curMsg = "Buffering ...";
byte[] fileData = File.ReadAllBytes(filePath + fileName);
/* Read & store file byte data in byte array. */
byte[] clientData = new byte[4 + fileNameByte.Length + fileData.Length];
/* clientData will store complete bytes which will store file name length, file name & file data. */
byte[] fileNameLen = BitConverter.GetBytes(fileNameByte.Length);
/* File name length’s binary data. */
fileNameLen.CopyTo(clientData, 0);
fileNameByte.CopyTo(clientData, 4);
fileData.CopyTo(clientData, 4 + fileNameByte.Length);
/* copy these bytes to a variable with format line [file name length][file name] [ file content] */
curMsg = "Connection to server ...";
clientSock.Connect(ipEnd);
/* Trying to connection with server. /
curMsg = "File sending...";
clientSock.Send(clientData);
/* Now connection established, send client data to server. */
curMsg = "Disconnecting...";
clientSock.Close();
/* Data send complete now close socket. */
curMsg = "File transferred.";
//Server Scoket Code
//Make IP end point to accept any IP address with port no 5656.
sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
//Here creating new socket object with protocol type and transfer data type
sock.Bind(ipEnd);
//Bind end point with newly created socket.
}
public static string receivedPath;
public static string curMsg = "Stopped";
public void StartServer()
{
try
{
curMsg = "Starting...";
sock.Listen(100);
/* That socket object can handle maximum 100 client connection at a time & waiting for new client connection /
curMsg = "Running and waiting to receive file.";
Socket clientSock = sock.Accept();
/* When request comes from client that accept it and return new socket object for handle that client. */
byte[] clientData = new byte[1024 * 5000];
int receivedBytesLen = clientSock.Receive(clientData);
curMsg = "Receiving data...";
int fileNameLen = BitConverter.ToInt32(clientData, 0);
/* I’ve sent byte array data from client in that format like [file name length in byte][file name] [file data], so need to know first how long the file name is. /
string fileName = Encoding.ASCII.GetString(clientData, 4, fileNameLen);
/* Read file name */
BinaryWriter bWrite = new BinaryWriter(File.Open(receivedPath +"/"+ fileName, FileMode.Append)); ;
/* Make a Binary stream writer to saving the receiving data from client. /
bWrite.Write(clientData, 4 + fileNameLen, receivedBytesLen - 4 - fileNameLen);
/* Read remain data (which is file content) and save it by using binary writer. */
curMsg = "Saving file...";
bWrite.Close();
clientSock.Close();
/* Close binary writer and client socket */
curMsg = "Reeived & Saved file; Server Stopped.";
Hope that it will solve your problem
Thanks
Annapurna
|
|
|
|
|
i have completely installed VS2008 and SQL Server management studio express,could i create a new database without SQL Server?
|
|
|
|
|
No (at least not an sql database)
|
|
|
|
|
Yes you can create a stand alone database, or a 'single file database'. You can do this with SQLite.
|
|
|
|
|
your answer is different from Tom Deketelaere's,so could you make it more clear?
|
|
|
|
|
Yes, it's really simple, you can make a database withouth an sql server. I myself are using SQLite for this, because I'm making applications which will run localy, if that's all you need a single file database is enough and I reccomend SQLite. SQLite is working as an dll, nothing more.
It works the same as the rest, you just execute some sql statements and you're done.
Just try and search google with 'C# SQLite', you'll find some information about it.
|
|
|
|
|
Interesting didn't know that, will have to give it a try.
I'm guessing tho that this is not usable with multiple connections?
|
|
|
|
|
What do you mean with multiple connections?
That there are 2 applications running which will make connections to one (the same) database?
I've never tried that.
OR
That there are 2 databases which will be accessed from 1 application?
This is possible.
OR
Something else :P?
|
|
|
|
|
Deresen wrote: What do you mean with multiple connections?
Deresen wrote: That there are 2 applications running which will make connections to one (the same) database?
I've never tried that.
That one
|
|
|
|
|
Lol, I guess it won't be possible. In order to do that, you have to connect twice to the database at the same time, if you manipulate some data at that point, the other connection won't be aware of that. But I guess that's with every database the same.
It works exactly the same as when you work with a server like sql express or something. But in stead of storing it via the sql server, you just store it directly (via a dll) into a file.
|
|
|
|
|
No, you need at least Sql Server Express, you can install it on your machine (some Visual Studio versions have it included) or on a development server.
There are database engines that don't require a server runtime installed, such as SqlServerCompact, but keep in mind that they are meant for local client databases, not for server-side database that require multiple concurrent connection from different clients.
|
|
|
|
|
yes,i have installed SQL server management studio express ,but i don't know how to create a database.
|
|
|
|
|
IT depends what database you want to install - you need to have some program to run it. plus this is a c# forum and not a database forum. Try there for better answers!
|
|
|
|
|
I have used several code for email validation like
{string pattern=@"^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|" +
@"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z]" +
@"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";
System.Text.RegularExpressions.Match match =
Regex.Match(txtEmail.Text.Trim(), pattern, RegexOptions.IgnoreCase);
if(match.Success)
MessageBox.Show("Success");
else
MessageBox.Show("Fail");
}
// But it is not working .It gives a run time error like argument exception.Please help me out ASAP.
Thanks & Regards
Sayantan Basu.
|
|
|
|
|
string pattern = "^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|" +
"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z]" +
"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";
This?
I are troll
|
|
|
|
|
I have written following code but It is not displayed on the form
pictureBox1 = new System.Windows.Forms.PictureBox();
pictureBox1.Location = new Point(Wnd[18].Left + 2, Wnd[18].Top + 2);
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new System.Drawing.Size(80, 40);
pictureBox1.Image = new System.Drawing.Bitmap("c:\\bitmap1.bmp");
pictureBox1.Show();
pictureBox1.BringToFront();
what to do ?
thanks
|
|
|
|