I found Reflector...thanks :) Wow, this might just do the trick. It's definitely a good start for me to compare my 1.3 code to what reflector gleens from 1.5! Matter of fact, what I'm looking at is pretty scary! I can't believe this much of my actual code can be disassembled from a release version of software! On the one hand maybe I'm lucky I'm using .NET but on the other hand, I'm not very crazy about sending out released versions of software that can be so easily reverse-engineered either! FWIW, I still haven't been able to figure out how this happened folks and as I said earlier, I'm not perfect, but I have been programming for a lot of years. If this could happen to me, it can happen to you! So back up often and don't learn the hard way like I did that VS might just decide to dump all your changes on you! Thanks again Scott, this was definitely a help.
Phil C
Posts
-
OMG, I am hosed...Lost changes! ? -
OMG, I am hosed...Lost changes! ?OK, I'm in a state of panic. I opened up a VS2003 (C# .NET) project I've been working on for several months now to start adding some features per users request. As I started entering my new methods/forms etc. I opened up my mainform in designer mode and to my horror realized that my main project has mysteriously reverted back to a version that's a month old. Two entire versions behind what it should be. Oh no says I, what's going on here? So I carefully tiptoe around and look at all the files in my project folder (time to abandon the little tweaks I've done in the last few minutes..I've halted everything right in the middle of an edit to figure out what's going on here) As a normal practice, I keep a set of comments at the top of my code (like most people) and sure enough, my comments only reflect things up to version 1.3 and no mention of version 1.4 and 1.5 changes. The really wierd part is (get this) in my bin folder, under debug and release are my version 1.5: exe files, pdb files, .resources file, .suo file and .csproj.user file! Each of those files is definitely version 1.5 because the date/time all jive with the version 1.5 I distributed to my customer, but my source file is definitely version 1.3 right down to the date/time on the file itself. Somehow what I'm missing is the source (insert panic cry here) I don't have any non-default setting in VS2003 and certainly don't remember doing anything dumb like discarding changes when I closed the solution so I'm baffled. FYI there isn't any third party source control involved or anything either, it's just a straight forward single computer/single developer development system. Has anyone else seen this behavior or have an idea of whether I'm totally screwed here? (Please no preaching about backups, yes I have a backup copy of the entire solution folder, but like most people I don't backup daily so that's not going to help me recover the last 15+ man hours of changes I've put in on this project). I'm mostly just baffled, how on earth could VS2003 have possibly compiled my files into version 1.5 objects and EXE's and somehow reverted back to version 1.3???? This seems impossible. Especially reverting back 2 versions. Oh whoa is me. crying in San Diego :((
-
C# equivalent to char * (well, System.IntPtr)??My exception fault was from a mistake on one of the other params - unrelated and I thought so when I first saw it. This did work Christian. It's a bit ugly, but at least all the ugly stuff is isolated inside my AVI class. I'd still be spinning my wheels if you hadn't stepped in. Thanks again. Now I can sleep :zzz: Phil
-
C# equivalent to char * (well, System.IntPtr)??OK, now that solution I definitely never would have come up with! It does compile anyway. I had to modify my prototype to to to a byte * instead of an System.Intptr the way I originally had it (not a big deal, although it would have been nice to keep all the pointer types consistent throughout this class...all the rest of the API Functions were done that way). Running the debugger does seem to show it working. The API function is throwing a nasty exception though, I'm not convinced it likes this byte pointer and I'm not sure how to browse memory to confirm this pointer is really pointing to my actual buffer of data. I'm assuming you wanted me to call: AviFileWriteData( ..., send, 2048); In other words "send" is the pointer? (obviously I've never used the fixed keyword before so this whole syntax is another new adventure). I should be able to figure it out from here anyway. At least I got the thing to compile. For me, that's 90% of it, I can usually tweak, adjust and debug from there. thanks Christian :) (P.S. this all still strikes me as a HUGE pain in the butt compared to the old C++ way, I'll never be convinced C# is better).
-
C# equivalent to char * (well, System.IntPtr)??Yup, you're right, it really doesn't matter what I pass it so long as it's a pointer to the string memory. But if I do it like you said then I have this myArray buffer that becomes difficult to print simple strings to. ie. then I'm left with the question: how to I format text into myArray? My approach was to have MyFunction() encapsulate all this ugliness and just make a simple c# call inside my main program like: string aviinfo = "[Timing] Frame Rate=250 Mark Frame=9"; PhilsFunction( aviinfo); Inside Philsfunction is the ugliness of converting this simple ordinary c# string into a padded 2048 byte area of memory and delivering the pointer to AVIWriteFileData() it's the conversion, padding and pointer part that has me stuck.
-
C# equivalent to char * (well, System.IntPtr)??Thanks Christian, I appreciate your attempt here, but I'm afraid I'm too lost. As I said to digitalKing above. I've literally spent the last 5 hours mired trying to pick apart the various methods to do this. I have no doubt, there's probably at least a dozen ways and I'll bet I've tried 30. I've been reading every book on my library on C# strings, pointers, how they work, what they don't do. Other classes, like StringBuilder, Marhsal, pinning, pinvoke My brain is mush and all these terms are now just jumbled into one big mess. What I need at this point is a simple example showing the csharp equivalent of the code I provided. FTR, the actual API function I'm using is AVIFileWriteData() and I've also googled it and searched out every possible example, but that function is so rarely used (it writes ancillary information data into a AVI header) by anyone that nobody bothers to include it in their port of the AVI functions into .NET. Trust me, there is no example of this particular functions use in managed code, but I really didn't think it made any difference, all I'm trying to do is make a string then pad it up to 2048 characters (I won't go into why it needs to be 2048, it just does) and then give this function a pointer to the data. Why does this have to be so hard? regards, Phil
-
C# equivalent to char * (well, System.IntPtr)??I knew that question was coming, I tried to just focus on the problem and keep it simple. If it makes any difference (and I don't honestly know why it does) the full function is: AVIFileWriteData( IntPtr aviStream, Int32 ckid, IntPtr lpBuffer, Int32 cbBuffer); It's part of the SDK AVI functions located in AVIfile32.dll. The C++ header files and library are vfw.h and vfw32.lib if I were working in C++ (but I'm not) Basically I have already got all the other parameters of this function figured out because there are plenty of examples on how to port AVI functions to Csharp to work with. Sadly, no examples include this function and I need to use it so I'm tyring to bring it into the project. So, to restate the question, I need to deliver to this function a "pointer" (lpBuffer) to an area of memory that I need to be exactly 2048 bytes long. I'm going to be formatting that data something like: [Timing] Frame Rate=250 Mark Frame=9 Time at Mark Frame=0 .... and whatever of the 2048 sized buffer that's left over needs to be padded with zeroes. I did also look at the StringBuilder class. I read Petzold's whole chapter on strings and I've also been reading MSDN info on it for at least 5 hours now. I also checked through two other O reilly books I have in my library. Really, I'm not being a idiot, I've honestly tried to figure this out on my own before running for help. But I'm completely lost in the syntax of what I need to do. I have so many posibilities and options running through my head at this point I can't tell which combination of the 15 different ways will work. Just telling me to use the StringBuilder class really doesn't help at this point. I need a pointer, not the name of a class.
-
Output of Simple C Program ?You are breaking the rules. Do not do this. You say you understand arrays and indexes...then why do you insist on using a[3]? a[3] is pointing to an area of memory that is being used by another part of the program. It might point to the actual memory being used by int i, it might be pointing to something else. It all depends on how the compiler allocates memory on the stack and in what order you have declared your variables and it's going to change everytime you edit your program. You are not supposed to be using a[3] so don't use it! if you create your array: int a[2]; then you can go use a[0] and a[1], and that's it. Period, exclamation point.
-
how to save all frames from a video file as a jpeg imageMaybe I'm missing something here, but jpg files aren't made to store movies. The jpg file format is only able to store one frame of image data. You need to use another format, AVI, WMF, Quicktime, Realvideo, Tiff...if you want to store multiple frames. On the other hand, if you save each frame to a separate jpg file then it will work, but then you'll have to deal with all those jpg's and find or make a player that can play them back in sequence.
-
Class Bascis Question...Is that where all the leading underscores are coming from???? I've been wondering why I've been seeing them more and more lately. For the record: regarding ANSI specifications, ANSI.org and places like that. I'll be damned if i'm going to pay $291 so I can download a 2MB file of instructions telling me how I'm supposed to name my variables. If I feel like using m_blahblah...or mixedUpperLower...or lower local and Upper global or whatever then tough. I've been listening to this grand promise of making code portable for over 20 years now and I've lost count of how many times I've been told we're all doing it wrong. At least 5 times I've changed to suit some imaginary standard and guess what? As soon as the next new compiler comes out we're told we aren't doing it right and we spend countless hours converting our supposed "portable" code anyway. If you want to run along with ISO/IEC whatever, more power to you. Have fun and why not? There's nothing wrong with guidelines and doing things consistently (more to make everything readable than anything). I'll make you a bet that within the next 5 years you'll be programming in a completely different environment, there's a new way and leading underscores are suddenly wrong. I have history on my side.
-
Migration to C++.NETStephen Hewitt wrote:
When one hears how it works it almost impossible to believe it could compare to C++ in speed or memory consumption
I can appreciate the candor :) I admit, I get crusty at times. It's just that all too often people seem to feel that just because something is new (.NET, managed memory, etc.) it's automatically better. I'm not trying to say .NET and the managed memory model don't have a place and aren't wonderful for some applications. But in my world, which is generally standalone desktop programs that have no interaction with the internet, ASP, web pages, distributed SQL servers etc. etc. the extra layers of "stuff" do nothing but make things 10 times harder, slower and more complex. If things keep going the way they are I'll probably become one of those (gag) Linux gcc geeks. LOL. And I'll also be the first to admit that I don't always re-quote all the lingo, correctly. Anymore, the basic concepts of programming are all one big long techno-geek sentence that makes little sense to me. Sad when I think I really did have a pretty good grasp of all the compiling, linking, DLL's, libraries, includes, preprocessor directives, classes, pointers, heaps, stacks...and now I'm a idjut :wtf:
-
C# equivalent to char * (well, System.IntPtr)??OK, as usual I'm stuck in transition between my familiar C/C++ background and finding the C# equivalent. This is really probably first grade stuff, but I've been beating my head for the last hour, reading through my books, help and basic texts and I need to just give up and ask for help getting back on track. I'm importing a Win32 API function (because there is no .NET equivalent yet) that I need to call in my program. Basically this function requires a pointer. So I need to create a block of memory 2048 bytes long, manipulate it in a string fashion (set it to something) then give the Win32 API a pointer to the memory. If this were C++ I could bang this out in 2 seconds and be done with it.
void MyFunction( char *astring) { char chunk[2048]; if(strlen(astring) > 2048)//they gave me too much data, bail out return; memset(chunk, 0, 2048);//make sure my chunk starts with zeroes strcpy( chunk, astring);//copy the data into my chunk TheWin32APIFunc( (int *)chunk, 2048 );//the magic function //notice that it requires a int * but a typecast does the trick }
But this is not C++, I'm in C# managed memory land. c# strings aren't zero terminated, I can't change the length of a string once it's created and c# and .NET really don't want me touching the actual memory directly so just doing a typecast isn't very appreciated by my compiler either. Anyone feel like taking pity? TheWin32APIFunc is formatted/prototyped thusly: private static extern int TheWin32APIFunc( IntPtr data, Int32 datlen); so I need a System.IntPtr and a plain Int32 (I got the Int32 covered). Thanks in advance -- modified at 1:15 Sunday 7th May, 2006 -
Compute Speed of Download Algorithmmaybe things are happening faster than you think. Put a temporary label1.Text = String.Format("_movingAverage={0}", _movingAverage) statement to see what kind of values you are working with. ie. is it typically 0, 0, 3, 0, 3, 0, 3? or is it typically 35, 39, 31, 39...? What about adjust the SAMPLESIZE up, that have any effect? Tinker a little and use the debugger you'll get it :)
-
How to use maps in C# Desktop Applicationyou mean something like this??? http://www.codeproject.com/aspnet/LatLaysFlat-Part1.asp
-
Compute Speed of Download Algorithmwell now, I'm not going to do the whole thing for you. I don't know how you have it set up so it's a bit tough for me to guess. but assuming you have a function that gets called every time a 1k chunk is downloaded I'd do it this way: Forgive the lack of indenting, I never have figured out how to put tabs in these messages, I hit the tab key and my cursor jumps to the next block in the web page. I used spaces, but they don't make it either.
startdownload() { m_sumx = 0;//running sum of the moving average..initialize it m_numsamps = 3;//change to adjust sample size, otherwise just a fixed value } new1kblock()//this function gets called every time a 1k block arrives { int elapsedtime = whateveryouuse();//pretend it's in seconds, //I don't know what units you're dealing with, converting is up to you //m_sumx holds the sum of the last 3 values, first subtract 1/3 to keep // it from growing to infinity m_sumx -= m_sumx/m_numsamps; //then add the latest elapsed time m_sumx += elapsedtime; //ok, now sumx is again the sum of the last three values float dlspeed=0; if(m_sumx>0)//be careful to avoid divide by zero, it can happen dlspeed = 1024.0/(float)m_sumx/(float)m_numsamps; //in this example dlspeed is now a value representing how fast we // downloaded the last 3 1k chunks in bits/second. // Display it however you desire }
-
Hiding a data file from users1)From what you described as your requirements I'd do A and B, yes. 2)That depends on what you anticipate the reason for the tempering. I'd probably start out with a messagebox to the user if you detect something wrong. something like: The database appears to have been changed or corrupted since the program was last run. Rebuilding Database, MB_OKCANCEL This way, the user at least has an option and has been warned that he may have completely screwed things up when he fooled around with your file. As I said, if he's sophisticated and determined enough to set the read-only attribute to false, then edit the file and finally to ignore the warning message you gave him, there isn't much you can do to stop him and there may be a legitimate reason for him to do it so you can only do so much. 3) Yeah, you're right, I think there is some permission thing that XP has. OK fine, don't put it in Windows\System, but I think there's another separate "Application Data" folder somewhere that's been designated for this type of use. You should be able to find a place, just putting the copy in a completely different folder goes a long way to making thngs more secure both from a tampering issue and crash-proofing. 4) I think someone else already answered this, yes there are ways. Personally I wouldn't bother. You mentioned that your data file can get fairly large. Whatever you do to encrypt/decrypt it will cause things to slow down, introduce bugs and will probably have a lot of other drawbacks too. ie. what if YOU want to edit the file to check for bugs, problems during development? If the thing is unreadable you are only making things harder on yourself. On the other hand, if you really really don't want anyone to see what's inside (prevent unwanted reverse engineering for example) then maybe it's worth all the extra time and trouble. This one is really something only you can answer. Good luck :)
-
Migration to C++.NETStephen Hewitt wrote:
I'm no .NET fan but there are lots of things you say which simply aren't true: Phil C wrote: a "interpreted intermediate language". MSIL is not interpreted; it is compiled. There are two main differences between typical compiled languages and .NET:
Hmm, well you are exactly correct. You have a much MUCH better command of the various details of it all than I do including the proper terms and how it's separated out. However, I do know this for a dead on fact. I've now ported many of my old C++ workhorse functions over to .NET and the result is a program that runs many times slower (for whatever reason). And yes, you can do pointers, you're right again. I've been forced to do all that many times now, but it's a huge pain and becomes even worse if you are trying to work with third party libraries some in managed and some with unsafe form because you have to carve out sections that are "unsafe". The pinning of object also does work and add to that the Marshal class to get access to managed memory objects...they did give us that. But all of it still adds up to training wheels to the Ferarri in my opinion. You see, my area is dealing with and managing various image data. Doing automated inspection, manipulating images from cameras, framegrabbers and looking for defects or whatnot. My programs spend a lot of time doing millions of calculations on big chunks of data. I've been recently forced to use .NET because my hardware has shipped with .NET libraries and I've come face to face with a lot of hard realities of how well/poorly the whole .NET scheme works under my conditions. The old "unsafe" C++ unleashed the true horsepower of the CPU to zip around huge amounts of data, deal with pixels on a byte by byte basis, convert from 8 to 10 to 16 to 24 bits/pixel with ease by using several differnt types of pointers into the same memory area, etc. etc. etc. I could spend the rest of the day showing examples of hundreds and hundreds of lines of patches I've had to make to what once upon a time was nice clean code. In conclusion I'll quote Jesse Liberty in the O'Reilly book - Programming C#:
While it is possible to program in .NET with C++, it isn't easy or natural. Frankly, having worked for ten years as a C++ programmer and written a dozen books on the subject, I'd rather have my teeth drilled than work with managed C++.
I couldn't agree with him more.
-
VS2003 version of Add Windows Message Handler?As I continue my struggle to move from VC6 to VCsharp2003 I'm often left with all kinds of longing for the old days. One of which is the VC6 Class Wizard and it's ability to just right click on my class and select "Add Windows Message Handler" For instance, I have a RichTextBox control on my form and I need to add a OnGetFocus() handler to it in an attempt to make it automatically select the entire content of Text (you know, the way most forms work by default so when you tab from one field to the next you can overwrite old values by typing instead of having to delete them one letter at a time first). Anyway, I still haven't found the equivalent (if there is one) method in VS2003 to get a complete list of all the possible EventHandlers for a given control (like OnMouseDown, OnMouseUp, OnSelect...etc. etc.) and pick one from the list. All I've been able to come up with is to manually create the handler function by hand, then add the handler to the control by hand. Did this simple One Click functionality never make it from VC6 into VC2003 or did I miss some chapter in a book somewhere?
-
RichTextBox - AutoWordSelection??? no effectHmmm, well you are right, I guess I did misread what ths property was for. However, setting this property to true still has no effect. I have two controls on a form side by side. One with autoword select = true and one with autoselect=false. As far as I can tell both controls behave the exact same way. I can select a single letter, a couple letters, or the entire word with my mouse. But as usual I'm getting distracted from the goal I was tyring to achieve which was selecting the text as soon as the control gain focus. It's just frustrating when you try and experiment and various properties seem to have no effect. About the only thing I can conclude is perhaps if the RichTextBox is stretched out and contains a sentence rather than a single word it works. I don't know *sigh*
-
Hiding a data file from usersAfter reading all this, I think you should: A) Just make the File Read-Only after your program closes it. This will keep a casual user from accidently damaging editing it. If they actually reset the read-only flag and then edit it, then they are determined and sophisticated enough that they can damage anything if they want to. B) Make a backup copy of the file when you close your program. Put it in the Windows/System folder or somewhere similar. Yes, this will take up an additional 800 MB of extra data, but if you're worried about data integrity and safety there really is no substitute for making a backup and HD space is cheap. When your program starts back up, check the data file against the copy, if you see any differences then you know someones been messing with it and can take action. I never cared much for trying to use Hidden files. I tried it a couple times in the past, and inevitably got a tech support call later and when I needed them to go look for, find and tell me something about that hidden file I had a heck of a time explaining to them how to "unhide" that file. (imagine a 5 second question over the phone "You're out of disk space? What's the size of the MYDATA.DAT file?" becoming a 30 minute long lesson in Windows File attributes and how to change them) Good luck, don't forget...KISS.