|
nielsm posted:Does this sound like the right approach, and what would be the pattern to implement this? Personally, I don't like using DI containers to do runtime configuration by swapping implementations. It can definitely be done, but it feels a little hokey. What if you had an IConfigurableIdentitySupplicant that took a dependency on the other two implementations, as well as a dependency on your config provider. It would use the config setting to call the correct concrete implementation. One advantage to this is that the logic providing the right implementation based on config settings would be testable.
|
# ? May 30, 2019 03:08 |
|
|
# ? Jun 1, 2024 19:14 |
|
nielsm posted:DI question, I'm using SimpleInjector to set up my application. Now I need to have a dynamic configuration, depending on a configuration setting I'd like to supply a different object for a specific interface. I think. You're probably better off injecting a POCO with the configuration setting and having your code read that and do different things based on what's in the POCO rather than having than changing which object is registered based on configuration settings. This might not matter if you only care what the setting is at application startup, but simpleinjector locks the container after the first use, so after getInstance() you won't be able to re-register.
|
# ? May 30, 2019 03:25 |
|
I've done conditional injection based on things like the type of clients calling an API endpoint in autofac and various other configuration flags etc. If you spend a bit of time to learn the library well enough you can swap out complex conditional dependency trees with a minimal amount of clear and easy to read code. In my opinion it's much nicer than passing around flags and stamping conditional logic all over the place.
|
# ? May 30, 2019 03:35 |
|
Is it possible to embed razor code within an HTML element's attribute value? I'm trying to conditionally apply a certain CSS class to 16 different elements, based on a model's property. So instead of: code:
code:
I can't just do something like code:
|
# ? May 31, 2019 15:15 |
|
code:
code:
|
# ? May 31, 2019 15:43 |
|
Munkeymon posted:
Brilliant, I must've just had some random syntax typo I'm too tired to have picked up on Friday.cs Thank you.
|
# ? May 31, 2019 16:03 |
|
Continuing the PDF talk from the previous page: I'm not sure how well this would work for a WPF application (in fact I suspect it probably wouldn't work very well at all) but something I've done in the past is generate HTML documents and then use headless Chrome to convert them to PDFs. In my case it was an ASP.NET MVC application so it worked very well, since it meant you could design and create the PDF files with the same html/css skills you were already using for the rest of the system.
|
# ? Jun 1, 2019 01:58 |
|
NiceAaron posted:Continuing the PDF talk from the previous page: I'm not sure how well this would work for a WPF application (in fact I suspect it probably wouldn't work very well at all) but something I've done in the past is generate HTML documents and then use headless Chrome to convert them to PDFs. In my case it was an ASP.NET MVC application so it worked very well, since it meant you could design and create the PDF files with the same html/css skills you were already using for the rest of the system.
|
# ? Jun 1, 2019 02:34 |
|
NiceAaron posted:Continuing the PDF talk from the previous page: I'm not sure how well this would work for a WPF application (in fact I suspect it probably wouldn't work very well at all) but something I've done in the past is generate HTML documents and then use headless Chrome to convert them to PDFs. In my case it was an ASP.NET MVC application so it worked very well, since it meant you could design and create the PDF files with the same html/css skills you were already using for the rest of the system. I like where your head is at, unfortunately I can't (realistically) include Chromium as a dependency, nor rely on my customer's necessarily even having it on their systems. I've been granted a stay of execution for at least the next couple of weeks while that feature gets pushed back a bit
|
# ? Jun 3, 2019 17:22 |
I've used wkhtmltopdf for generating PDFs, it's a standalone binary with all dependencies compiled in statically. But it's not terribly good to work with/debug and can be rather slow.
|
|
# ? Jun 3, 2019 19:48 |
|
We used EOPdf for HTML -> PDF in a previous job. I never worked with it, paid for it, or had to support it in production, but it seemed ok enough.
|
# ? Jun 4, 2019 02:36 |
|
nielsm posted:I've used wkhtmltopdf for generating PDFs, it's a standalone binary with all dependencies compiled in statically. But it's not terribly good to work with/debug and can be rather slow. I have never seen a (non-trivial) page that properly renders with wkhtmltopdf, so if you need proper styling and rendering... eeeh. Be prepared to treat it as a special browser akin to IE6. It is an unmaintained and ancient fork of Chromium, basically.
|
# ? Jun 4, 2019 10:45 |
|
redleader posted:We used EOPdf for HTML -> PDF in a previous job. I never worked with it, paid for it, or had to support it in production, but it seemed ok enough. I used this at my previous job for the same thing. Worked well enough. We were in fintech so consistent PDF generation was a must.
|
# ? Jun 5, 2019 01:57 |
EssOEss posted:I have never seen a (non-trivial) page that properly renders with wkhtmltopdf, so if you need proper styling and rendering... eeeh. Be prepared to treat it as a special browser akin to IE6. It is an unmaintained and ancient fork of Chromium, basically. https://selectpdf.com/community-edition/ I use SelectPdf Html To Pdf Converter, and haven't had any problems with styling and rendering. It even supports Javascript, so you can print your React app. The community edition is free for PDFs up to 5 pages. SimonChris fucked around with this message at 08:35 on Jun 7, 2019 |
|
# ? Jun 7, 2019 08:12 |
|
I'm working on a .net core application and I was planning on moving the database to a network server on the network instead of running on a local test DB, so I pointed the connection string to the new server, then I ran the update-database command in the package manager console and I am getting user rights issues. Ok I am not wondering about that, but this part of the message has me confused: "CREATE DATABASE permission denied in database 'master'." WTF is this application doing trying to gently caress around with the master database in the first place? Nothing in this app has got anything to do with the system databases.
|
# ? Jun 11, 2019 13:07 |
|
Well, the master database is where information about other databases is stored. So you need access to the master database if you wish to create/modify certain aspects of other databases.
|
# ? Jun 11, 2019 13:19 |
|
His Divine Shadow posted:I'm working on a .net core application and I was planning on moving the database to a network server on the network instead of running on a local test DB, so I pointed the connection string to the new server, then I ran the update-database command in the package manager console and I am getting user rights issues. Ok I am not wondering about that, but this part of the message has me confused: "CREATE DATABASE permission denied in database 'master'." You always need to connect to some database to run any query at all. If you want to create your own database from scratch, which this application is trying to do, it's standard to first connect to the default database 'master' (or 'postgres' or whatever), which will always exist. It doesn't mean you want to actually alter the default database at all.
|
# ? Jun 11, 2019 13:26 |
|
EssOEss posted:Well, the master database is where information about other databases is stored. So you need access to the master database if you wish to create/modify certain aspects of other databases. NihilCredo posted:You always need to connect to some database to run any query at all. If you want to create your own database from scratch, which this application is trying to do, it's standard to first connect to the default database 'master' (or 'postgres' or whatever), which will always exist. It doesn't mean you want to actually alter the default database at all. I had no idea that all connections to a SQL DB do an initial read from master. TIL. Thanks Goons
|
# ? Jun 13, 2019 19:10 |
|
Careful Drums posted:I had no idea that all connections to a SQL DB do an initial read from master. TIL. Thanks Goons I may be wrong, but I'm not sure that's necessarily 100% true. SQL Server logins have a default database setting. That database is used when the connection is established. It doesn't have to be master, but that's the default.
|
# ? Jun 13, 2019 20:08 |
|
zerofunk posted:I may be wrong, but I'm not sure that's necessarily 100% true. SQL Server logins have a default database setting. That database is used when the connection is established. It doesn't have to be master, but that's the default. Yeah, the user account definitely doesn't need to connect to master. Just look at Azure SQL, there's a master DB there in addition to 'your' DB, but you have no access to it. SQL Server itself needs to connect to master to allow connections to any DB, so if your master DB is hosed/unavailable, you won't be able to do anything. edit: The default DB for your user account can be specified when the user is created/edited, or you can specify it in your connection string with Database=MyCoolDB. The latter option is probably what you're missing here, and/or you're trying to create a new database and you don't have permissions to do so. B-Nasty fucked around with this message at 21:24 on Jun 13, 2019 |
# ? Jun 13, 2019 21:21 |
|
To avoid overgeneralizing, the specific error you are getting here talks about master because you are creating a database, which involves writing information about this new database to master. Presumably the login you are using does not have permissions for that, so it refuses.
|
# ? Jun 13, 2019 22:15 |
|
Anyone got any recommendations for writing an installer/msi for a wpf app? I normally do web dev, so got no ideas... What I'd like to do is install to a user-specified dir, and set some stuff in the app.config, and be scriptable so it can be run remotely/headless by the ops team. If there's a way to deal with updates too that'd be great, but I don't know enough to figure out if the stuff I'm finding like WiX or AdvancedInstaller is actually fit for purpose.
|
# ? Jun 15, 2019 10:19 |
WiX is the way to go. If you didn't need to allow headless install, customization of destination and change configuration, then I'd have suggested ClickOnce, but while it's easy it's not very flexible.
|
|
# ? Jun 15, 2019 10:49 |
|
I tried WiX once and found it a horrible mess of boilerplate. Trying to achieve even the simplest thing took 10 times more effort than I found reasonable. Has it improved in the last 5 years or is it just recommended because it is free? Advanced Installer, on the other hand, worked a treat and I was very happy with my purchase. Not sure about your specific requirements - they do not sound very complicated - but I would suggest trying Advanced Installer, as it made life quite easy for me at least.
|
# ? Jun 15, 2019 12:05 |
|
We use Wix for some end-user software at my place and when I've had to interact with it I've found it to be a bit complicated, but very flexible and ultimately I could do everything I needed to with it. I put the complexity of it down to installation on Windows just being complicated in general. Whatever you do, don't try to roll your own installer.
|
# ? Jun 15, 2019 12:54 |
|
WiX also, in my experience, is pretty stable once you've got it doing what you want. It's not intuitive to set up but once you've got it figured out you don't need to worry about it again.
|
# ? Jun 15, 2019 16:08 |
|
Currently using advancedinstaller - wish I could spring for the non-free version though, as it seems there are some options I'd like but am missing out on with free. I took a look at WiX, and if I was doing this for my day job I'd choose that, but I don't have the time to burn coming up to speed on it. I did try decompiling the advancedinstaller-generated msi with dark.exe to see what the wix xml looked like, which was interesting, but it was a bit much of a mess to read clearly, and I don't want to go down the rabbit hole of tidying it and using it as a basis for future wix work. Not sure this is the best path, but the resulting msi does what I'm after, so going to leave it at that and move on the next thing.
|
# ? Jun 16, 2019 09:18 |
|
WiX will do the job but it has the worst documentation I've ever seen in my life. You will end up confused because there are often multiple ways of accomplishing the same task and different tutorials/docs will tell you different things based on when they were written and what version of WiX they were using at the time.
|
# ? Jun 20, 2019 04:37 |
|
NoDamage posted:WiX will do the job but it has the worst documentation I've ever seen in my life. You will end up confused because there are often multiple ways of accomplishing the same task and different tutorials/docs will tell you different things based on when they were written and what version of WiX they were using at the time. It's really awful, and it doesn't help that it works alongside project files like .csproj, which if you're not using core are their own gigantic piles of XML that you better not gently caress up, mister! Edit: I converted a big project at work from using manually managed libraries (reference include hint path=path to binary included in source control ARGHGHGHGHG) to letting the package manager do its thing. Took way too long to set up a basic "harvest all the binaries in the output directory and include them in the installer". Che Delilas fucked around with this message at 18:44 on Jun 21, 2019 |
# ? Jun 21, 2019 18:41 |
|
Che Delilas posted:It's really awful, and it doesn't help that it works alongside project files like .csproj, which if you're not using core are their own gigantic piles of XML that you better not gently caress up, mister! You'd think installers would be a solved problem by now. Especially for the OS with the largest consumer install base in the world. Especially using the manufacturers own development environment. But I also thought that about GUI toolkits......
|
# ? Jun 22, 2019 07:26 |
|
I look at golang's "compiles to a single exe" with envy! To be fair, you can sort of achieve that in .NET too by embedding the assemblies into the exe but it requires extra hassle (and I bet does not work with netcore).
|
# ? Jun 22, 2019 20:41 |
|
EssOEss posted:I look at golang's "compiles to a single exe" with envy! To be fair, you can sort of achieve that in .NET too by embedding the assemblies into the exe but it requires extra hassle (and I bet does not work with netcore). The ability to generate a single exe is going to be in. NET core 3 https://www.hanselman.com/blog/MakingATinyNETCore30EntirelySelfcontainedSingleExecutable.aspx
|
# ? Jun 22, 2019 20:48 |
|
EssOEss posted:I look at golang's "compiles to a single exe" with envy! To be fair, you can sort of achieve that in .NET too by embedding the assemblies into the exe but it requires extra hassle (and I bet does not work with netcore). netcore 3 supports self-contained executables.
|
# ? Jun 22, 2019 20:48 |
|
it'll also support tree trimming and AOT compilation so you can make small + fast startup single binaries which should be cool for writing utility applications
|
# ? Jun 22, 2019 20:51 |
|
Added a unit test project to a solution I'm working on as a personal project. The unit test project itself is .NET Core 2.1 and the project it is testing is .NET Standard 2.0. Foo.Bar.csproj: code:
code:
[22/06/2019 21:42:42 Warning] Test run will use DLL(s) built for framework .NETCoreApp,Version=v1.0 and platform X86. Following DLL(s) do not match framework/platform settings. Foo.BarTests.dll is built for Framework 2.1 and Platform AnyCPU. Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings. Why the hell is it printing this warning? What's "Framework 2.1"? That link printed as part of the message is to a page with a "this page is no longer being updated" banner at the top, that talks about the difference between 32-bit and 64-bit tests - it seems totally irrelevant. The tests do actually run, but I'm paranoid that it'll arbitrarily stop running them at some point in the future. The reason I am paranoid about this is that at work, we had a build that was supposed to be running unit tests as part of the build process, but after an upgrade of the toolset on the build server the unit tests stopped running because they were no longer being detected (and Microsoft had made the extremely stupid decision that if you pointed vstest.console.exe at a DLL and told it "hey go run the tests in this DLL", and it didn't find any tests in the DLL, it should just print out a warning instead of what would be sensible, i.e. returning a failure code which would have caused our build to fail). So for a period of months we weren't running the unit tests we thought we were running on every build. I'm running VS version 16.1.3. If I go Help -> Check for Updates, Visual Studio claims that it is up-to-date.
|
# ? Jun 22, 2019 21:55 |
|
Hammerite posted:Added a unit test project to a solution I'm working on as a personal project. The unit test project itself is .NET Core 2.1 and the project it is testing is .NET Standard 2.0. I would suggest providing a run settings file and having it specify TargetPlatform, etc. explicitly (rather than relying on it figuring out what to do by itself.)
|
# ? Jun 23, 2019 01:35 |
|
Bruegels Fuckbooks posted:Have you tried making a runsettings file? I had not tried that. I tried adding this file and telling VS to use it via Test -> Test Settings -> Select Test Settings File: code:
I did try "FrameworkCore21" and "FrameworkCore20" as the TargetFrameworkVersion - neither of those is valid, it prints out an error message and doesn't run the tests.
|
# ? Jun 23, 2019 13:43 |
|
Hammerite posted:I had not tried that. I tried adding this file and telling VS to use it via Test -> Test Settings -> Select Test Settings File: I'm looking into this more and I'm seeing results like: https://developercommunity.visualstudio.com/content/problem/579073/test-discovery-reporting-dlls-do-not-match.html It might just be an open bug with visual studio 2019.
|
# ? Jun 23, 2019 14:43 |
|
Yes, it looks like that. Thanks for finding that. OK, I guess I'll just have to keep an eye on it.
|
# ? Jun 23, 2019 15:43 |
|
|
# ? Jun 1, 2024 19:14 |
|
How can I use reflection in C# to create an array (as in T[], not Array)? All I've found involves an explicit cast, but I don't necessarily know the type. What I'm trying to do is take a List of objects and feed it into a function that has a params field. I have its MethodInfo and can poke the parameters. The List has all the arguments for the params field just appended on. I need to collapse them down to an array, apparently; I got type exceptions otherwise. I'd love to know if there's a better way, by the way. So if I have: code:
"bar", 1 "bar", 1, 2.0, 3.0, 4.0 I need to convert these into: "bar", 1, null "bar", 1, [2.0, 3.0, 4.0] ...and of course use ToArray() to finish the deal. It looks like I can't use Array as an argument instead of T[]. I don't know T at compile time; I just know it for this example. Yes, there are some assumptions about my list and I assume I have to do something to cast the individual elements too.
|
# ? Jun 26, 2019 17:39 |