|
Bognar posted:I'm assuming the existing web app uses a session cookie to maintain authorization state? If so, you can just use cookies with HttpClient. It lets you set a CookieContainer, which will handle cookies like a browser would. Existing web app just uses the standard iis forms authentication and standard asp.net webforms controls. I'm also using restsharp client side - not sure if that would make a difference?
|
# ? May 2, 2015 08:42 |
|
|
# ? Jun 7, 2024 11:59 |
|
aBagorn posted:Go on... Well, the good news is that you can watch it here! Here's some fun facts about the demo. A little inside info:
There are plans to open source the client portion of the app at some point. I don't really want to open up the server part, because the code is pretty jank (Again, three weeks, and I don't know of a net benefit anyone would have using it since it has nothing to do with Xamarin) but the client portion is really well done.. But if anyone is interested I can talk about it. Drastic Actions fucked around with this message at 15:09 on May 2, 2015 |
# ? May 2, 2015 14:41 |
|
Thank God parameterless constructors for structs are not in the RC. That was a can of worms that didn't need to be opened. Edit: Finally found an up-to-date bit on what got in the RC for C# 6:
For primary constructors they really just need to add a new, context-sensitive keyword "primary" for constructors, because sticking it in the part with the class name is the worst thing for formatting. Either that or make "default" have a different meaning in that context: C# code:
Inverness fucked around with this message at 03:01 on May 3, 2015 |
# ? May 3, 2015 00:50 |
|
I found a bug in our app due to comparisons between DateTimeOffset and DateTime. I want to audit the rest of the codebase for the same type of problem and have fishy comparisons fail a unit test or something. Using Roslyn I can find all the BinaryExpressionSyntax I think I want to inspect, but doing it for the whole solution instead of a single file seems tough. We're still using 2013 with no immediate plans to go to 2015, so I didn't really want to write a VS code analyzer for this. Is there a story for analyzing problems across a whole solution but not by using a code analyzer? What are my options?
|
# ? May 3, 2015 05:12 |
|
Is the Windows 10 registry different than previous versions of windows? It seems like 10 will save registry values as typed, but 7/8 saves objects that need to be parsed. Specifically I'm doing this: code:
code:
Is there a better way to go about this? Is there a right way to add a shim for Win10? Just check Environment.OSVersion?
|
# ? May 3, 2015 07:52 |
|
Onion Knight posted:Is the Windows 10 registry different than previous versions of windows? This ought to do the trick: code:
EDIT: Although I'm not sure why you're getting that exception in the first place, since Convert.ToBoolean should accept boolean inputs quite fine. This works in dotnetfiddle, for example: code:
NihilCredo fucked around with this message at 11:01 on May 3, 2015 |
# ? May 3, 2015 10:39 |
|
NihilCredo posted:This ought to do the trick: Because before he was doing this code:
|
# ? May 3, 2015 13:04 |
|
Drastic Actions posted:Because before he was doing this
|
# ? May 3, 2015 15:08 |
|
Drastic Actions posted:Because before he was doing this I interpreted your latest reply on the repo as it still failing after my changes, because what you posted caused it to fail on my machine. If you haven't tried it after yesterday, then I misinterpreted your response and I asked a dumb question here. My original attempt at just casting the registry value to bool failed too, with the same exception, which is why I added the weird bool->string->bool conversion. Honestly I'm still not sure why that worked. I'm also not sure why it couldn't interpret the registry data as the correct type. It seems to be okay now, but that's not very helpful from a learning standpoint. I might work on it a little more and clean it up, but today I found out that ShareX is a thing, which does what I want my app to do, but better and with more features, so there's probably not much more use in the project except as a portfolio piece. Once I get Windows 10 on my laptop I'll test it again with NihilCredo's solution, just in case. Also I'm way new to this stuff and Drastic Action's was the first pull request I ever got and I was super pumped. Sorry if my etiquette about this stuff is way off base, haha
|
# ? May 3, 2015 15:56 |
|
How safe is it to install VS2015 RC alongside VS2013? I vaguely remember reading something that said you should only install VS2015 in a VM or something that can be reformatted. Was this only for the CTPs or something like that? When it's actually released, will I be able to completely uninstall the RC and install the actual release, without messing up my system?
|
# ? May 3, 2015 17:39 |
|
Cryolite posted:How safe is it to install VS2015 RC alongside VS2013? I vaguely remember reading something that said you should only install VS2015 in a VM or something that can be reformatted. Was this only for the CTPs or something like that? When it's actually released, will I be able to completely uninstall the RC and install the actual release, without messing up my system? RC is a "go live" release, meaning it is supported. I've been using it for a few weeks alongside 2013, it's fine.
|
# ? May 3, 2015 18:54 |
|
Onion Knight posted:Once I get Windows 10 on my laptop I'll test it again with NihilCredo's solution, just in case. Cryolite posted:How safe is it to install VS2015 RC alongside VS2013? I vaguely remember reading something that said you should only install VS2015 in a VM or something that can be reformatted. Was this only for the CTPs or something like that? When it's actually released, will I be able to completely uninstall the RC and install the actual release, without messing up my system? Have been running the CTP alongside VS13 for a few months now (for messing around with F#4 and with vNext, while I did production work on VS13), never had any problems. If all my plugins work fine I'll probably switch over to VS15RC for production work too; side-by-side installations are a little expensive on a SSD.
|
# ? May 3, 2015 19:25 |
|
Onion Knight posted:Is the Windows 10 registry different than previous versions of windows? No! quote:Is there a better way to go about this? Is there a right way to add a shim for Win10? Just check Environment.OSVersion? Don't check Environment.OSVersion because that's way too fragile! I'm 99.9% sure that there's something else going on. What key are you looking at? Is it a key created by your own app? I'd figure out the underlying problem before hacking around with weird casts.
|
# ? May 3, 2015 22:34 |
|
Cryolite posted:How safe is it to install VS2015 RC alongside VS2013? I vaguely remember reading something that said you should only install VS2015 in a VM or something that can be reformatted. Was this only for the CTPs or something like that? When it's actually released, will I be able to completely uninstall the RC and install the actual release, without messing up my system?
|
# ? May 3, 2015 22:38 |
|
ljw1004 posted:Don't check Environment.OSVersion because that's way too fragile! I'm 99.9% sure that there's something else going on. What key are you looking at? Is it a key created by your own app? I'd figure out the underlying problem before hacking around with weird casts. That's fair. Here's the code as it looks now. The program is a task tray app that listens for a hotkey press then uploads a user-defined screenshot crop to imgur. The source is here. The configurations are being loaded when the app starts up, and saved only when the configuration menu is closed. This, for me, works: code:
code:
Then, I went into regedit and cleared all of the keys my program generates. If the registry doesn't have an Imgruber key already, it runs and generates the default values. However, next time it runs, it'll break on the first bool again. I've checked the registry in every case I could think of (bool cast, default values/bool cast, saved values/bool conversion, default values/bool conversion, saved values) and the registry entries look identical. They're all of type REG_SZ and their data is either True or False, without exception. The string and int casts work totally fine, no problems with any of those. I am stumped!
|
# ? May 4, 2015 04:33 |
|
Onion Knight posted:Then, I went into regedit and cleared all of the keys my program generates. If the registry doesn't have an Imgruber key already, it runs and generates the default values. However, next time it runs, it'll break on the first bool again. I reckon in your mass of retesting you got into a mixed state. key.SetValue("useCtrl", chkbox.Checked) will always write a REG_SZ into the registry with value "True" or "False". (This appears to be true regardless of current culture). key.GetValue("useCtrl", false) will either return a string (if the regvalue was there), or a boolean (if the regkey was absent and it had to fall back to the default you provided which was a bool). It's up to you to handle both. Certainly the (bool) cast will fail with InvalidCastException in the first case and succeed in the second case, so it's not appropriate. Convert.ToBoolean() will succeed in both cases. (Personally I think it's fishy to supply a default which has a different type from the thing you're actually reading from the registry... I think you should have written key.GetValue("useCtrl", "False") to simplify your code-paths). I suspect that the difference you observed wasn't a 10 vs 7/8 issue, but was rather a "stuff was in the registry" vs "stuff wasn't yet in the registry" issue. ljw1004 fucked around with this message at 18:47 on May 4, 2015 |
# ? May 4, 2015 07:40 |
|
I'm trying to deserialize a JSON string onto a C# class using Json.Net, but the process seems to be failing silently.code:
|
# ? May 5, 2015 16:14 |
|
Daysvala posted:I'm trying to deserialize a JSON string onto a C# class using Json.Net, but the process seems to be failing silently. Don't use async void. You should be awaiting that method, so use async Task.
|
# ? May 5, 2015 16:50 |
|
Daysvala posted:I'm trying to deserialize a JSON string onto a C# class using Json.Net, but the process seems to be failing silently. Json.Net is by default pretty permissive; when it sees something it doesn't understand it just moves on instead of complaining. I don't know what the problem is, but if you pass your own JsonSerializerSettings to PopulateObject you can turn on a few "throw instead of skipping if this particular failure case is encountered" options and even wire up your own error handler.
|
# ? May 5, 2015 16:56 |
|
Could someone recommend a good WCF book or a tutorial to get a REST webservice going for a SQL Server DB?
|
# ? May 6, 2015 14:39 |
|
TheReverend posted:Could someone recommend a good WCF book or a tutorial to get a REST webservice going for a SQL Server DB? Maybe I'm wrong, but I feel like the way this question is worded is exposing some misconceptions, so I'll start from the beginning. WCF is a communication framework from Microsoft that you should probably avoid unless you are required to use it. REST is a software architecture style that literally means "representational state transfer", but effectively means something different to everyone - only Roy Fielding knows what it really means. Neither WCF nor REST has anything to do with SQL Server. What you probably want in .NET is something like Web API which allows you to easily create HTTP endpoints to build your web service out of. There are probably some good books about it, but in my opinion the linked tutorials are good enough. Those tutorials use Entity Framework to talk to their SQL database, but use literally whatever you want. Web API (and WCF) have no requirements on how you get your data or where you get it from.
|
# ? May 6, 2015 15:05 |
|
TheReverend posted:Could someone recommend a good WCF book or a tutorial to get a REST webservice going for a SQL Server DB? There are some good videos from Jim Webber on how to architect a REST service. Especially how to handle HTTP methods and the ideas behind it all.
|
# ? May 6, 2015 15:36 |
|
Nice! Thanks a lot. I thought since I use .net a lot that WCF would be easiest. I actually have a fake web service running that I made that's all socket based and non standardized so I'm trying to do it right since we decided that the concept was good.
|
# ? May 6, 2015 15:54 |
|
ASP.NET Web API is the current generation upgrade from WCF.
|
# ? May 6, 2015 16:20 |
|
Follow up: Would Azure make this really easy? I'm having issues with the Azure management page right now but I've never used it and I think that's what Azure is for?
|
# ? May 6, 2015 19:43 |
|
I wonder why the using statement in C# wasn't made to be more like that in C++ Sometimes it feels like a lot of boilerplate is added for using statements in C#. I don't like having my code indented too much. I was thinking of something like this: C# code:
|
# ? May 6, 2015 20:23 |
|
fwiw, F# does that.
|
# ? May 6, 2015 21:31 |
|
Are you sure about the scopes? I'm pretty sure I've seen people just open up a block in some C# code so they could redeclare a variable or something. It's kind of nasty when it happens.
|
# ? May 6, 2015 21:44 |
|
TheReverend posted:Follow up: Azure is a cloud platform that can be used for hosting web applications (and other types of server-side applications) and which provides various pre-existing services. It does not change the way you develop software unless you wish to integrate those pre-existing services it offers. If you need to make a REST web service then make a REST web service. Yes, you can easily host it in Azure. And you can easily host it elsewhere. It may be possible to share further advice if you provide more details about what you need to accomplish.
|
# ? May 7, 2015 08:09 |
|
WeirdAPI is weird, or, I'm learning a new way to do things. To Update, not Add/Insert a new Foo to $ENDPOINT, I call hit the same url, same verb, but I just omit two properties from the JSON. is there a clean way to programmatically ignore the serialization of these properties, or should I just make a class without them and serialize that instead? Edit: http://www.newtonsoft.com/json/help/html/ConditionalProperties.htm My googlefu is rusty. Space Whale fucked around with this message at 20:59 on May 7, 2015 |
# ? May 7, 2015 14:29 |
|
Inverness posted:I wonder why the using statement in C# wasn't made to be more like that in C++ I'm having trouble understanding what you are looking for. But using-blocks just expand to a try-finally. C# code:
C# code:
|
# ? May 7, 2015 15:41 |
|
loving help me goons before I kill someone. All I want to do is copy the client area of one form, and set it as the background of another form. I've tried a million things today, mostly nicked from SO, and I either get no background or some sort of stupid "General GDI error' exception. When I write the capture BitMaps to files they are just plain black rectangles. Here's what I have at the moment, as I say, mostly stolen code:
Someone save me? p.s. Winforms p.p.s Also tried this, similar results: code:
|
# ? May 7, 2015 16:30 |
|
Wait, no! The second bit is now getting *something*, but it's the wrong part of the screen. I am going to shoot myself. edit: OK, mostly there, except I'm getting the title and bar and minimize, restore, etc. controls. final edit: Don't worry goons, you can take me off suicide watch. Next time I'll just ask for help immediately instead of just struggling for hours, as Sod's Law dictates that this will cause me to immediately get it working. chippy fucked around with this message at 16:51 on May 7, 2015 |
# ? May 7, 2015 16:33 |
|
zokie posted:I'm having trouble understanding what you are looking for. But using-blocks just expand to a try-finally. They just want a way to modify a declaration such that the declared variable gets Dispose called when it falls out of scope, but not requiring a new scope the way using does.
|
# ? May 7, 2015 17:02 |
|
I loving give up. OK, so, Plexiglasss is just a borderless form with a blurred, faded image of the form it's given in its constructor set as its background. If I do this: code:
But if I do this in another method of the form: code:
I even tried sleeping for 5 seconds in case the work was just happening too quickly. Nothing. Someone help me before I actually do kill myself? e: Got it. Needed to call Refresh on the glass. Anyone know why calling it in its Shown event handler wasn't enough? ee: Putting it in the Activated handler worked. gently caress Winforms. chippy fucked around with this message at 17:47 on May 7, 2015 |
# ? May 7, 2015 17:38 |
|
zokie posted:I'm having trouble understanding what you are looking for. But using-blocks just expand to a try-finally. I could write something like: C# code:
C# code:
|
# ? May 7, 2015 18:51 |
|
Inverness posted:What I'm saying is that rather than being forced to create a new scope, I want the using statement to apply to whatever scope its located in. That starts to fall apart when the using block doesn't coincide with the end of the method. For example: C# code:
|
# ? May 7, 2015 18:57 |
|
Ithaqua posted:That starts to fall apart when the using block doesn't coincide with the end of the method. This is a far less common case, though. Again, F# does this exact thing (along with "C#-style using" for when you need explicit control), and having worked with both, I much prefer the F# version, from both a readability and usability point of view. F# also allows the neat trick of combining use bindings with object expressions: code:
|
# ? May 7, 2015 20:53 |
|
Is there a "right" way to open new views in MVVM? In a possibly ill-advised attempt to avoid controlling views from a viewmodel directly, I cobbled together something like this. Is it kind of the right way to go about it?XML code:
C# code:
Ciaphas fucked around with this message at 20:59 on May 7, 2015 |
# ? May 7, 2015 20:56 |
|
|
# ? Jun 7, 2024 11:59 |
|
Inverness posted:What I'm saying is that rather than being forced to create a new scope, I want the using statement to apply to whatever scope its located in. I think the difference is that in C++ doesn't have GC, so every single blasted resource has to be disposed of, which is why they made the idiom so easy to use -- at the cost of it being implicit+invisible. C# does have GC, so you only use the "using" pattern for heavyweight resources where you want to manually be fully aware and in control of disposing of those resources. So an implicit+invisible way to call Dispose would defeat the point.
|
# ? May 7, 2015 20:57 |