|
JacquesDP wrote: I'll try changing the reference from the project to the compiled dll directly and hopefully that will help.
Scratch that one, tried it with the exact same result as referencing the project, works until the first build.
No matter how long he who laughs last laughs, he who laughs first has a head start!
|
|
|
|
|
Think I might have found the problem, I never read the warnings on the build failure, and saw the following warning being displayed.
The referenced assembly "XXX.dll" could not be resolved because it has a dependency on "System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. CallCentreMgrNS
Thanks.
----MODIFIED-----
Changed the targeted framework of my service from .NET Framework 4.0 Client Profile to .NET Framework 4.0 and no the project builds successfully
No matter how long he who laughs last laughs, he who laughs first has a head start!
modified on Tuesday, January 4, 2011 2:38 AM
|
|
|
|
|
I am try to read serial of bytes and if I find the first byte is 55 and the second is 55 I will try till , I receive CC CC as a terminal.
but my problem is : when i reading I can find 55 55 and this is not start like this sample of bytes.
55 55 03 0A 0C 28
AA AA 00 00
99 08 F1 00 00 0B 09 0D
AA AA 5F 00
99 1E 3F 48 56 41 30 31 31 32 34 31 4E 4E 20 20 30 31 30 20 20 20 20 01 00 00 00 00 00 0D
AA AA 17 08
99 1E 3F 48 56 41 30 37 31 32 34 32 4E 4E 20 20 30 37 30 20 20 20 20 07 00 00 00 00 00 0D
55 55 03 0A 0C 2A [synch message every 3 minuits]
AA AA 04 09
99 08 F1 80 00 0B 09 0D
AA AA 0E 09
99 08 F1 80 00 0B 09 0D
AA AA 05 0A
CC CC [end of section]
What I want to ignore the message which start with 55 55 with length equal 6 because it's not the start of current block.
and here's My code :
1- I am Calculate Number of Blocks.
2- Then Store each block.
Current code neglect some bytes but I am not able to reach where's the logic error.
Note : All bytes are stored in VopMessageDetails ArrayList and I am converted from Hex to Decimal so 55 Hex Will equal = 85 and CC =204
int NblockCounter = 0;
int prevBlockLengths = 0;
#region To Get Numbers Of Blocks
for (int i = 0; i < VopMessageDetails.Count; i++)
{
if (VopMessageDetails[i].ToString() == "204")
{
i++;
NblockCounter++;
}
}
#endregion
List<String>[] catchBlockBytesArray = new List<String>[NblockCounter];
int blockCounter = 0;
catchBlockBytesArray[blockCounter] = new List<string>();
#region Catch blocks where each block stored as a item in catchBlockBytesArray.
for (int i = 0; i < VopMessageDetails.Count; i++)
{
if (VopMessageDetails[0 + prevBlockLengths].ToString() == "85" & VopMessageDetails[1 + prevBlockLengths].ToString() == "85")
{
if (VopMessageDetails[i].ToString() != "204")
{
if (VopMessageDetails[i].ToString() == "55" & VopMessageDetails[i + 1].ToString() == "55")
{
i += 6;
}
else
{
catchBlockBytesArray[blockCounter].Add(VopMessageDetails[i].ToString());
}
}
else
{
prevBlockLengths = i + 2;
i++;
blockCounter++;
if (i != VopMessageDetails.Count - 1)
{
if (blockCounter < NblockCounter)
{
catchBlockBytesArray[blockCounter] = new List<string>();
}
}
}
}
}
#endregion
}
}
}
|
|
|
|
|
Oh dear.
Firstly, stop using magic numbers. Define these as constant byte values with sensible names and use them instead. It makes your code more readable, and easier to maintain.
private constant byte SequenceInto = 0x55;
Secondly, stop converting to strings!
if (VopMessageDetails[0 + prevBlockLengths].ToString() == "85" & VopMessageDetails[1 + prevBlockLengths].ToString() == "85")
instead use:
if (VopMessageDetails[0 + prevBlockLengths] == SequenceIntro & VopMessageDetails[1 + prevBlockLengths] == SequenceIntro)
You may find this solves your problem:
if (VopMessageDetails[0 + prevBlockLengths].ToString() == "85" & VopMessageDetails[1 + prevBlockLengths].ToString() == "85")
{
if (VopMessageDetails[i].ToString() != "204")
{
if (VopMessageDetails[i].ToString() == "55" & VopMessageDetails[i + 1].ToString() == "55")
Did you forget to do the hex conversion here?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Thanks for YOU , but you write the code as the same.
|
|
|
|
|
Yes. I did. It is a cut-and-paste section of your code with a likely error in in it.
When you rewrite your code to follow my two suggestions, you will get rid of the string comparisons in favour of constant based numeric comparisons. If you have only defined the values your are interested in, you can only use the correct values. That is one of the advantages of not using "magic numbers" in your code - it is harder to get it wrong.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Hi All
I am developing a website in C# using VS 2005, Is it possible to get
1) Visitor IP
2) Visitor Country
3) Visitor Browser Details
4) Visitor Logged Time
as email to my gmail account
Kind Regards
RK
|
|
|
|
|
You can store this data in a database and use an automated process, perhaps a SQL Job, to format and email it. There is nothing built-in that will do this if that's what you are asking.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Assumption: ASP.NET
You can get the first three from Request.Headers, but not the last.
The last is probably not possible, since everything is stateless and you can't tell when they leave unless there is a "log out" of some kind. If there is, then that's just a matter of doing a time difference between login and logout.
Emailing can be done with System.Net.Mail as long as you have an available SMTP server out there you can use.
|
|
|
|
|
E-mail seems like a terribly inefficient way to record that kind of data.
Try adding google analytics[^] to your site. It will give you way more than what you are looking for and probably take less time to add than some custom code for the short list you gave.
|
|
|
|
|
Hi,
I am using the open source provided at code project for SFTP. However it gives following error :
'Tamir.SharpSsh.jsch.Util' is inaccessible due to its protection level
Is Anyone aware of this error? How to resolve. Please help
|
|
|
|
|
If you got the code from an article, then there is a "new message" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.
Otherwise, we would need to see relevant code fragments to be specific. However, the error "inaccessible due to its protection level" normally means you are trying to access a private, protected or internal class, field, property or method from outside. Either change the protection level (carefully, restrictions are generally put there for a purpose), or reconsider what you are doing.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Typically the projects have some kind of "main class" which is meant for general use, and some "code behind classes" which are required by the main class, but the author did not think that they are used without the "main class". Depending on your specific needs, it can be quite appropriate to directly access such a "code behind class" or derive one of your classes from there. Simply change the "private"/"internal" label to "public" and recompile, but more important: do a lot of testing, because some further changes to that class may be required.
|
|
|
|
|
I want to change the font size of the Console but that is not easy. After googling, the WinAPI SetCurrentConsoleFontEx() located in the kernel32.dll should do the trix. This is my code:
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
[StructLayout(LayoutKind.Sequential)]
public struct COORD
{
public short X;
public short Y;
}
[StructLayout(LayoutKind.Sequential)]
public struct CONSOLE_FONT_INFO_EX
{
public uint cbSize;
public uint nFont;
public COORD dwFontSize;
public ushort FontFamily;
public ushort FontWeight;
string FaceName;
}
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool SetCurrentConsoleFontEx(IntPtr ConsoleOutput, bool MaximumWindow, CONSOLE_FONT_INFO_EX ConsoleCurrentFontEx);
static void Main(string[] args)
{
CONSOLE_FONT_INFO_EX font = new CONSOLE_FONT_INFO_EX();
}
}
}
My code is is in the Main() method, all other code I have googled and pasted in.
The only thing I miss is how I shall instantiate the CONSOLE_FONT_INFO_EX struct?
I want the font to be 16 x 12. Some suggestions?
Some sites I used:
http://msdn.microsoft.com/en-us/library/ms686200%28VS.85%29.aspx[^]
http://msdn.microsoft.com/en-us/library/ms682069%28v=VS.85%29.aspx[^]
|
|
|
|
|
You shouldn't change it. Let the user use what he likes. I prefer 7x12 and I wouldn't want someone to change it on me.
|
|
|
|
|
Never tried it, but from the code you've posted...
COORD coord = new COORD();
coord.X = 12;
coord.Y = 16;
font.cbSize = coord;
|
|
|
|
|
Thanks! It actually worked.
|
|
|
|
|
I've been working with C# for about 6 months. This is the first time that a little searching has not resolved a problem for me. I'm trying to change the text of a label and update a progress bar in a loop that does some graphic calculations. The progress bar is working fine but the label text does not change until the loop has completed.
int nImgCnt = m_Parent.m_ImageList.Count - 1;
int nStatBarAdd = 1000 / nImgCnt;
for (int nIdx = 0; nIdx <= nImgCnt; nIdx++)
{
lblProg.Text = "Calculating minimum image size. Image " + (nIdx+1).ToString() + " of " + (nImgCnt + 1).ToString();
lblProg.Focus();
lblProg.Invalidate();
CurRC = getImageMinSize(m_Parent.m_ImageList[nIdx]);
if (CurRC.Width > MinRC.Width)
{
MinRC.Width = CurRC.Width;
MinRC.X = CurRC.X;
}
if (CurRC.Height > MinRC.Height)
{
MinRC.Height = CurRC.Height;
MinRC.Y = CurRC.Y;
}
prgBr.Value += nStatBarAdd;
}
If anyone can help me out with this I will really appreciate it!
|
|
|
|
|
it all depends where your code is sitting.
if it is in a GUI event handler (say a button click handler) then the main thread would be busy with your code, and hence the GUI would not respond to the things the user does, and a lot of things your code does. The right approach would be to use a separate thread, maybe a BackgroundWorker would be fine.
if it is not in a GUI event handler, hence already being executed by some other thread, then you are performing illegal cross-thread operations to GUI components. You might want to read this article[^].
All the above applies to all kinds of Controls; from what I've seen, I can't tell why the progress bar works better for you, I don't think it should the way things are.
|
|
|
|
|
Thanks for the quick response Luc!
Sorry, I should have pointed out this is in a button click event handler. I will trying doing the calculations in a BackgroundWorker, thanks again!
Edit:
I added a BackgroundWorker and life is good again. Thanks again Luc! I should have worked this one out for myself. I must be having a bad code day.
modified on Sunday, January 2, 2011 1:47 PM
|
|
|
|
|
You're welcome.
|
|
|
|
|
Luc Pattyn wrote: if it is not in a GUI event handler, hence already being executed by some other thread, then you are performing illegal cross-thread operations to GUI components. You might want to read this article[^].
But since he's not getting an exception, that can't be it. Unless there's more to it than I've experienced.
|
|
|
|
|
He didn't mention exceptions, so it was unclear whether any occurred or not. And a ThreadPool thread would happily swallow any exception he didn't handle explicitly: ThreadPool threads are built to survive no matter what.
|
|
|
|
|
I don't think their is a way of making this syntax work, but I think it would be quite nice to see this in C# .Net:
Instead of something on the lines of :
for(int i = 0; i <= 10; i++)myArray[i]...
We could just:
myArray[0 to 10]....
Even:
myArray[(n) 0 to length-1]n++;//which could increment each item in the array.
Just an idea although Linq may have some way already
|
|
|
|
|
Something wrong with foreach ?
foreach (MyElement me in myArray)
{
...
}
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|