|
C#code:
Also when I'm using HttpWebRequest and HttpWebResponse, if I get a 404 the program chokes out and closes. I've been trying to use: code:
Thanks.
|
# ¿ Feb 7, 2012 20:24 |
|
|
# ¿ May 22, 2024 16:26 |
|
Ithaqua posted:[edit] Worked perfectly, thank you .
|
# ¿ Feb 7, 2012 21:21 |
|
I'm running into a bit of trouble with a multi-threaded program. I'm getting completely random results (+- 100) with this bit of code:code:
code:
Does anyone have an idea why countAllHits will end up being 9900 +-, when it should be 10,000 on the dot? It's totally screwing up my status update so I don't know when it's finished running e(clarify): finishedHits will be 10,000, countAllHits will not be 10,000. Nearly immediately after finishedHits is incremented, a new threadpool call is made, which nearly immediately increments countAllHits as well. Knyteguy fucked around with this message at 04:15 on Feb 16, 2012 |
# ¿ Feb 16, 2012 04:07 |
|
Eggnogium posted:Not too familiar with C# threading so I could be wrong, but I think you need to lock around "countAllHits++;". It seems like a single operation but it's actually several (loading the value, incrementing it, and storing it back), so if a thread gets interrupted in the middle of those three steps the value will end up being wonky. Thanks that did it I'll have to lock down the other vars as well, I'm sure that's been causing some issues that I just haven't noticed yet.
|
# ¿ Feb 16, 2012 04:24 |
|
Sedro posted:No offense but it looks like you're totally over your head. That code you posted is full of horrors. You should really learn the threading concepts instead of just sprinkling mutex locks everywhere. Thanks I'll take a look at that. I've also used a bit of Parallel.ForEach but the program actually ended up slowing down. Because this is my first 'real' program, I'm not very worried about anything other than it working (which it is, besides some thread issues). If you think this part is bad though, you would probably get a headache from my regex list parsing . However besides the Interlocked class, do you mind mentioning a few of these 'horrors' so I can see where I can improve? If you get a chance. Knyteguy fucked around with this message at 05:29 on Feb 16, 2012 |
# ¿ Feb 16, 2012 05:27 |
|
Sup Goons, I'm building a portfolio website of all my work because my job pays me $12.50 an hour 20 hours a week to program software, program web, design web, computer troubleshooting, and manage a website. So... I figured it might be time to move onto greener pastures Anyway while I figure out what position I might be applying for, I'm trying to clean up some of my slightly older program code to conform with better practices I've learned since. Going back, I would have written this top function buttonParseProcommD2M_Click to work with an unlimited amount of systems by using sender, but I didn't. Barring that, does anyone see anything that screams "oh poo poo this is terrible!"? It runs wonderfully daily in a commercial environment, but I would like to move up a tier in the programming business if possible. (This is just 2 functions I used as a code sample, not the entire program (obviously...)) Formatting got a little screwed up, and I had add some return characters to stop it from breaking tables. code:
Knyteguy fucked around with this message at 21:31 on Sep 25, 2012 |
# ¿ Sep 25, 2012 21:03 |
|
CapnAndy posted:You're doing a slightly strange mixture of using .Show() and .Hide() vs. directly setting .Visible, I don't see where you show the button after you hid it at the start of the click event, and for personal preference I'd set .Enabled to false rather than hiding the button; greying it out is more visually understandable as "okay, you can still use this, just not now" whereas things disappearing when you click them can be a little startling. That's a great idea, I think I'll implement that thanks .
|
# ¿ Sep 25, 2012 21:28 |
|
Ithaqua posted:Yes. Do not submit this code to a potential employer as it is. Thanks I'll make some changes - I want it to be as well done as possible. MVC (this is MVC related right?) is something I've only briefly touched upon. It sounds like I should probably do some more reading on it and understand what it actually represents, and how to implement it correctly. Unit tests I've never done. I just found a basic tutorial for VS/C# so I'll look into this. Naming conventions... I'll read what the standard is. I'm certain I can learn this fairly quickly. Question: Does your application even update the progress bar visually? You're blocking the UI thread as far as I can tell. It does on this sample code. It doesn't in a second part of the program (which I've been meaning to fix for my co-worker in an update) that also uses a progress bar. I've gotten my feet wet with multi-threading/task parallel so it sounds like I should just update it in the program and the sample code. Thank you for the input .
|
# ¿ Sep 26, 2012 06:23 |
|
Hughmoris posted:Since the OP hasn't been updated in 3 years, are there any new recommended books for people looking to pick up C# as a first language? This was a pretty good book in my opinion: http://www.amazon.com/Stephens-Prog...24-Hour+Trainer It walks you through how to use and setup visual studio, building program UIs, creating functions, manipulating variables, accessing the printer, making responsive dialogs, etc and they give you 1 main exercise and 4-5 extra exercises at the end of every chapter. At the end of the book you'll have written 1 pretty complicated program, and 40-50 main and extra programs. The author writes in a very comfortable manner that makes it all easy to follow even if you've never learned a language. He doesn't just drop a shitload of code on you and expect you to copy it. Often he'll explain concepts and then challenge you to implement the knowledge yourself (though you can download exercise code from his website if you get stuck). Obviously you won't pick it all up in 24 hours, so the title was my only complaint about it It will not cover more advanced things like multi-threading/task paralleling, but it's a great way to get into the language. e: clarification Knyteguy fucked around with this message at 23:55 on Sep 29, 2012 |
# ¿ Sep 29, 2012 23:51 |
|
Ithaqua posted:That book looks like it's terribly organized. How can you spend 10 chapters talking about Winforms GUI stuff before introducing the concept of variables? I think he pretty much just explains how to actually build the UI, and then goes into the code side of it. I remember being a bit frustrated reading the book because I simply wanted to make a basic calculator and wasn't familiar with how to declare variables in C# . All-in-all it was extremely helpful for someone who had never touched Visual Studio though.
|
# ¿ Sep 30, 2012 03:22 |
|
Ithaqua posted:Yes. Do not submit this code to a potential employer as it is. So after re-reading this I decided I'm probably just going to rewrite most of my inventory program tomorrow. I've never actually done unit tests, so I'm going to try a test-driven design with multi-threading and see how it goes. I'm still not very familiar with OOP principals (I'm not formally taught and usually just try different things until they work), do you or does anyone else have a good book I could read on the subject? I feel a bit over my head with best practices regarding this. Anyway here's another sample of code that I'm hoping is good as-is. code:
E: had to remove html special codes Knyteguy fucked around with this message at 08:05 on Sep 30, 2012 |
# ¿ Sep 30, 2012 07:59 |
|
Ithaqua posted:* The code itself is meaningless. You're providing no background on why this code exists. What problem were you solving? Why did you approach it that way? Did you try any other approaches? Thanks Ithaqua. I'll be going over this tomorrow and seeing what I can get from it. I made this program back in April and need to go over all of the code to figure out what it's doing again apparently. On that note I probably need better comments too.
|
# ¿ Sep 30, 2012 08:46 |
|
Okita posted:Here's a slightly more concise(but more esoteric and cheeky) way of essentially doing what you did. Just trying to give you some ideas about ways you can go about doing this kind of stuff: Thank you for the example. I hadn't thought of using a list for the extensions . The rest of the code is very good as well, I'm going to check out the link you posted as well. Thanks everyone else too, the help is appreciated.
|
# ¿ Oct 2, 2012 01:28 |
|
Does anyone know of a good random number generation library for C#? I'm thinking of creating a basic slot machine. I know the best random number generators come with some hardware, but that's pretty much beyond the scope of what I want to do.
|
# ¿ Oct 10, 2012 02:07 |
|
Ithaqua posted:System.Random? Hm alright thank you; I suppose you're right - it should be sufficient. http://www.extremeoptimization.com/Documentation/Statistics/Random_Numbers/Random_Number_Generators.aspx looks awesome but I'm not going to pay $1,000 for a project I'm doing for fun.
|
# ¿ Oct 10, 2012 02:23 |
|
Anyone that wouldn't mind giving a quick code review? I've never conformed with separating logic and view before, so I tried to do that here without going too crazy on functions. Credit to Ithaqua for the random code.code:
|
# ¿ Oct 11, 2012 06:06 |
|
Anyone mind doing a quick code review? https://github.com/Noppadet/LPMigrate/blob/master/LPSD%20Product%20Migration/Form1.cs E: This code isn't completely finished just in case you're wondering. Knyteguy fucked around with this message at 08:38 on Dec 27, 2012 |
# ¿ Dec 27, 2012 08:34 |
|
Cross posting from Version Control: Using TFS and I keep running into this error, anyone have any idea what's up? I tried clearing the cache, but this is like the third time it's happened. "The local version table for the local workspace XXX:XXX@EMAIL.com could not be opened. The workspace version table contains an unknown schema version." It's incredibly annoying and hampering development time by quite a bit.
|
# ¿ Jun 7, 2013 19:15 |
|
Ithaqua posted:Delete the workspace. Thanks; I've tried that and it works but it ends up happening again within a day for some reason. It sucks because I end up losing commits/pushes (which what the hell this shouldn't happen), -and- have to download 16k files every single time from the server .
|
# ¿ Jun 7, 2013 21:00 |
|
e ^: Thanks I'll check. I'll see if a server workspace will work better, too. I had installed VS2012 Update 2 yesterday, but every time I would run the project (web project) it would only say "Server is busy". I did a system restore and the error went away. Is VS2012 still reaching maturity? Maybe I'll try again just before closing up today. I'll check what TFS version is installed. epalm posted:If my version control software "lost" some commits/pushes, even once, I would throw it out. It's like a dog that bites someone, gotta put 'er down. Unfortunately my boss is pretty sold on it; I'd prefer a bitbucket repo even though some of the features of TFS are pretty nice. Knyteguy fucked around with this message at 21:12 on Jun 7, 2013 |
# ¿ Jun 7, 2013 21:08 |
|
Ithaqua posted:I've had no problems with VS2012 (or TFS2012, for that matter), other than some minor usability complaints (the VS2012 test runner sucks). I've been using both since January 2012. Changing the workspace from local to server seemed to do the trick with corruption of the cache/workspace, at least. I'm thinking Sync had something to do with it. Thanks again.
|
# ¿ Jun 7, 2013 22:57 |
|
Rooster Brooster posted:I liked Autofac when I used it. I've also been meaning to check out the one included in Catel. Just seconding this. We're using Autofac here and it works well.
|
# ¿ Jun 12, 2013 00:41 |
|
Just a quick .NET/C# obfuscation question: we're (the company I work for) offering a licensing system for a popular .net system. Basically we'll be offering plugin creators of this system a centralized place to sell their plugins, while taking care of all the stuff that developers don't really want to deal with, like keeping a server up and running, and attracting (more) customers. So I wrote some code in a DRM library that checks local values such as the host domain and license key against our licensing server to return a value with the status of the license (authorized, in trial, etc). Basically the only sensitive value stored on the client server is an obfuscated date (MD5 hashed date with a couple seeds). We use this date to determine whether we need to authorize again (we auth once a day). Because the seeds are stored client side as well, and would be in memory even if they weren't, we've been wondering whether an obfuscation solution would be worth it. So to get to the point, I'm wondering if we obfuscate our DRM class library (DLL) with Eazfuscator, whether plugin authors still be able to call the functions by name? If not with Eazfuscator, does anyone have an obfuscation solution that will keep function names the same, and simply obfuscate everything else? Also, according to general consensus would obfuscation be worthwhile in the sort system we've made? Thanks. Knyteguy fucked around with this message at 07:55 on Aug 6, 2013 |
# ¿ Aug 6, 2013 00:02 |
|
crashdome posted:I've purchased Eazfuscator in the past and although I really only used it once (and not for a public class library), I seem to remember being able to control whether or not certain public class and method names were obfuscated. I haven't used it in years though. Is there a trial? Thanks for your reply. We're using the free version of Eazfuscator which was available on NuGet. I'll have to dig through the configuration a bit more to see if there is an option for renaming functions. If anyone else has any information on other free obfuscation software that would be great, too. I checked out most of the ones Stack Overflow mentioned, but most replies were at least a year old.
|
# ¿ Aug 6, 2013 08:01 |
|
Not a question, but I couldn't find our old licensing thread. It looks like a GPLv3 (modified) license will be tested in court: http://www.nopcommerce.com/boards/t/24760/smartstore-rejected-to-meet-nopcommerce-license-terms-lets-discuss.aspx (.NET software)
|
# ¿ Aug 16, 2013 17:55 |
|
Is it possible to return a 301/302 redirect view from a controller? Here's the setup:C# code:
Knyteguy fucked around with this message at 00:25 on Sep 27, 2013 |
# ¿ Sep 27, 2013 00:23 |
|
ManoliIsFat posted:So you have a POST on configure that sets up these various things, and you wanna redirect to a GET on configure...why a get on the same method? Are you gonna have some Hey Manoli, here's the get: C# code:
We also do not have a license_key in our settings service defined because we can have multiple license keys for one product in a multi-domain environment, so it was more important that we actually allow different license keys for multiple domains in this environment (the rest of the settings that we set in these methods are pretty optimized and tested, so they can be shared across domains without any real benefit loss). So basically because we don't have these variables (expire_date, license_key) in the settings service, we don't send them to the view in the post. I know we could set them the same way we do in the get, but for standards it would be best to allow a user to refresh after posting, without reposting data. Also DRY and such. Thanks for the help (both of you); I'll give that redirect a try and see what happens. Also edit: this method really needs refactoring; I just found my morning project. E2: refactored a bit Knyteguy fucked around with this message at 17:31 on Sep 27, 2013 |
# ¿ Sep 27, 2013 16:56 |
|
Bah RedirectToAction("Configure") didn't work:quote:Child actions are not allowed to perform redirect actions. Oh well it's deployment day, if anyone has any ideas on how to fix I'll throw it in the next version. Edit: got it. return Configure(); did the trick. Knyteguy fucked around with this message at 18:28 on Sep 27, 2013 |
# ¿ Sep 27, 2013 17:45 |
|
Does anyone have a good resource on caching in .Net MVC 4? Also perhaps something to help me use the profiler to identify bottlenecks? It can be free or paid (though hopefully free on the profiler). Thanks! Edit: In particular, System.Runtime.Caching Knyteguy fucked around with this message at 23:58 on Nov 12, 2013 |
# ¿ Nov 12, 2013 23:34 |
|
Fastbreak posted:After digging in to NoSql and Document DBs, we are finally at the point where we are going to use them in some production apps. That means RavenDB is no longer viable since we don't have any budget to pay for it. We are looking into free options and so far RaptorDB and BrightStarDB are looking good. We are starting to flesh them out now, anyone tried them and had some success/ Any other recommendations we should try? Something that can work embedded as well would be needed. There's a lot of good discussion regarding a few different NoSQL databases here: http://forums.somethingawful.com/showthread.php?threadid=3571035&userid=0&perpage=40&pagenumber=2 (the front end development thread).
|
# ¿ Nov 14, 2013 17:27 |
|
mintskoal posted:MiniProfiler by StackExchange is really awesome for MVC 4 profiling. Hey thanks a lot this is absolutely perfect. Basically we have a request table that we now know is looking like this on an initial load: code:
I'm not 100% sure what we need to cache yet, but with the Mini Profiler I'm drilling it down right now. Subsequent page loads are still 10,000ms minimum. I had tried to use the VS profiler, but this is absolutely awesome.
|
# ¿ Nov 14, 2013 19:33 |
|
So, here's a logic defying problem I'm running into with C# MVC: Given this code below: All of that commented out code works. In fact it assigns filterableSpecificationAttributeOptionIds a List<int> containing the collection { 1, 3, 6, 7 } after everything is said and done. This collection is correct. In this second image, I have highlighted in blue where I hit the actual problem which is: If I use the commented code to return the collection ({ 1, 3, 6, 7 }) this method will take about 10 seconds to complete. If I use the code that is currently uncommented in image 1 (simply creating a new list with those collection values) this method goes through extremely quickly. I have tried debug and release builds. This will happen whether I'm debugging, or not. None of these methods are async. The method that hangs (highlighted image 2) is the last line here: C# code:
C# code:
Does anyone see what the heck might be up? The commented code and the uncommented code in the first image are functionally identical as far as I can tell? code:
Knyteguy fucked around with this message at 18:23 on May 14, 2014 |
# ¿ May 14, 2014 18:16 |
|
Ithaqua posted:Did you use a profiler? Use a profiler. There are a ton of moving parts here and no one in this thread is going to be able to pinpoint which moving part is causing the problem by looking at a few snippets of your code. I can appreciate that. I'm just looking to see if there's any known bugs. Here's what profiling found out for me: Slow Method: Fast Method: Basically exactly the same thing that I'm seeing with the debugger: the SQL calls though identical for some reason take more time when the list is populated from my method instead of declared as a new list with the same exact collection. Strange but I'm sure I'll figure out what's up.
|
# ¿ May 14, 2014 22:23 |
|
Ithaqua posted:Profile the code, not the SQL. Do you know of a good free profiler that can do better than the picture below? My Google-fu is failing me. I profile the code constantly but this is about the best data I can get with it: I've tried the JetBrains demo but it had a bit of a learning curve. Almost all of this poor performance is from core NopCommerce (open source ASP.NET store software) which is just absolutely terrible for the amount of data we have (100,000 products). I think it's too late in the game to get the company to switch though. Step 9 and of course PrepareSpecsFilter is where all of the excess is (the CategoryNavigation sucks too but that's for another day).
|
# ¿ May 14, 2014 23:11 |
|
GrumpyDoctor posted:I'm really curious about what's causing this - if you figure it out, be sure to post it! So I'm fairly certain it must be an EF bug or EF threading issue. Building out the data from a stored procedure rather than going through LINQ/EF fixed this. This was regardless of the fact that stepping through the code in the debugger worked very quickly.
|
# ¿ May 28, 2014 22:28 |
|
Ithaqua posted:Use SQL Server Data Tools. Import your database into an SSDT project, and then you have a source-controlled, canonical version of your database. Change things in your SSDT project, then publish it when you need to do a release. There you go, source controlled database objects. Dangit, Ithaqua! Every time I want to answer one you beat me to the punch! (just kidding man we're all lucky to get your help). Just wanted to chime in this is what we use at work and it works perfectly.
|
# ¿ May 30, 2014 20:42 |
|
beuges posted:I'm not sure if this is something straightforward or not. If you're developing a large MVC site, is it possible to break that up into separate projects? I don't mind if the sub-projects get included into the main site at compile time or run time... it's basically to potentially solve two problems in my head (that may not even be problems, or may be solved better in other ways): Check out nopCommerce (.net mvc). If you're asking what I think you're asking, then they organize their solution in that manner. https://nopcommerce.codeplex.com/SourceControl/latest It's probably easier to download the source and run it from Visual Studio to get a good idea of how they do it, as opposed to that web interface though.
|
# ¿ Jun 8, 2014 02:25 |
|
Funking Giblet posted:I probably wouldn't copy nopCommerce, I mean, have you seen their controllers? Unfortunately yes. I have to work with their controllers nearly daily (it's awful and makes me hate my job sometimes). We have a custom eCommerce package based off their source at work. They do some stuff right and really well though. I still kind of copy their layout tree on personal projects. Maybe I'm just familiar with it though. I am going to look into this mediator pattern though. I might be able to convince the owner of the company we should spend some time on this. He's a developer so he should understand. Of course he might say "Clients don't care if the code looks pretty. We don't need to spend any time refactoring." and then we'll have to work on it later and not know what the gently caress. I think the last time he said that he also said we shouldn't add the project to source control because we can keep the project on our dropbox. [/rant] (sorry)
|
# ¿ Jun 8, 2014 17:49 |
|
RICHUNCLEPENNYBAGS posted:Tremendously useful in eliminating some tedium from unit testing. No reason not to use it. This thread is over 7 years old and the OP sucks. It would be really cool for someone to create a new OP with stuff like this in it (AutoFixture). Helpful common libraries and VS addons, newbie resources, books, etc.
|
# ¿ Jun 17, 2014 01:35 |
|
|
# ¿ May 22, 2024 16:26 |
|
c355n4 posted:Any suggestions on a good book to learn MVC? Coming from a background in webforms. Assuming you mean ASP.NET MVC, maybe http://www.amazon.com/Pro-ASP-NET-Experts-Voice-ASP-Net/dp/1430265299/ref=sr_1_1?s=books&ie=UTF8&qid=1403031126&sr=1-1 ? I've used version 4 of this book as a reference and it's pretty solid. If you're not familiar with the MVC pattern it explains it, and at least in version 4 a good portion of the beginning of the book is building a multifaceted web project using MVC. YMMV of course.
|
# ¿ Jun 17, 2014 19:56 |