|
Visual Studio 2012, with Update 4. New Project -> ASP.NET MVC 4 Web Application -> Web API Run the project, see standard "Welcome to ASP.NET Web API!" greeting page. Click "API" in top right corner, taking me to auto-generated API documentation at http://localhost:12345/Help Take a look at MvcApplication1\MvcApplication1\Areas\HelpPage\Views\Help\Index.cshtml Apparently the Help area of a fresh WebAPI project Just Doesn't Work out of the box. I've tried a few suggestions like running Uninstall/Install-Package Microsoft.AspNet.WebApi from the package manager console, no dice. If I look at the properties of System.Web.Http in my references list, and set Copy Local to True, http://localhost:12345/Help works just fine. What the hell is wrong with my system?
|
# ? Oct 16, 2014 23:46 |
|
|
# ? May 15, 2024 19:27 |
|
Try updating your nuget packages. Microsoft pushed a new version of the MVC4 dll today that is breaking things. StackOverflow Microsoft bulletin EDIT: Rereading this probably won't help. However, this might be good information for other developers
|
# ? Oct 16, 2014 23:52 |
|
Speaking of updates, VS2013 Update 4 RC is out. http://blogs.msdn.com/b/visualstudio/archive/2014/10/16/visual-studio-2013-update-4-rc-now-available.aspx
|
# ? Oct 17, 2014 00:10 |
|
Newb question: VS2012 on a basic web project I've got a solution (let's call it Helper) that's been running on my local workstation for the last 18 hours, on the local IISExpress worker process. As you can probably guess from my earlier questions, it's doing a bunch of image downloading and manipulation (370,000 images to be exact). I'm doing this on my local because it's a one time thing and I thought it would finish overnight. The thing is, I want to run/build Helper again, in a separate instance that won't blow up/stop my huge image download (which has at least another 14 hours to go). How can I run another another instance of the same project, build it, and not have it interfere/mess with the existing and running version of the same project? Due to the chancy nature of losing 18 hours of downloading if I'm wrong, I'm kind of scared to guess and test on this one. These are possibilities I've thought of in order of ugliness: 1. Just build it again in the same instance of VS, iis is smart enough to not shut down an existing running process. 2. Open another instance of VS, open the solution, and VS will be smart enough to keep them separate 3. Copy entire solution folder somewhere else and rename it and open as solution in VS (uggh the RCS implications) or 4. Man up and just RDP into the development server, get latest from Git, and go from there.
|
# ? Oct 17, 2014 00:45 |
|
Scaramouche posted:1. Just build it again in the same instance of VS, iis is smart enough to not shut down an existing running process. Big fat No to 1 and 2. 3 should work with just copying and not renaming the solution, and 4 sounds pretty similar to 3. The real answer, though, is to build long running processes to be able to pick up from where they left off after a catastrophic failure (or, you know, a rebuild). Bognar fucked around with this message at 01:59 on Oct 17, 2014 |
# ? Oct 17, 2014 01:52 |
|
Silly question: Why are you downloading and manipulating images in a web application? Not that it matters in this particular instance, it's just a weird thing for a web application to do.
|
# ? Oct 17, 2014 01:55 |
|
If you do anything to the one that is running it will bounce IIS because the DLLs will change which tells IIS to bounce the app pool. The best bet if you want to work locally in it would be to check out a 2nd copy in git and develop there while it runs, being very careful of VS. The better bet for the future is to deploy a copy locally and run long-running tasks there if you don't need interactive debugging for some reason.
|
# ? Oct 17, 2014 02:07 |
|
Thanks guys, looks like I was right to be paranoid instead of diving right into 1 or 2. It's running as a web app because this is kind of my swiss-army knife utility for functions related to a particular web site, and I like being able to instantiate events via URL (e.g. /helper.aspx?op=update-inventory). While this batch is a one-off, the idea is that it'll run iteratively in future, and only have to handle 200-300 images a day (product images for ecommerce). The way it's set up now is a manufacturer can launch new products and they'll automatically be created for the site and uploaded to 8 different marketplaces within a few hours. The downside is when a vendor decides to launch 100,000 new products all at once. I can come back if it's interrupted; it's downloading images based on an incremental id so worse came to worst I could just look at last id processed and jump on from there. I knew it was going to be long running, but not this long running. I also might have mis-estimated the timing, based on where it's at now there's still about 18 hours to go which means it's time to go home and then bite the bullet tomorrow by using the dev server. EDIT-For anyone curious, it just finished now. Scaramouche fucked around with this message at 01:06 on Oct 18, 2014 |
# ? Oct 17, 2014 03:46 |
|
Is this F# code ok?code:
Will this get me in trouble with stack overflows? Or will this be properly handled? Tail recursion is the word for this right? Total F# noob here.
|
# ? Oct 18, 2014 22:06 |
|
You have correctly made the recursive tail call, although by default, it will not be eliminated in Debug mode.
|
# ? Oct 19, 2014 01:44 |
|
Any ideas? The key record is clearly annotated. Just trying to get EF to create my tables (code first). Knyteguy fucked around with this message at 08:46 on Oct 19, 2014 |
# ? Oct 19, 2014 08:43 |
|
Knyteguy posted:Any ideas? The key record is clearly annotated. Just trying to get EF to create my tables (code first). C# code:
C# code:
|
# ? Oct 19, 2014 09:10 |
|
epalm posted:
Haha, thanks. I just realized about half of my model classes have fields and half have properties (some have both). Late night coding .
|
# ? Oct 19, 2014 16:23 |
|
Any ideas why this code gives me an AccessVilolation?code:
It only gives the error when stepping trough the code though, the result when running the program is fine and works as I expect it to do. Both the commented array.choose as the other one give me this error.
|
# ? Oct 20, 2014 05:45 |
|
Have you tried breaking up the pipeline to see exactly what the problem is?
|
# ? Oct 20, 2014 05:56 |
|
You're right, they do create new arrays. If it's only when you're debugging it sounds like the "Locals" window or something in VS is trying to read something it shouldn't? Side note: you can collapse your choose to a filter if you want: Array.filter (not << System.String.IsNullOrEmpty)
|
# ? Oct 20, 2014 06:56 |
|
GrumpyDoctor posted:Have you tried breaking up the pipeline to see exactly what the problem is? Not yet, that was going to be my next step. I was scratching my head because I think it is quite reasonable code and everything I found on Stack overflow and the like said it should work. Destroyenator posted:You're right, they do create new arrays. If it's only when you're debugging it sounds like the "Locals" window or something in VS is trying to read something it shouldn't? Hmmm, I think you might be onto something. Pretty weird if it does. Access Violations during normal execution would stop my program right? I mean, I am not ignoring some exception silently? Love your method, I am not that well versed in F# to work with it though. Not yet anyway. Thanks Edit: Thinking about your rewrite: Am I correct in assuming that the Not operator is a function that takes a value or a function? So you pipe the value coming out of the Array into the String.IsNullOrEmpty function and piping that into the Not operator? This results in a bool for the filter function? Sometimes F# code cooks my noodle. Mr Shiny Pants fucked around with this message at 07:16 on Oct 20, 2014 |
# ? Oct 20, 2014 07:01 |
|
Mr Shiny Pants posted:Hmmm, I think you might be onto something. Pretty weird if it does. Access Violations during normal execution would stop my program right? I mean, I am not ignoring some exception silently? You might want to double-check your exceptions list (Debug > Exceptions, I think) and make sure that "Thrown" is checked for that particular exception type. Do you see the problem any time you have a debugger attached, or just when you're actually stepping through?
|
# ? Oct 20, 2014 07:15 |
|
GrumpyDoctor posted:You might want to double-check your exceptions list (Debug > Exceptions, I think) and make sure that "Thrown" is checked for that particular exception type. Do you see the problem any time you have a debugger attached, or just when you're actually stepping through? Only when actually stepping through this particular piece of code.
|
# ? Oct 20, 2014 07:17 |
|
Yeah, sorry I could've been clearer, the << operator is function chaining, it's just a terser way of writing: Array.filter (fun x -> not (System.String.INOE(x))) Where "not" is just the boolean not like "!" in c#.
|
# ? Oct 20, 2014 07:35 |
|
Destroyenator posted:Array.filter (not << System.String.IsNullOrEmpty) I wish C# has this kind of composition. I love that you can do .Where(string.IsNullOrEmpty) but I hate that you have to do .Where(x => !string.IsNullOrEmpty(x)).
|
# ? Oct 20, 2014 13:37 |
|
Bognar posted:I wish C# has this kind of composition. I love that you can do .Where(string.IsNullOrEmpty) but I hate that you have to do .Where(x => !string.IsNullOrEmpty(x)). Is it possible to write a generic wrapper that lets you do something like .Where(Not(string.IsNullOrEmpty))? The closest I can get is this: code:
|
# ? Oct 20, 2014 13:59 |
|
It would probably work better as an enumerable extension method:code:
|
# ? Oct 20, 2014 14:15 |
|
Mr Shiny Pants posted:Only when actually stepping through this particular piece of code. That's really weird. If the problem still happens with the pipeline broken up, can you post the exception message?
|
# ? Oct 20, 2014 18:09 |
|
Rewrote it like this:code:
Error message: code:
Rewrote as pointed out: code:
Mr Shiny Pants fucked around with this message at 18:43 on Oct 20, 2014 |
# ? Oct 20, 2014 18:40 |
|
Aren't those array functions evaluated lazily? I wonder if stepping through in the debugger forces an evaluation and you wouldn't otherwise see it in normal execution for a while.
|
# ? Oct 20, 2014 18:49 |
|
Jewel posted:Is it possible to write a generic wrapper that lets you do something like .Where(Not(string.IsNullOrEmpty))? The closest I can get is this:
|
# ? Oct 20, 2014 18:52 |
|
I don't like the word typeless for describing a method group, but I can't really express why. It's an internal type used by the compiler, but yeah it can't map directly to C# types. The important thing to note is that a method group is a group since it can describe multiple methods (e.g. multiple overloads). If you do something like cast to a typed Func, then you are explicitly specifying which overload you are using (and you will get a compilation error if the overload doesn't exist). C# code:
Bognar fucked around with this message at 19:36 on Oct 20, 2014 |
# ? Oct 20, 2014 19:34 |
|
Actually, I take that back, the compiler probably can't figure it out due to generic type covariance/contravariance. Func<T1, T2> has an contravariant T1 (parameter type) and covariant T2 (output type), e.g.:C# code:
C# code:
Bognar fucked around with this message at 19:55 on Oct 20, 2014 |
# ? Oct 20, 2014 19:51 |
|
Unit Testing and Web API 2 questions ahoy!!! I have a basic framework laid out for how I want to start writing my tests (which is good, I'm learning TDD on the fly), but I'm kind of stumped with testing the put functionality. As taken from here: http://www.asp.net/web-api/overview/testing-and-debugging/mocking-entity-framework-when-unit-testing-aspnet-web-api-2#tests The most basic PUT unit test should be something like: C# code:
For example, we have a tenant object and a building object, and then there is a history mapping table that maps the start date and end date of a tenant's assignment to a building. I want to check against that table (or mock it) when a tenant is edited to make sure that the new start date is greater than the previous start and end date (and so on and so forth). Is this testing or validation is basically my big question...
|
# ? Oct 20, 2014 20:08 |
|
If you're thinking that far ahead, you're not doing TDD. In TDD, you should be thinking about the next tiny, logical step that moves you closer to your end goal.
|
# ? Oct 20, 2014 20:47 |
|
Anyone have clue how to get SQLite working in F# using the Nuget drivers? I downloaded the SQLite core drivers and referenced them, but no luck. During compilation it craps out and in the interactive window I am getting a cannot load DLL error SQLite.Interop.DLL. Pretty frustrating, any pointers would be appreciated. Edit: Found it. Don't know what is wrong with the Nuget package but the one from the site works great: http://system.data.sqlite.org/downloads/1.0.94.0/sqlite-netFx451-setup-bundle-x64-2013-1.0.94.0.exe It even works in the FSI and no mucking about with the interop DLL. Edit 2: Wow, the X64 DLL does not work with the TypeProvider because Visual Studio is a 32Bit application that can't load X64 binaries. So the X86 binary is still required for VS to work. Bummer. Mr Shiny Pants fucked around with this message at 21:13 on Oct 20, 2014 |
# ? Oct 20, 2014 20:48 |
|
Ithaqua posted:If you're thinking that far ahead, you're not doing TDD. In TDD, you should be thinking about the next tiny, logical step that moves you closer to your end goal. Right. That makes sense. I guess I'm mixing up my "project manager" and "lead developer" hats that I'm wearing for this particular project.
|
# ? Oct 20, 2014 20:55 |
|
aBagorn posted:Right. That makes sense. I guess I'm mixing up my "project manager" and "lead developer" hats that I'm wearing for this particular project. You also threw the word "table" in there, which makes it sound like you're thinking in terms of SQL. Unless you're testing your persistence layer, your code shouldn't know or care how the data is persisted. It could be a SQL database, a NoSQL database, a flat file, a paper tape, or engraved in stone tablets. If the "history table" is something represented in your code and you're doing TDD, you'll end up writing tests for it. That's how TDD works: You don't write code that isn't backed by a test. There's still value in testing your SQL, especially when dealing with ORMs. This is where integration tests come into play, or if you're just using straight up stored procedures, SQL server data tools lets you do "database unit tests". I'm not a huge fan of it, but it's not terrible.
|
# ? Oct 20, 2014 21:14 |
|
I thought I had a grip on async / await and then I got a bit confused. Is this: code:
code:
|
# ? Oct 21, 2014 02:45 |
|
Dirk Pitt posted:I thought I had a grip on async / await and then I got a bit confused. No, in fact they are very different. Task.Run returns a task, which you're not awaiting. That means that you synchronously call LoadView, and it starts a task and immediately returns, without waiting for that task to complete. This is probably not what you want. Also, you should never use async void methods except for event handlers. There are a bunch of good reasons why: you can't await them, and exceptions can cause unexpected behavior, like outright crashing your application. If you need to synchronously wait for an asynchronous thing to finish, use Task.Wait. Or more ideally, make the application async "all the way down". Async keywords will spread throughout your code, which is okay! New Yorp New Yorp fucked around with this message at 02:54 on Oct 21, 2014 |
# ? Oct 21, 2014 02:52 |
|
Ahhh, I was using task.run to avoid having to make an async void. What am I supposed to do if I need to await an asyncronous method in an override void or constructor? I typically make everything async all the way down. This is an issue I am curious about in a framework I have little control over (xamarin).
|
# ? Oct 21, 2014 02:54 |
|
Dirk Pitt posted:Ahhh, I was using task.run to avoid having to make an async void. Task.Wait, although IIRC this can cause deadlocks.
|
# ? Oct 21, 2014 02:58 |
|
Hmm, ok, thanks a ton. I will look at that. I really usually do have a good grasp on async / await, this is the edge case that gives me loving fits. Especially when I tell someone on stack overflow that there are other options (even if they are correcting my code), and they get all huffy puffy.
Dirk Pitt fucked around with this message at 03:04 on Oct 21, 2014 |
# ? Oct 21, 2014 03:00 |
|
|
# ? May 15, 2024 19:27 |
|
chmods please posted:Aren't those array functions evaluated lazily? I wonder if stepping through in the debugger forces an evaluation and you wouldn't otherwise see it in normal execution for a while. Bognar posted:I wish C# has this kind of composition. I love that you can do .Where(string.IsNullOrEmpty) but I hate that you have to do .Where(x => !string.IsNullOrEmpty(x)).
|
# ? Oct 21, 2014 03:05 |