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
C

Chadwick Posey

@Chadwick Posey
About
Posts
26
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Does this language feature seem strange to anyone else?
    C Chadwick Posey

    I always thought this part of C# was kind of hokey, but after reporting it to Microsoft as a bug (derp), and it getting escalated to the framework team, it was revealed, it is part of the spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf[^] (The C# Specification), page 136 states: "An implicit enumeration conversion permits the decimal-integer-literal 0 to be converted to any enum-type." So the short answer is, it's in the spec. The long answer is (from Habib, here: http://stackoverflow.com/questions/14950750/why-switch-for-enum-accepts-implicit-conversion-to-0-but-no-for-any-other-intege[^]) At compile time 0 is known as the default value for an enum. No other value is explicitly known, and that is why no other value is allowed to be substituted. In fact, you can try some sample code out for yourself:

    class Program
    {
        enum Direction { left = 1, right = 2 }
    
        static void Main(string\[\] args)
        {
            Direction d = 0;
    
            Console.WriteLine("Direction: " + Enum.GetName(typeof(Direction),d));
    
            Console.ReadLine();
        }
    }
    

    Note that even though we've explicitly excluded 0 from our example, the code still compiles and works happily returning "" for the label corresponding to 0. It's always going to be there, and that's why 0 is allowed an implicit cast.

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn't ya like to be a developer too?

    The Lounge csharp database design help question

  • MIME Attachment Names containing Extended Characters Fails
    C Chadwick Posey

    For posterity, I'm including my findings here -- I believe it to be a bug with .NET, and have submitted as such to connect here: Microsoft Connect[^] It appears to stem from the way encoded headers are wrapped. if the filename length exceeds a certain number of bytes when encoded, the system double-encodes the filename for some reason... Odd... Hope they fix it... if anyone can please test the sample code I uploaded to Microsoft and verify it fails, I would greatly appreciate the help. ================================================= Update: We worked around the issue by zipping the file using ASCII characters. It has been patched in a .NET 4 Framework Hotfix available here: Microsoft Connect Download[^]

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn't ya like to be a developer too?

    C# tutorial com help question

  • MIME Attachment Names containing Extended Characters Fails
    C Chadwick Posey

    I will definitely look into that... optimally I'd like to send the bare file with the name intact, but this will be my last resort option I think. I figured even if the filename length was 255 with single byte characters, that it would support 128 or so with double byte characters, but it is significantly less... I think at 36 characters (72 bytes) it starts exhibiting the strange behavior... I'm wondering if the whole MIME-wrapping thing (I think the mime source is limited to 75 characters wide or something) is throwing something off if it is in UTF-8. Thanks Chadwick

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn't ya like to be a developer too?

    C# tutorial com help question

  • MIME Attachment Names containing Extended Characters Fails
    C Chadwick Posey

    Hello all, While working on a project that emails files with international filenames, I've come across an unusual issue. if I attach with a US-ASCII filename only, I can get better than 200 characters long without errors. If I include an extended character, it encodes in UTF-8 and the length before it gets funky is very small (< 40 characters). To define funky.. here's an example filename after it goes bad: =utf-8BSU5GT1JNw4FUSUNBX0ltcGFjdF9Bc3Nl it looks like UTF8 encoded string with a UTF-8 decoding instruction or a mime boundary... not sure which. Has anyone seen this before -- and what are the rules / limitations of filenames -- I tried emailing the file by hand through outlook and it handles it, so I don't think it is a MIME specific limitation. Sample code:

    class Program
    {
    private const string DOMAIN = "foobar.com";
    private const string SMTPHOST = "mail." + DOMAIN;
    private const string FROM = "chadwick.posey@" + DOMAIN;
    private const string TO = FROM;

        static void Main(string\[\] args)
        {
            MailMessage msg = new MailMessage(FROM, TO, "Subject", "Body");
            
            string path = Path.GetTempPath();
            string name = "AAAAAA\_AAAAAAAAAAAA\_AAAAAAA\_AAAA - IIIIIII CCCCCCCCCC DD IIIIIIÁIIII\_20111018\_091327.pptx";
            
            File.WriteAllText(path + "\\\\" + name, "blah");
            Attachment att = new Attachment(path + "\\\\" + name, new ContentType("application/vnd.openxmlformats-officedocument.presentationml.presentation"));
    
            msg.Attachments.Add(att);
    
            SmtpClient client = new SmtpClient(SMTPHOST, 25);
            client.Send(msg);
        }
    }
    

    I've tried (so far) -- setting the encoding for the attachment.NameEncoding to UTF8 and UTF32, neither worked. Setting the ContentDisposition.FileName on the attachment fails because it is not using US-ASCII characters only. Any suggestions on how to get it to include the full filename with the accent / extended characters in tact? Thanks Chadwick

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn't ya like to be a developer too?

    C# tutorial com help question

  • If only we could harness the power of bitching on this forum...
    C Chadwick Posey

    Complaining about complaining about complaining... my head is beginning to hurt :wtf:

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn't ya like to be a developer too?

    The Lounge beta-testing help code-review

  • Managerial skills are more important or Technical skills
    C Chadwick Posey

    I would suggest reading Dale Carnegie's "How to Win Friends and Influence People". Therein lies the answer -- assuming you want "success", which, of course, is a relative thing. But the MOST successful people are not the most technical or the smartest, it is the people who have people skills.

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn't ya like to be a developer too?

    The Lounge question

  • User Experience Question
    C Chadwick Posey

    I would recommend something more like the roll-over titles here (not my design): http://www.joomlart.com/demo/#templates.joomlart.com/ja_teline_iii_v2[^] beside the blue rectangle are a series of "sub headlines" (The first one is about nutrition) that when rolled over, reveal the detail... something like this is almost trivial to do in jQuery I would think, but is still accessible.

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn't ya like to be a developer too?

    The Lounge question design tutorial announcement

  • Catch an Exception... then throw it?
    C Chadwick Posey

    doja93 wrote:

    I recognize that it is technically harmless

    Not really... rethrowing the exception with throw e; breaks the stack and you never get to see where the original exception was thrown. That said, I'm with what the others said earlier in the thread: It's a good opportunity to mentor someone before they get ruined by some jackaninny who doesn't understand proper exception handling.

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn't ya like to be a developer too?

    The Weird and The Wonderful csharp question

  • Considering starting a software project - anything like this exist?
    C Chadwick Posey

    I was going to say the same thing, but I had to read through all the posts to make sure someone else didn't come up with it yet... and lo and behold... last post... lol I should start from the end and go up! :)

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn't ya like to be a developer too?

    The Lounge csharp visual-studio c++ com help

  • Hello
    C Chadwick Posey

    In honor of Kevin Pollak[^]: I kick life square in the nuts.

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn't ya like to be a developer too?

    The Lounge question

  • Drag and Drop Into Word
    C Chadwick Posey

    Welp this is as close as I could figure out. You cannot do it directly in memory (as far as I can tell), but here is the code emulating something close to dragging and dropping a file from explorer into word: string[] files = new string[1]; files[0] = @"C:\someimage.jpg"; IDataObject d = new DataObject(); d.SetData(DataFormats.FileDrop, files); if (this.DoDragDrop(d, DragDropEffects.Copy) == DragDropEffects.Copy) { //your drop succeeded } Still cannot figure out why I cannot just drag and drop an image directly though.... would love to know what I could do differently.

    ============================= I'm a developer, he's a developer, she's a developer, we're developers, Wouldn't ya like to be a developer too?

    Windows Forms com graphics help question

  • Drag and Drop Into Word
    C Chadwick Posey

    I have all the code necessary (I think) to perform a drag and drop into word... but I am having trouble with pictures... any kind of Bitmap or Image does not drop properly into word, it does something but then acts as if I didn't drop anything it understood.... However, the same code works for dragging and dropping onto other office apps (e.g. Excel and Powerpoint). The code looks like this: private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (_mouseIsDown) { IDataObject obj = new DataObject(DataFormats.Bitmap, pictureBox1.Image); this.DoDragDrop(obj, DragDropEffects.All); } } Any one have any idea what I'm doing wrong? (and for the record, I have tried it without using IDataObject as well, just directly putting the image into the data argument... oh and I also tried creating a "new Bitmap(pictureBox1.Image)" and putting that in the data argument... To no avail.... A) Can anyone reproduce the issue at hand B) Does anyone know what I'm doing wrong? Do I need to use OLE directly or something? Thanks Chadwick Posey

    ============================= I'm a developer, he's a developer, she's a developer, we're developers, Wouldn't ya like to be a developer too?

    Windows Forms com graphics help question

  • Bitmap + Clipboard + Transparency = Blue Background?
    C Chadwick Posey

    Hey folks, I think this is my first time asking a question here, so please go easy on me ;) I have an application wherein I render a transparent bitmap (to be specific -- a chart with a transparent background).... When I do, I then try to copy it to the clipboard using: bmp.Save(filename); // Save to FS Clipboard.SetImage(bmp); // Save to Clipboard Now if I open Excel, and click Paste (from the clipboard), I end up with a copy of my chart with this lovely blue background wherever the transparency color was. If I, instead, use Excel's Insert->Image->From File, the chart's transparency is preserved... (same bitmap as above, just one is saved to file system, the other is copied via clipboard) What gives? Am I copying the bitmap incorrectly, or is there something else I need to do to make copy and paste of transparent bitmaps a reality? (I have searched high and low, and nothing seems to answer this question... I have tried all kinds of things to resolve this on my own, even using MakeTransparent() (which has no effect, since the bitmap was already transparent to begin with (as evidenced by the Flags value on the bitmap being "2" which is hasTransparency)... I have tried converting the image, using color maps, using SetClipboardDataObject, converting to an HBITMAP object or whatever.... all kinds of things, nothing seems to avert this issue....) Thanks in Advance!

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?

    C# question graphics help

  • Pentagon report investigated lasers that put voices in your head
    C Chadwick Posey

    Just in case you guys hadn't seen this (who hasn't?)... The last of those -- heating of the human body -- did have a practical application and is in development -- The Active Denial System: You Tube Link[^] (I picked this one because the intro was just too funny....The real "weapon" shows up at about 50ish seconds in)

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?

    The Lounge c++ html database com question

  • Help with SQL Server (NOT A programming question) [modified]
    C Chadwick Posey

    Dave Thomson wrote:

    I agree on all points although I'll add that SQL Server will use a whole byte for a bit field and so a dba might consider having only one bit field as wasteful or something. I think the original post stated char(1) so the end result would be comparable but using bit would allow for 7 more bit fields in the table without any row size increase but the same 7 extra char(1) would add 7 more bytes, no brainer for me. Personally I use bit for boolean every time.

    You are exactly right but it depends on using SQL 2005 (from the Books Online (BOL)):


    bit (Transact-SQL) "The Microsoft SQL Server 2005 Database Engine optimizes storage of bit columns. If there are 8 or less bit columns in a table, the columns are stored as 1 byte. If there are from 9 up to 16 bit columns, the columns are stored as 2 bytes, and so on. The string values TRUE and FALSE can be converted to bit values: TRUE is converted to 1 and FALSE is converted to 0."


    MS-SQL does no such optimization on char columns. My other thoughts on this are as follows:* Y and y and N and n may make sense to your DBA, but if you were to hire / contract someone who is non-English speaking to audit the data, it may well be that they would expect something else. A bit-field has no such barrier, a 1 is a 1, and a 0 is a 0.

    • If you want to search the table for all rows that match an intended value (true or false), it must do two comparisons (the Y and the y), forcing the SQL server to do more work.
    • Y and N only have meaning if given context, as you said before, no context is offered by a constraint buried in the server. If a column is defined as DropShipYN, maybe a Y and N would make sense, but what if the column was defined as DropShip -- Does Y stand for Yonkers? Its a bit contrived but a bit column has no context issues, you automatically know its either 1, 0, or null.
    • It may increase the size of your indexes. The reason for this is that you may be tempted to include the char field in a composite index, whereas a bit field cannot be included (BOL - CREATE INDEX).
    • Char, nchar, varchar, and nvarchar are collation dependent, bit is not, unnecessarily complicating replication and third-party database integration issues (BOL).
    • It hampers the use of OTS reporting packages, as you will likely need to do conversion from the char to a boolean for use with the tools built-in items (do the conv
    The Lounge csharp database wpf question sql-server

  • So it begins...
    C Chadwick Posey

    Isn't this sort of thing what Java is made for?!

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?

    The Lounge com question discussion

  • Web hosting hell - what to do? [modified]
    C Chadwick Posey

    I've used MaximumASP for quite some time, they have great shared boxes, as well as dedicated boxes, plus they have top tier technical support. They can set you up with just about any configuration you require. And like other decent services mentioned in this thread, that service and reliability doesn't come cheap. Their cheapest shared plan I think is $99 a month -- but its a virtual server and monitored very closely. A good overview of their services is here: http://www.maximumasp.com/solutions/virtuozzo/comparison.aspx[^]

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?

    The Lounge sales sysadmin hosting business regex

  • Article Worthy??
    C Chadwick Posey

    A nice tidbit that seems to be lacking the documentation is how to optimize the overlays... uncheck everything on the page except "Fixed Drives" and add C:\* to your exclude paths... then if your local checkout is C:\source, add C:\source\* to your includes That seems to be the 99% rule of how most people setup their systems... of course if you have multiple drives, include them all in the exclude paths, and only include bonafide source directories. I've been using Tortoise SVN v1.4.3 and v1.3.8 constantly for about 2 weeks each now, on different machines (and networks) with both SVN and WebDAV repositories, even over a VPN... and haven't had the first hiccup.

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?

    The Lounge tutorial collaboration beta-testing tools question

  • Compiler issue?
    C Chadwick Posey

    Yes, I got the same general response from MS... Section 13.1.3 of the ECMA standard states that the decimal-integer-literal 0 can be implicitly cast to an enum type. It does not, however, provide the same rationale as your MVP friend said. It definitely displays the stated behavior, because if you do int x = 0; then pass x as your parameter, it does the box properly. I kindof see the point in why the standard is the way it is now. I still think that it should at least generate some sort of level 4 warning or something... it is not like all of us have the time (or the brain space) to memorize the ECMA and C# 2.0 standards...especially one as esoteric as this.

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?

    C# help question

  • Compiler issue?
    C Chadwick Posey

    Now I know we're not crazy :) From Microsoft -- Thanks for your feedback. We have reproduced this bug on , and we are sending this bug to the appropriate group within the Visual Studio Product Team for triage and resolution. Thank you, Visual Studio Product Team. Posted by Microsoft on 3/22/2007 at 12:21 AM

    ============================= I'm a developer, he's a developer, she's a developer, Wouldn'tcha like to be a developer too?

    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