|
1. The lounge is for the CodeProject community to discuss things of interest to the community, and as a place for the whole community to participate. It is, first and foremost, a respectful meeting and discussion area for those wishing to discuss the life of a Software developer.
The #1 rule is: Be respectful of others, of the site, and of the community as a whole.
2. Technical discussions are welcome, but if you need specific programming question answered please use Quick Answers[^], or to discussion your programming problem in depth use the programming forums[^]. We encourage technical discussion, but this is a general discussion forum, not a programming Q&A forum. Posts will be moved or deleted if they fit better elsewhere.
3. No sys-admin, networking, "how do I setup XYZ" questions. For those use the SysAdmin[^] or Hardware and Devices[^] forums.
4. No politics (including enviro-politics[^]), no sex, no religion. This is a community for software development. There are plenty of other sites that are far more appropriate for these discussions.
5. Nothing Not Safe For Work, nothing you would not want your wife/husband, your girlfriend/boyfriend, your mother or your kid sister seeing on your screen.
6. Any personal attacks, any spam, any advertising, any trolling, or any abuse of the rules will result in your account being removed.
7. Not everyone's first language is English. Be understanding.
Please respect the community and respect each other. We are of many cultures so remember that. Don't assume others understand you are joking, don't belittle anyone for taking offense or being thin skinned.
We are a community for software developers. Leave the egos at the door.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
modified 16-Sep-19 9:31am.
|
|
|
|
|
After coming off of a run of a bad few days in terms of development I did a thing.
I have a device that can connect via USB but only as a virtual COM port. It can't be a HID device or anything. All communication is serial, RS232 style (even though it's USB)
I have an application that works with it, and the bluetooth stack I was using prior exploded and regressions ate my BLE code. So I wanted to make it work over serial.
I did this in C# in the app, with C++ on the MCU end.
I have created a serial negotiation system that
A) Allows the application to automatically detect a device, and which COM port it's on with no user intervention. Only valid devices will be detected.
B) Allows the serial port to *also* be used at the same time for logging output messages. A filter can be applied that would only produce log messages.
So now the silly thing is plug and play *and* it still allows me to write debug spew to the serial port without interfering with the application's serial comms.
I do it by seeding my commands with characters outside of the ASCII 7-bit range to signal a command stream. This means you get periodic "garbage" in your logs, but like i said it can be filtered out.
Anyway, after the past few days of banging my head against the wall and making rookie mistakes I pulled a rabbit out of my hat. Woo!
To err is human. Fortune favors the monsters.
|
|
|
|
|
Wordle 378 4/6
β¬β¬β¬π©β¬
β¬β¬π¨π©π©
π¨π¨β¬π©π©
π©π©π©π©π©
|
|
|
|
|
|
Wordle 378 5/6
β¬β¬β¬β¬π¨
β¬β¬π©π¨β¬
β¬β¬β¬β¬β¬
β¬π¨π©π©π©
π©π©π©π©π©
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
I am starting to learn PowerShell. I have avoided it for years, because whatever I needed to do beyond a simple BAT file, I could do in C#.
However, I am in a situation where I have to use PowerShell, so I am learning it.
One of the things I learned is that within a PowerShell script, you can call .cs files to run C# code. So this question came to mind, and I thought you all might have some opinions. I wrote a PS script that calls a .cs file and does exactly what I described. I have not mastered calling non-GAC .NET library DLLs yet, but I am working on it.
Why not use PowerShell as a management script, and write C# code to execute the "business logic"? I am not convinced that it is better to use PowerShell cmdlets to hack up some brittle script to do what can be more easily done in C#, which is far more capable and wider-ranging than PowerShell script.
This is a snippet from my script:
$Source = Get-Content "SomeCSClass.cs" -Raw
Add-Type -TypeDefinition $Source
$TestDLL = New-Object PSTest.SomeCSClass
$TestFilePath = $TestDLL.GetCurrentDirectory() + "\PowerShell Example Files\"
## Get a list of files using C# code from a static method
$Files = [PSTest.SomeCSClass]::GetListOfFiles($TestFilePath, "*.txt", 0)
Your thoughts?
|
|
|
|
|
I also avoid PowerShell, it's of no use to me either.
|
|
|
|
|
This is very welcome news. I might just want to learn PowerShell after all just for this capability.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Powershell+C#=cryptic^2
sorry no interest
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Wordle 377 4/6
β¬β¬π¨β¬π¨
β¬β¬π¨π¨π¨
π©π¨π¨π¨π¨
π©π©π©π©π©
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Lesley posted that over 12 hours ago ... still on the same page ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I know. Cut me some slack. just trying to get this wordle sharing thing down
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
We never cut slack on Leslies!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I recently implemented a small service to handle uploads from the browser to our "media server" (rather legacy, don't ask) and on our dev server, no problem. On the actual media server box, I kept getting the dreaded no-access-control-allow-origin header.
Fussed with all the IIS settings and web.config settings to no avail.
Tested vanilla POST calls, all passed CORS without issues.
Learned about "simple requests" which multiform is one of and which don't do an OPTIONS preflight request.
Found an obscure post that people were getting this CORS error on ngnix when the file size was too large.
Tried uploading a a 1K file, and it worked!
Discovered that if the file size was somewhere between by 31K and 67K test files, the larger one failed.
Discovered that if I removed the docInfo parameter:
public IActionResult Upload([FromForm] DocumentUpload docInfo)
The endpoint was hit, no CORS error.
Was thinking, geez, what is .NET 6 doing? Do I have to parse the multiform data myself?
Found a post on the topic that mentioned this code:
var form = ControllerContext.HttpContext.Request.Form;
Tried that and to my horror, it threw an UnauthorizedAccessException that c:\windows\temp\[temp file] is not accessible.
Googled, added IIS AppPool\[my application pool] as a user to c:\windows\temp.
AND IT WORKED.
Unbelievable. An unauthorized access exception results in the browser giving me a CORS error!
This took all week to figure out, spending probably 6 hours a day on it.
And the small <30K file uploads worked without problems because it didn't require creating a temp file for the stream content.
|
|
|
|
|
I have no idea what you're talking about other than the punch line, which seems to be that this house of cards is shite at generating error messages that are useful for debugging.
|
|
|
|
|
Greg Utas wrote: seems to be that this house of cards is shite at generating error messages that are useful for debugging
It's ALWAYS been this way. SQL Server is the worst.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I know what an SQL server is but had no idea the post was talking about one.
|
|
|
|
|
Hmmm,
Marc Clifton wrote: Googled, added IIS AppPool\[my application pool] as a user to c:\windows\temp.
AND IT WORKED. Are you sure that allowing your application pool to use global %TEMP% is a good idea? Everybody can read/write to that location. It's probably more secure if your application pool uses the %USERPROFILE% temp path.
I'm not an IIS expert but I think a better fix would be loading the user profile[^] for the application pool identity. You should dig around for a setting to enable that. This setting will populate your environment variables and should change your temp folder to the %USERPROFILE% temp.
Just a security recommendation. 
|
|
|
|
|
Agreed - the main point being, the absurd journey it took to discover that this was all the result of not being able to access the temp folder that .NET (or something?) was trying to use to buffer the files being uploaded.
|
|
|
|
|
I've had something similar before with something going wrong on the API, but the browser showing it as a CORS error. There's a whole flow that happens and I assume that the initial CORS request fails due to whatever is wrong in the background and the browser then just shows that CORS failed.
On a ASP.Net project I had to put a if statement in for handling CORS Options requests from Angular because it was calling the method like it would have with a normal request. Maybe just a weird setup in my case. With .Net Core I don't think the options request activates the breakpoints, although it looks like you can with some middleware: https://www.codeproject.com/Questions/5162494/Currently-I-am-working-on-angular-and-web-API-NET
Complete Guide to CORS
modified 15hrs ago.
|
|
|
|
|
Fantastic & interesting post & great detective skills.
Marc Clifton wrote: Googled, added IIS AppPool\[my application pool] as a user to c:\windows\temp.
I'm filing this one away in my brain for later use.
That is a crazy situation but I totally believe it because of horrors I've seen with similar & IIS & CORS etc.
BTW, was this change needed only on your dev box or did you have to make that change on the Server also?
This is just crazy to me. Can you post the link where you found that solution? Very interesting and quite terrible.
|
|
|
|
|
raddevus wrote: was this change needed only on your dev box or did you have to make that change on the Server also?
I've never had to make this change anywhere, whether my local devbox, our development server setup, our live servers. It occurred on an obscure server used only as a repository of uploaded files, and it had never seen a .NET application before.
I ended up install VS2022 on it to debug the situation, to some extent I'm glad the VS2022 setup didn't magically "fix" the problem.
|
|
|
|
|
One other piece of configuration you need to do: Configure Storage Spaces to run automatically and scrub the temp folder structure after 30 days. IIS is atrocious when it comes to cleaning up after itself.
|
|
|
|
|
I'm on a 5 year plan to move to Canada, which hubby and I will do assuming things continue to go south here in the states. Living in Canada will be like moving from the meth lab to the apartment above the meth lab, but at least we'll be able to breathe. Learning Canadian English should be fun. I imagine there are lots of synonyms for hockey.
Do you think getting this tattoo somewhere visible will help streamline the admission process?[^]
To err is human. Fortune favors the monsters.
modified 18hrs ago.
|
|
|
|
|
Only if it's a matching pair, and on the genitalia ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|