Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

Julian Bucknall MSFT

@Julian Bucknall MSFT
About
Posts
58
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Detect cause of application memory leak
    J Julian Bucknall MSFT

    Search for "Application Profiler" on http://www.gotdotnet.com/community/usersamples/. It'll enable you to see what's going on with your managed heap. There are other similar tools out there; try googling for "managed heap profiler" or similar. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# csharp performance question

  • Array question
    J Julian Bucknall MSFT

    Arrays are reference types, therefore they're always allocated on the heap. An array of structs is no different -- it'll be on the heap -- however, in this case the memory block on the heap will be a contiguous series of Data structs, one after the other. All that the "new Data()" calls are doing is initializing the various elements of the array. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# question csharp c++ data-structures

  • IsInRole
    J Julian Bucknall MSFT

    How about:

    bool isDishWasher = principal.IsInRole("DishWasher");

    Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# question

  • Encryption/Decryption problem
    J Julian Bucknall MSFT

    Just a quick reply to your final question (I'm afraid I don't have time at the moment to figure out your code): SSL was designed to protect against man-in-the-middle attacks. Check out the specification of SSL to understand how it works (it involves the exchange of certificates for example). Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# security help data-structures cryptography

  • Writing hexadecimal to a file
    J Julian Bucknall MSFT

    What's happening is that, by default, the character is being written out in UTF-8. If you want to just write out the character as if it were a ushort, either cast it to a ushort, or change the encoding for the binary writer. By the way, writing out the ushort 0xABCD to a file will produce 0xCD 0xAB in that order. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# question

  • Info for switch statements
    J Julian Bucknall MSFT

    Then you have two choices, I suppose: either write out the 30 or so if-elseif lines, or, you take a step back and consider how to refactor the code into something cleaner. The switch statement won't help you, I'm afraid. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# question csharp

  • Info for switch statements
    J Julian Bucknall MSFT

    No, I'm afraid you can't do that with C#. The expressions in the case labels must be constant since they're evaluated at compile-time (for speed at run-time). To do what you want to do, you'd use a structure like

    if (firstCondition) {
    // do stuff
    }
    else if (secondCondition) {
    // do some other stuff
    }
    else {
    // otherwise if all fails do this
    }

    Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# question csharp

  • BinaryWriter/BinaryReader Portability
    J Julian Bucknall MSFT

    Andrew I'm sorry, I see I wasn't being explicit enough . Any stream written with any existing BinaryWriter can be read by any existing BinaryReader. I can even confirm that fact with Whidbey's BinaryReader and Writer (that is, with .NET Framework 2.0). If it didn't then it's a bug. (So the 3D matrix of 1.0, 1.1, 2.0 frameworks, for the two layers of writers and reader combinations has ticks in every cell). That's the statement about Microsoft's .NET Framework. I know nothing about the Mono project (apart from what it is, of course). I have no idea whether their BinaryReader would always work with a stream createed with BinaryWriter. Similarly I don't know if a stream written by Mono's BinaryWriter would be readable with MS's BinaryReader. However, I would *guess* that the Mono people would have taken endianness into account when they were writing their reader and writer. Now, as to the future (beyond Whidbey): it would make sense for the .NET Framework team to make sure that BinaryReader and BinaryWriter can continue to work as before. Why? Because the ResourceManager uses BinaryReaders and Writers internally. And that would be bad if Visual Studio .NET X (for X>2) couldn't read resource files from existing projects. Also, the format used by BinaryWriter is very, very simple and easily reverse engineered. There's no wierdo enums or class names being put in there or stuff like that. An int is written out as 4 bytes, a double as 8, etc, etc. So, although neither I nor anyone else can really tell you what would happen five years down the road, I wouldn't worry about it. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# csharp tutorial question

  • BinaryWriter/BinaryReader Portability
    J Julian Bucknall MSFT

    In answer to your primary question, BinaryReader will read streams created by BinaryWriter correctly. Your question about endianness is meaningless at the present time because .NET only runs on Intel CPUs and hence you don't have to worry about it. Once Microsoft target .NET for other CPUs then, yes, the .NET Frameowrk team will have to worry about how the stream is created and used between different endian CPUs. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# csharp tutorial question

  • C# switch case style
    J Julian Bucknall MSFT

    Ah ha! You're reading the "simplified" pages and I'm not surprised that you found ambiguity. Personally I tend to go to the authoritative source, the C# Language Reference. Here you see that a switch statement consists of "switch" followed by an expression in parentheses followed by a switch block a switch block consists of 0 or more switch sections, the whole wrapped in braces a switch section consists of one or more switch labels followed by a list of statements a switch label is either "case" followed by a constant expression followed by colon, or "default" followed by colon. It is the statement list that cannot "fall through." (In fact, it's stated as "the end point of a statement list cannot be reachable," by which it means that you cannot get to the point just after the last statement in the statement list. In other words, the last statement in the list must be a "jump" type statement: break, goto, throw, etc.) Hence, , you can have code that lokos like this: switch (foo) { case 1: case 2: DoSomething(); break; ... } As to the error message, I agree that it could be a little misleading, although it does correctly talk about the last switch label in the (possible) list of labels. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# csharp c++ css debugging json

  • C# switch case style
    J Julian Bucknall MSFT

    I don't understand. Your example of stacking up case labels does compile in C#. Here's a small example:

      Random r = new Random();
      switch (r.Next(10)) {
        case 1:
          Console.WriteLine("It's one");
          break;
        case 2:
        case 3: 
        case 5:
        case 7:
          Console.WriteLine("It's prime");
          break;
        default:
          Console.WriteLine("It's composite");
          break;
      }
    

    Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# csharp c++ css debugging json

  • Freeze form when it removing and reloading ctls
    J Julian Bucknall MSFT

    Use the form's SuspendLayout() and ResumeLayout() methods. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# design tutorial question

  • mp3 calculations
    J Julian Bucknall MSFT

    Since the MP3 music format is copyrighted, I would guess that you'd have to purchase a license to the format. That's why you're not getting any hits. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# help tutorial question

  • mp3 calculations
    J Julian Bucknall MSFT

    If I have this kind of question, I use Google and do a little searching. After a couple of minutes I found this on CodeProject itself http://www.codeproject.com/useritems/mp3fileinfo.asp Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# help tutorial question

  • XML transfer
    J Julian Bucknall MSFT

    I would suspect that something else is going on since that code should work. It's not as if the operating system treats XML files differently than other files when copying them. I'd play around a little to try and discover what's occurring. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# xml help question

  • convert ASCII into char
    J Julian Bucknall MSFT

    char MyChar = (char) someIntValue; Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# tutorial question

  • Help: Object reference not set to an instance of an object.
    J Julian Bucknall MSFT

    Well, I would guess that, since you only create the swStats member when cf.buffCount is true, cf.buffCount is false. Your best bet is to use the debugger to trace through your application. Check that swStats is being created properly, and if it is what else is happening as your app runs. Also, I would define a new class that encapsulates the "create a filestream, create a stream writer" code. You're replicating it several times. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# csharp com sysadmin help

  • Using postmessage to interoperate?
    J Julian Bucknall MSFT

    Unless I'm missing something, just call PerformClick():

    private void button1_Click(object sender, System.EventArgs e) {
    BusinessRules.PerformClick();
    }

    Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# c++ help question

  • Accessing Over A NETWORK
    J Julian Bucknall MSFT

    1. Create a share on the target system, and use two FileStreams (one for a file on the local system, the other for a file on the target system) to copy the data over. 2. Use sockets and have a sending application on the source system and a receiving application on the target system. Obviously the target app has to be installed and running before this will work. 3. Use .NET Remoting instead of sockets. Again the target app needs to be installed in the target system. I'm sure that there are other ways, but that'll get you started. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# question sysadmin help

  • Holding ArrayLists in an ArrayList
    J Julian Bucknall MSFT

    You're just copying references around. When you write

    ALSendedList=ALSendedL;

    you're merely copying the reference to the array list, you are not copying the array list itself. You need to think about copying the items in the array list instead. Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

    C# help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups