|
I'm writing a network sniffer in C# on Windows XP SP2 using VS 2005 and .NET 2.0, and apparently with SP2 Microsoft has disabled the ability to create Raw Sockets.
Does anybody know if there is a workaround so that Raw Sockets
will work? Other than going to a different OS?
Thx,
Tom
|
|
|
|
|
I'm just off the wikipedia site, reading on the concept of CLI, bytecode, JIT, Managed C++, etc. It jdawns on me that Microsoft's .NET Framework( still a key part of VS 2005)makes C++ no longer a precompiled Lan tool anymore! The C++ code is precompiled by .NET engine to bytecode, which is transmitted to the user, then translated into machine code by .NET virtual machine on the users's computer, just before runtime. (Just In Time-- JIT)
This is exactly like what Java does. So .NET Framework makes C++ like Java?
Here is my question, if .NET Framework makes C++ portable now, why bother with C#? to create web, ADO.NET, and ASP.NET applycations?
Can I stay with C++ to creat a powerful ASP.Net apps? Do you have weblinks talking about this subject?
Thanks
|
|
|
|
|
Essentially, managed C++, C#, J# and VB.NET all get compiled into MSIL (Microsoft Intermediary Language, if i remember correctly), so anything you can do in one language, you can call/re-write in another.
However, certain features of C++'s syntax make this harder than in C#, so I would advise learning the syntax of C#.
|
|
|
|
|
There are two flavors of C++ now. The normal unmanaged C++ that you've always had, still compiles to native code. And the Managed C++ variety, that compiles to MSIL or sometimes sections in native and sections in MSIL.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
larryfran wrote: why bother with C#? to create web, ADO.NET, and ASP.NET applycations?
Because it's a damn site easier!
class="FQ">larryfran wrote: Can I stay with C++ to creat a powerful ASP.Net apps?
As far as I'm aware there is no support for creating ASP.NET apps. in C++. Thre certainly isn't in the IDE. Though in theory there's no reason why you shouldn't be able to.
Kevin
|
|
|
|
|
Hello,
I have a C# interface with a method carrying C# structs(inherted from System.ValueType whose base class is System.Object). I implemented this interface in MC++ adapter class. Pasting the sample code below:
eg:
//C# interface definition:
public interface ISrv
{
void Ping(PingIn aPing_in, ref PingOut aPing_out);
}
[StructLayout(LayoutKind.Sequential)]
[Serializable]
[Guid("C6497AEF-1839-45bd-AFAC-E533D7A03225")]
public struct PingIn
{
public Int32 flag;
public Guid lockId;
}
[StructLayout(LayoutKind.Sequential)]
[Serializable]
[Guid("B6BC3BEB-2FA2-45c6-B64A-434CE00F6A55")]
public struct PingOut
{
public Int32 status;
public Int32 lockStatus;
public Int32 nFailures;
[MarshalAs(UnmanagedType.SafeArray,SafeArraySubType=VarEnum.VT_I4)]
public Int32[] list;
public Int32 state;
public UInt32 errMsgId;
}
//MC++ class implementing ISrv interface
public __gc class AimAdapter: public ISrv
{
///c'tor
:
:
:
void Ping( [In] nsIAimServer::PingIn aPing_in,
[In,Out] nsIAimServer::PingOut* aPing_out)
{
}
:
:
:
:
};
When tried to use aPing_out in Marshal:;StructureToPtr() to convert to IntPtr, I received compilation error for casting. For some reason aPing_out lost its connectivity to System.ValueType (whose base class is System.Object). Is there a special way to maintain this connecitivity while implementing C# interface in MC++? Can you please clarify?
-- modified at 16:45 Tuesday 24th January, 2006
|
|
|
|
|
I've got a list of ~1500 items that I am putting into a ListView. Originally I was doing it in the main UI thread but it "freezes" the application for a few seconds. So I tried moving it to a BackgroundWorker, but the main UI thread still gets bogged down. In my ProgressChanged event handler I added Sleep(10), as a few examples suggest. The good news is that it works; the bad news is that it makes the operation take an order of magnitude longer. What can I do to speed this up?
private void fillListView(IList list)
{
this.listView.Items.Clear();
this.listView.BeginUpdate();
this.progressBar.Visible = true;
this.backgroundWorker.RunWorkerAsync(list);
}
private void backgroundWorker_DoWork(System.Object sender, System.ComponentModel.DoWorkEventArgs e)
{
System.ComponentModel.BackgroundWorker worker = sender as System.ComponentModel.BackgroundWorker;
IList list = (IList)e.Argument;
for(System.Int32 i = 0; i < list.Count; i++)
{
System.Windows.Forms.ListViewItem item = getListViewItem(list[i]);
System.Threading.Thread.Sleep(10);
System.Int32 progress = (System.Int32)System.Math.Ceiling((System.Single)(i + 1) / (System.Single)(list.Count) * 100.0f);
worker.ReportProgress(progress, item);
}
}
private void backgroundWorker_ProgressChanged(System.Object sender, System.ComponentModel.ProgressChangedEventArgs e)
{
System.Windows.Forms.ListViewItem item = (System.Windows.Forms.ListViewItem)e.UserState;
this.listView.Items.Add(item);
this.progressBar.Value = e.ProgressPercentage;
}
private void backgroundWorker_RunWorkerCompleted(System.Object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
{
this.progressBar.Visible = false;
this.listView.EndUpdate();
}
|
|
|
|
|
Try turning off screen updates for that control before you add the items and then turn them on again when you are done.
Take a look into SuspendLayout and ResumeLayout.
The bottom line is that you have to trade off SOMETHING. Suspend and Resume stop you form seeing the updates as the data is put in. Adding the sleep allows you to process the main thread and see UI updates but as you see causes the process to take longer.
Better, Faster, Cheaper, Pick two. You can't have it all. Maybe look into how you can load less items. Do you really need all 1500?
Maybe consider doing something like putting them into a local dataset and then binding to that instead of writing directly to the control.
Maybe write some entries then wait for the user to scroll down closer to the end and then add more as needed at that time.
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
My Blog[^]
|
|
|
|
|
Well ListView has BeginUpdate() and EndUpdate() to temporarily disable paiting the control. I am already using these, and adding SuspendLayout() and ResumeLayout() didn't change anything. Perhaps I should have mentioned that I'm using the ListView in Details view with multiple columns; the ListView does not support complex databinding out of the box and all the examples I've seen use the same method to fill the ListView that I am using so that's not really any help. I think I will look into Virtual mode. Thanks.
|
|
|
|
|
The UI can only be updated in the main thread, so a BackgroundWorker doesn't help.
Use listView.VirtualMode, then you can display items without having to add them to the list.
|
|
|
|
|
I am using the BackgroundWorker mainly to get progress updates. It also prevents the UI thread from freezing (i.e. I can drag the window or resize it, click menu items, etc). I agree that using a BackgroundWorker shouldn't help, but for some reason it does. Anyway, I am going to look into using Virtual mode.
|
|
|
|
|
I tried the virtual mode but that led to all sorts of problems. I need to have the listview sorted and be able to remove items from the listview; both are non-trivial in virtual mode (sorting may not even be possible). I have comprimised and split the 1500 items into smaller sets and just entirely forego virtual mode and threading altogether. The slight delay to add ~200-300 items is acceptable.
|
|
|
|
|
You are using sorting? There is some bug/misfeature in the .NET Framework code that makes sorting very slow - when using a custom Sorter class (not just Sorted=true), .NET completely re-sorts everything after every insertion. You should create an array with the ListViewItems, sort the array, and then add it to the (unsorted) listview with a single AddRange call.
|
|
|
|
|
The other option would be to add all the items and then attach the sorter and do the sort at the end. I've done this in an app that had issues (don't recall what offhand) with leaving the comparitor permantly attached. I *think* they were related to using different rules based on the type in the column in question.
|
|
|
|
|
Aha! That's what it was. I figured that using BeginUpdate() would disable sorting the items until I called EndUpdate(), but apparently not. Now I just set the sorter to null before filling it, then set the sorter to my sorter after filling it, and it is DRAMATICALLY improved (takes less than a second). Thank you both!
-- modified at 13:34 Wednesday 25th January, 2006
|
|
|
|
|
Greetings
Lately I've been using the "System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName" as a language code for my project(s) where I have text translated.
The system I'm working up against uses for instance "gb" as english langauge code for translated texts whereas "us" covers american.
However TwoLetterISOLanguageName gives out "en" for both, making it impossible for me to distinquish between the two.
I could use other variables in the culture object but these all gives out longer then 2 characters, and not the result I wanted, which means that I'll have to use session variables to hold langauge code (which I find bad because this culture object is already there).
So - is there anyway I can connect for instance the variable "gb" with en-GB culture object withouth having to create my own new culture object for each culture I want to use?
(yes, I could use substring :p - but that wouldn't help much because then I need to know when to do substring etc and that kind of voids the reason I'm starting to use culture )
Regards.
---------------------------
127.0.0.1 - Sweet 127.0.0.1
|
|
|
|
|
Derive a class from CultureInfo adding your own code as a new property. You will obviously need to map the constructor as well.
Remember this is a hack, and you should migrate to RFC3066 as soon as possible (or rather, the modified RFC3066 used in the .NET framework as the real RFC3066 can't handle Chinese correctly). You might still run into problems with Spanish though.
|
|
|
|
|
Anyone has a good example how to call InvokeMember when you are calling a COM-server with late bindning and the you have a [out] parameter?
Im working in C#... but VB .NET will do fine as well.
Ex:
virtual /* [id] */ HRESULT STDMETHODCALLTYPE bcGetUserRoles(
/* [out] */ VARIANT *pvarrUserRoles,
/* [retval][out] */ INT *piRetval) = 0;
How do you retrieve the pvarrUserRoles ?
Thanks in advance!
/T
-- modified at 2:50 Tuesday 24th January, 2006
|
|
|
|
|
Anyone know if there are (or will be) posters available for .Net 2005 like there are for 2003?
"My dog worries about the economy. Alpo is up to 99 cents a can. That's almost seven dollars in dog money" - Wacky humour found in a business magazine
|
|
|
|
|
Jack,
Have you tried contacting Microsoft?
Paul
|
|
|
|
|
We just moved to Visual Studio 2005, and previously we were using a manifest file to make our vc6 apps look ala Windows Xp theme.
1. First of all, what the heck is this manifest file? Does it really do anything useful?
2. What is the correct way to use it for apps created in vc2005?
3. Is there any way to get menus to look half decent without integrating one of the xp-style menu implementations found here in CodeProject?
Cheers and thanks!
swine
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Hello All,
I would like to use the solid dots that one encounters when logging onto Windows XP. How can I make this happen with a textbox that will be password protected? I've tried setting PasswordChar to * and * is what I get. Any help would be groovy. I'd probably just be able to google it, but I'd like to see what fellow CPians have to say
Thanks in advanced,
Paul
|
|
|
|
|
Have you tried changing the font to one with those dots in it and changing the Password Character to that dot? Open Character Map to find one.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave,
Thanks for the post. I found that Symbol font has a dot and has the value of \xB7. Very simple solution to something I thought was going to be complicated. Wish everything could be like this.
Thanks again,
Paul
|
|
|
|
|
Hmm..."checks ASCII charrt" - there is a black dot character - ascii is
DEC: 007
HEX: 07
Hope that helps
|
|
|
|