|
For VS For Mac, I highly encourage you to go into the preferences and look at the Behaviors and IntelliSense options At lot of really useful options are turned off by default (As a certain someone doesn't seem to like them) that a Visual Studio for Windows user would normally expect. So it's useful to play around with them and see what best fits with your workflow. In terms of IntelliSense, VS For Mac uses roslyn so anything VS for Windows shows, VS for Mac should show. For that enum, you could right click it it offer to fill in the switch. Keyboard shortcuts may be different between Windows and Mac, owing a bit to the heritage of VS for Mac. For crossplatform GUI frameworks, Eto.Forms is good if you like more programatic GUI design. Xamarin.Forms is great if you like working with XAML (which most WPF developers are), and it targets more platforms, including mobile. You can also make native Mac applications with Xamarin.Mac, but it's not as straightforward as it is making a Windows application with WinForms, WPF, or UWP.
|
# ? Jul 19, 2018 17:27 |
|
|
# ? Jun 8, 2024 15:05 |
|
Thanks for those suggestions. I've changed my Behaviour + Intellisense bits. As far as the right-click option, mine seems to be less useful. https://imgur.com/Z1MHsJX I found people talking about liking Rider, and I've got a JetBrains licence through my university so that sounds like a possible alternative, especially as I'm used to PyCharm. Thank you for the suggestion of Eto. I have no experience of making GUI, or exposure to XAML, so neither of those ideas mean anything to me. A quick google however suggests Eto doesn't work with Rider.
|
# ? Jul 19, 2018 21:49 |
|
Sad Panda posted:As far as the right-click option, mine seems to be less useful. Right click on "switch" instead of the variable. It should also show this if you click on "switch" and hover over the red line.
|
# ? Jul 19, 2018 22:14 |
|
Thank you! I'm a moron. That's pretty magical that it can bounce from switch to if and from foreach to for to while to dowhile.
|
# ? Jul 20, 2018 13:20 |
|
EssOEss posted:What I would prefer to do is to zip the files on the fly to a temporary Azure blob. That is, do not write to filesystem, do not write to a MemoryStream in RAM, just append the data directly to the blob. This avoids using significant server resources besides the CPU and limits the range of things that can go wrong. Once the write is finished, give the user a SAS token enabled link to the blob and get rid of the blob after N hours. After riding the struggle bus directly downloading .zips from web api endpoints I gave this sort of solution a spin and I think it's going to work out much better. I'm going to have our web api generate the zip, store it in blob storage, and send a link to the blob to the client so the user can do what they want with it. It's a nice benefit that users can download the same zip twice without doing any duplicated computation. storage is cheap as hell, after all. The built in ZipArchive class seems to be working fine with constructing the files in-memory and streaming up to blob storage, I was just misunderstanding things when I first posted about it. Thanks programmer goons e: also much easier to implement client-side code:
Careful Drums fucked around with this message at 16:00 on Jul 20, 2018 |
# ? Jul 20, 2018 15:52 |
|
I want to make sure I understand something correctly. In asp.net MVC, I've got a class that acts as a layer between my controllers and EF. All methods are static, and I use this bit of code for the db context... code:
|
# ? Jul 31, 2018 19:57 |
|
You really should be injecting a DB context into your controller from a DI container that can maintain scope.
|
# ? Jul 31, 2018 20:04 |
|
Is there an advantage to di with a super small project? I've never implemented it, so I don't know what sort time it takes realistically.
|
# ? Jul 31, 2018 21:32 |
|
The smaller the project the easier it is to do, and knowing how to do it will be very helpful for larger projects.
|
# ? Aug 1, 2018 00:23 |
|
bobua posted:Is there an advantage to di with a super small project? I've never implemented it, so I don't know what sort time it takes realistically. You will probably have to spend some time learning whatever framework you choose, but once you know how it works then setting up simple stuff is practically free.
|
# ? Aug 1, 2018 02:37 |
|
bobua posted:I want to make sure I understand something correctly. You don't want to have a single context, ideally you'd have a per-request context.
|
# ? Aug 2, 2018 02:58 |
|
I'm strugging with some weird database stuff. I'm attempting to run a query, do some stuff to the results, and return them. Standard stuff. But the query I'm running returns a large dataset (several hundred thousand records). The query itself executes incredibly quickly in DataGrip, but when I run the query in C# it's incredibly slow. I originally thought maybe it was Dapper's mappings that were taking forever, so I went straight to the database using NpgsqlConnection and NpgsqlCommand and still it takes a huge amount of time. Are there any tricks to reading a large dataset from a database in C# that I can use to speed things up?
|
# ? Aug 2, 2018 03:37 |
|
a hot gujju bhabhi posted:I'm strugging with some weird database stuff. I'm attempting to run a query, do some stuff to the results, and return them. Standard stuff. But the query I'm running returns a large dataset (several hundred thousand records). The query itself executes incredibly quickly in DataGrip, but when I run the query in C# it's incredibly slow. I originally thought maybe it was Dapper's mappings that were taking forever, so I went straight to the database using NpgsqlConnection and NpgsqlCommand and still it takes a huge amount of time. Are there any tricks to reading a large dataset from a database in C# that I can use to speed things up? Anything specifically slow? Getting the records? Getting the query to the server?
|
# ? Aug 2, 2018 09:33 |
|
Assuming DataGrip works like every other (worthwhile) SQL IDE, executing a query won't actually fetch all results immediately. In fact, a quick search reveals the Result Set Prefetch Size setting, which is likely what tricks you into thinking retrieving the query results actually completes that fast. Try clicking the "go to last page" button in DataGrip and see how long it actually takes. My guess is the performance will now look more comparable. Speeding things up from this point on requires actual profiling to see where the bottleneck is (network? disk? memory?). However, it might be more practical to reconsider if you actually need all that data in memory in the first place, which depends on what you need to do with it. The final result may just be accepting that processing that amount of data simply takes a while - it really also depends on just how slow you're talking about here. SirViver fucked around with this message at 10:01 on Aug 2, 2018 |
# ? Aug 2, 2018 09:57 |
|
Also good (though not necessarily relevant in this case) reading on the topic: http://www.sommarskog.se/query-plan-mysteries.html
|
# ? Aug 2, 2018 17:10 |
|
Something I ran across today, which I present for your edification/amusement/complete apathy. I have had issues in the past where closing the main window does not terminate the application. Never been able to puzzle out why, no unclosed windows, so it’s something else. Because of this, in the method that actually closes my application, I got into the habit of calling Environment.Exit(0) as a final step. Working on a new app today, I did the same thing, except that I forgot to call Application.Current.MainWindow.Close() before calling Environment.Exit. As a result, if I ran the application and pressed the exit button (or hit Escape), everything worked as expected, and the debugger showed that the program exited with code 0. However, if I alt-tabbed to another app, or if the program main window lost focus for any reason, Environment.Exit actually threw an exception. I have no clue why losing focus would cause this, and it was corrected by closing the main window before calling Environment.Exit.
|
# ? Aug 6, 2018 01:56 |
|
I don't know the first thing about developing desktop apps, but it seems logical to me that exiting the app would be a distinctly different operation than closing the window and it doesn't surprise me that you need to do both. But again, I don't know anything about desktop stuff.
|
# ? Aug 6, 2018 08:55 |
|
Most desktop apps tend to just have a "DoMainWindowStuff()" as the last call in their entry point, so it makes sense for that window closing to end the app. The situation above sounds like an interesting mystery deserving of more investigation, though! Share some repro!
|
# ? Aug 6, 2018 12:26 |
|
iirc for windowed applications you should use Application.Exit() rather than Environment.Exit().
|
# ? Aug 6, 2018 12:56 |
|
EssOEss posted:Most desktop apps tend to just have a "DoMainWindowStuff()" as the last call in their entry point, so it makes sense for that window closing to end the app. The situation above sounds like an interesting mystery deserving of more investigation, though! Share some repro! The exception thrown is: code:
The real mystery is why is there a difference between when the window has lost focus (the above exception occurs), and when the window has never lost focus (process terminates with return code 0). Alas, my search ends here, as there are no further paths to explore, and the fix is to close the window before exiting.
|
# ? Aug 6, 2018 17:09 |
|
LongSack posted:I have had issues in the past where closing the main window does not terminate the application. Never been able to puzzle out why, no unclosed windows, so its something else. Because of this, in the method that actually closes my application, I got into the habit of calling Environment.Exit(0) as a final step. Typically, this happens if you still have another thread running in your process. Windows doesn't treat the UI thread differently to any other threads running in your process, so just because all your windows have been closed doesn't imply that Windows should end your process. You should see the other threads in the debugger in VS and figure out where they came from and why they weren't shut down before you closed your application's main window. If you're cleaning up your resources correctly, you shouldn't have to call Environment.Exit(0) in order to force your process to end.
|
# ? Aug 6, 2018 18:29 |
|
LongSack posted:Not sure what msctf.dll is, there is scant information about it It's the client side of Text Services Framework, which provides advanced text input features
|
# ? Aug 6, 2018 22:47 |
|
beuges posted:If you're cleaning up your resources correctly, you shouldn't have to call Environment.Exit(0) in order to force your process to end. Agreed, it’s down to laziness on my part, where if the cause wasn’t immediately obvious, I was like “welp, gently caress it ... Environment.Exit()” I understand a lot more about WPF than I did then, so I think I will get out of the habit of doing that, since - by definition - if closing the main window doesn’t end the application I’ve done something wrong. (Yes, I know there are situations where you might deliberately choose to do something else when the main window closes.)
|
# ? Aug 7, 2018 01:14 |
|
We use a library called RazorLight in one of our projects to render Razor strings to HTML strings. This has been working well enough up until our recent transition to .NET Core 2.1 from .NET Core 2.0. For some reason we're now getting a huge exception that basically says (in my interpretation) none of the core library stuff can be found: RazorLight.Compilation.TemplateCompilationException: Failed to compile generated Razor template: - (3:35) The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (3:63) Predefined type 'System.String' is not defined or imported - (3:79) Predefined type 'System.Type' is not defined or imported - (3:10) Predefined type 'System.Void' is not defined or imported - (7:69) Predefined type 'System.Boolean' is not defined or imported - (7:37) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (10:66) The return type of an async method must be void, Task or Task<T> - (10:61) The type name 'Task' could not be found in the namespace 'System.Threading.Tasks'. This type has been forwarded to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' Consider adding a reference to that assembly. - (10:66) 'GeneratedTemplate.ExecuteAsync()': return type must be 'Task' to match overridden member 'TemplatePageBase.ExecuteAsync()' - (10:66) The type 'Task' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (12:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (12:12) Predefined type 'System.Object' is not defined or imported - (12:25) Predefined type 'System.Int32' is not defined or imported - (12:28) Predefined type 'System.Int32' is not defined or imported - (12:31) Predefined type 'System.Boolean' is not defined or imported - (12:12) Predefined type 'System.Void' is not defined or imported - (13:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (13:12) Predefined type 'System.Object' is not defined or imported - (13:25) Predefined type 'System.String' is not defined or imported - (13:12) Predefined type 'System.Void' is not defined or imported - (14:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (14:12) Predefined type 'System.Object' is not defined or imported - (14:12) Predefined type 'System.Void' is not defined or imported - (15:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (15:12) Predefined type 'System.Object' is not defined or imported - (15:25) Predefined type 'System.Int32' is not defined or imported - (15:28) Predefined type 'System.Int32' is not defined or imported - (15:32) Predefined type 'System.Boolean' is not defined or imported - (15:12) Predefined type 'System.Void' is not defined or imported - (0:2) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (0:2) Predefined type 'System.Object' is not defined or imported - (0:2) Predefined type 'System.Void' is not defined or imported - (21:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (21:12) Predefined type 'System.Object' is not defined or imported - (21:12) Predefined type 'System.Void' is not defined or imported - (22:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (22:12) Predefined type 'System.Object' is not defined or imported - (22:25) Predefined type 'System.Int32' is not defined or imported - (22:29) Predefined type 'System.Int32' is not defined or imported - (22:33) Predefined type 'System.Boolean' is not defined or imported - (22:12) Predefined type 'System.Void' is not defined or imported - (23:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (23:12) Predefined type 'System.Object' is not defined or imported - (23:25) Predefined type 'System.String' is not defined or imported - (23:12) Predefined type 'System.Void' is not defined or imported - (24:12) The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. - (24:12) Predefined type 'System.Object' is not defined or imported - (24:12) Predefined type 'System.Void' is not defined or imported - (10:66) 'GeneratedTemplate.ExecuteAsync()': not all code paths return a value - (7:17) Predefined type 'System.Void' is not defined or imported See CompilationErrors for detailed information at RazorLight.Compilation.RoslynCompilationService.CompileAndEmit(IGeneratedRazorTemplate razorTemplate) at RazorLight.Compilation.RoslynCompilationService.CompileAsync(IGeneratedRazorTemplate razorTemplate) --- End of stack trace from previous location where exception was thrown --- at RazorLight.Compilation.TemplateFactoryProvider.CompileAsync(IGeneratedRazorTemplate razorTemplate) at RazorLight.Compilation.TemplateFactoryProvider.CreateFactoryAsync(String templateKey) at RazorLight.RazorLightEngine.CompileTemplateAsync(String key) at RazorLight.RazorLightEngine.CompileRenderAsync(String key, Object model, Type modelType, ExpandoObject viewBag) Does anyone know what would be causing this?
|
# ? Aug 7, 2018 02:53 |
|
a hot gujju bhabhi posted:
Seems like this GitHub issue fits the bill. Seems multiple people have "workarounds" but the issue is still open.
|
# ? Aug 7, 2018 03:13 |
|
Drastic Actions posted:Seems like this GitHub issue fits the bill. Seems multiple people have "workarounds" but the issue is still open. I did find that, but none of the suggestions seemed to help. The problem is when I try it in a console app it works just fine. It's something related to this project I think - to clarify: it's being used in a class library that is in turn being used in an MVC project. All of our projects are targetting .NET Core 2.1.
|
# ? Aug 7, 2018 03:22 |
|
hackbunny posted:It's the client side of Text Services Framework, which provides advanced text input features Interesting. Would this be related to the fact that I have a Russian language keyboard installed?
|
# ? Aug 7, 2018 03:24 |
|
a hot gujju bhabhi posted:I did find that, but none of the suggestions seemed to help. I should also mention we're using Linux Docker containers, but as far as I can tell that makes no difference - the console app also works when run within a docker container running the same image as our other project.
|
# ? Aug 7, 2018 03:36 |
|
Hello thread, I discovered I have to suddenly learn C# for work in order to develop Windows programs and I was wondering if there are any recommended books. I am already familiar with programming in C and C++, but I have never written code for Windows and I have no idea what .NET is. I would also appreciate feedback on recommended unit testing frameworks and practices. The OP mentioned some information about these but it looks like it hasn't been updated in a while so I just wanted to be sure.
|
# ? Aug 7, 2018 04:25 |
|
qsvui posted:Hello thread, I discovered I have to suddenly learn C# for work in order to develop Windows programs and I was wondering if there are any recommended books. I am already familiar with programming in C and C++, but I have never written code for Windows and I have no idea what .NET is. Are you talking about Windows desktop applications? Are these greenfield or are you maintaining existing applications? Fundamental unit testing practices haven't changed much in recent years. XUnit / NUnit are still excellent testing frameworks that are widely used. MSTest had "v2" open-source rebirth recently and it's fine, too. The Art of Unit Testing is still my go-to recommendation.
|
# ? Aug 7, 2018 04:44 |
|
qsvui posted:Hello thread, I discovered I have to suddenly learn C# for work in order to develop Windows programs and I was wondering if there are any recommended books. I am already familiar with programming in C and C++, but I have never written code for Windows and I have no idea what .NET is. For C# itself, as a reference work, I highly recommend this book, although I must stress that it is a reference and not a tutorial. For WPF, check out this book, which I found helpful. Edit: for a tutorial, try this book. Second edit: if you are not familiar with the MVVM model, learn it and use it - just my humble opinion, of course. LongSack fucked around with this message at 05:04 on Aug 7, 2018 |
# ? Aug 7, 2018 04:58 |
|
New Yorp New Yorp posted:Are you talking about Windows desktop applications? Are these greenfield or are you maintaining existing applications? I believe I will be working on new desktop applications. LongSack posted:For C# itself, as a reference work, I highly recommend this book, although I must stress that it is a reference and not a tutorial. For WPF, check out this book, which I found helpful. Thanks for the suggestions!
|
# ? Aug 7, 2018 05:21 |
|
qsvui posted:I believe I will be working on new desktop applications. I linked the wrong book for the tutorial (not that that book is necessarily bad, but it's not the book I was thinking of). I meant to link this book.
|
# ? Aug 7, 2018 15:28 |
|
LongSack posted:Interesting. Would this be related to the fact that I have a Russian language keyboard installed? Nah, Russian is one of the easy ones, just a key map for your keyboard. Text Services is there on the off-chance you need to input, say, Japanese, or provide text to an external spell-checker or dictionary lookup, stuff like that (not that I've ever seen any of that stuff on Windows, compared with macOS). Once upon a time, you had three layers of complexity to text input in Windows: simple keyboard layouts, built into Win32, which are good for the vast majority of languages in the world; Input Method Manager (IMM), to support input methods that don't fit on a standard PC keyboard (originally and notably, Chinese, Japanese and Korean writing); and Text Services Framework, which is extremely complex and a huge superset of IMM (fully bidirectional instead of input-only, supports rich text, etc.). You used to have to go out of your way to even load IMM and TSF, but I think nowadays even the standard Edit control from Common Controls has full support, so it would make sense that WPF enabled it by default, too. In a world where even Notepad loads it, you should make peace with it hackbunny fucked around with this message at 00:44 on Aug 9, 2018 |
# ? Aug 8, 2018 19:59 |
|
hackbunny posted:interesting information Thanks!
|
# ? Aug 9, 2018 00:38 |
|
This is sort of an odd question but it keeps popping up: Why is Virtual a thing? I learned in Java so all you had to do was override the method. Everything was 'virtual' in that way. I can understand the use of having sealed to disallow it, but I don't understand the reason for it allowing 'hiding' or whatever it does if you give a child class an override with the same name as an inherited non-virtual method. I'm sure there is a reason.
|
# ? Aug 9, 2018 01:02 |
|
Magnetic North posted:This is sort of an odd question but it keeps popping up: Why is Virtual a thing? I learned in Java so all you had to do was override the method. Everything was 'virtual' in that way. I can understand the use of having sealed to disallow it, but I don't understand the reason for it allowing 'hiding' or whatever it does if you give a child class an override with the same name as an inherited non-virtual method. I'm sure there is a reason. In C++, method are normally just functions with addresses that are determined at compile time (and the object is just like an extra hidden argument). This means that you normally don't have dynamic dispatch: you could shadow methods in the subclasses to hide and sort of fake override them (I assume) but the compiler has to be able to determine which function to call at compile time. If you want dynamic dispatch (so you don't need to know which subclass an object is an instance is when you call a method), you mark the method as virtual. In this case, rather than using a function that's determined at compile time, it uses a vtable (an array of function pointers). Instances have a pointer to the proper vtable, and when you call the virtual method it actually indexes into the vtable at runtime to figure out which function to run.
|
# ? Aug 9, 2018 01:34 |
|
I would say the main reason is intent. You are not supposed to derive from a class unless the author of that class intends you to do so. You are not supposed to override a method unless the author of that method intends for it to be overridden. Extending code that was not meant to be extended is a recipe for creating large piles of garbage code. The virtual keyword is the way that the author can signal this intent to the compiler. The sealed keyword is the equivalent for deriving from a class, though unfortunately it works the wrong way around (it should instead be "extensible" or such, with default being sealed).
|
# ? Aug 9, 2018 04:26 |
|
Yeah, virtual is a very important part of a class's contract and shouldn't just blindly be applied to everything in the way Java normally does. As a base class, making a method virtual means that you can't rely on it doing what you expect it to do in derived classes. Consider the following example:code:
code:
Allowing people to break your assumptions is something you should always be opting into (by adding a keyword to allow it), not out of (by adding a keyword to disallow it).
|
# ? Aug 11, 2018 00:53 |
|
|
# ? Jun 8, 2024 15:05 |
|
In Visual Studio 2015, if I have a class which doesn't inherit anything It looks like this in the solution explorer But if I subclass e.g. WebClient It looks like this in the solution explorer (the icon has changed) When I double-click the file, it opens in Design view. This is not what I want. The design view provides a link to "add components to my class". Is this because WebClient is a subclass of Component?
|
# ? Aug 15, 2018 16:15 |