Click here to Skip to main content
15,077,931 members

Comments by lmoelleb (Top 82 by date)

lmoelleb 15-Oct-21 4:51am View
What is QueuedTask? Sure I can take a guess and think it is some ArcGIS stuff based on other bits of the code - but it should not be necessary for readers of your question having to guess something as fundamental as this. And why not write what the 5 errors are - they are likely generic, meaning even programmers not using ArcGIS could help you.
lmoelleb 15-Oct-21 2:27am View
Isn't the "address space" as seen by the file system being mapped in the SSD for wear leveling? So the file system might issue an order to overwrite a block, but then the SSD controller decides to shift this block to a new location in the flash memory instead of overwriting the original location. I would expect trim (or the internal GC of the SSD) to take the data out, but I have no idea if it can still be recovered until an actual overwrite - and if you can trust the trim to be executed 100% reliable.
lmoelleb 12-Oct-21 10:07am View
You can't replace the attribute for an existing class. This is set at compile time. You could in theory generate a new class (using Roslyn or Reflection.Emit), but this sounds too much like an XY problem. An XY problem is: You have problem X. You think of solution Y. You can't implement Y so you ask for help finding a way to implement Y. You should ask for X instead, as there might be a better solution than Y. So what is the problem you are trying to solve?
lmoelleb 12-Oct-21 4:01am View
It will work, bug cramming everything into one line serves two purposed: 1) Makes you feel clever, 2) Makes the code just a bit more unreadable. The best thing to do as a programmer is to accept you are not clever (we get reminded every day as we work) and keep the simple easy to read - which means each line preferably should do one thing. So I would make a method as suggested, or at least assign it to a variable (with a proper name) and then create the XML on the next line.
lmoelleb 5-Oct-21 13:13pm View
lmoelleb 5-Oct-21 13:13pm View
lmoelleb 28-Sep-21 4:04am View
I recommend you go through tutorials showing you how to use MVVM. WPF is hard to learn for a beginner. If it is worth it depends on how much you will use it (or derived tech like .NET Core MAUI in the future). If you just want a quick UI and won't spend much time on client UI in the future, I recommend using WinForm. It is less powerfull, but also easier to understand.
lmoelleb 20-Sep-21 7:26am View
The program starts executing by calling Main. Startup.cs sounds like the ASP.NET concept and is not relevant for anything but web sites. But you can create a class called Startup and call it from Main.

Not sure what you mean with "pfx certification". What is the goal of this .pfx authorization? I.e. "I have problem X, I want to solve it with pfx certification authorization" - what is X in this sentence? And who or what passed "pfx validation" how?
lmoelleb 15-Sep-21 3:12am View
Working with dates as strings is extremely error prone. I am not sure if it is the cause of your problem, but personally I would never try to troubleshoot code like this before I had changed it as follows: 1) All dates where passed as DateTime or DateTimeOffset parameters to the SQL query - never as strings, and never concatenated into the SQL statement. 2) The API only accepts and return dates in ISO 8601 format (or even a subset of the format, i.e. first I would disallow "local time" as you never know when that is).
lmoelleb 27-Aug-21 6:38am View
I would create a simple .NET Core or .NET Framework MVC app following a tutorial. Once that is working, use the network tab of the browser to see where your requests goes wrong. It is hard to get this working without knowing 100% what needs to go on the wire.
lmoelleb 1-Aug-21 3:35am View
Please go to YouTube and watch the video 8ZtInClXe1Q (how NOT to Store Passwords! - Computerphile). It manages to be entertaining and educating at the same time. In case you think storing a hash is good enough, then no. That is what is referred to as "Naïve attempt number 3" in the video. So yes, also avoid "Password Storage: How to do it" here on code project - it is simply not safe.

Do you know you can let people sign in with Google/Apple/Microsoft ID, facebook accounts, corporate Office 365 accounts, ... - all for free and you can even allow Office 365 from enterprises without the company the email belongs to having to do anything to allow it. It has a bit of a steep learning curve, but once you have gone through that, the code is a lot simpler than storing local accounts.
lmoelleb 27-Jul-21 8:05am View
It is a rather complex issue for a reply to a comment.
Typically you layer your code in three layers. 1) Lowest persistent - database, whatever - this is implementing an interface/base classes allowing you to swap it out. 2) Domain/Business logic. This drives EVERYTHING, and is what you must call to get anything done. It will call the persistence layer as needed. 3) However many frontends you need - for example WebAPI with controllers for a REST API, your signalR hub, a command line tool, ...

As soon as you write a controller it is tied to the REST infrastructure. Your SignalR hub will be tied to the SignalR infrastructure. By moving the actual logic to the domain layer, you avoid the SignalR hub having to pretend it is a REST context as well or the other way around. The more contexts you need to deal with from within a single class, the more complex it gets - and it will get complex fast, once you start thinking about things like authentication/authorization etc.

The trick is that you do not entangle things. A controller necessarely needs to understand what a REST context is. But your SignalR context will be different. So if you try to make one
lmoelleb 26-Jul-21 8:54am View
It looks like an XY problem to me.
Problem X: How do I ensure the SignalR hub and controller runs the same code.
Solution Y: I could call the controller from the SignalR hub. Oh, I can't figure this out, let me ask how it is done (instead of asking how X is done).

So yes, I made an assumption which I probably should not. But then.... neither should you call your controller from your SignalR hub.
lmoelleb 26-Jul-21 8:54am View
Correct. It says what you should do, not how to get the wrong solution working.
lmoelleb 26-Mar-21 4:40am View
Just out of curiosity - did you try debugging this? I know for a beginner debugging might seem like an advanced topic you can learn later. But it in reality it is simple and extremely useful. It will save you many hours even in the first week of programming.
lmoelleb 24-Mar-21 7:54am View
Are you disposing everything related to the database that implements IDisposable?
lmoelleb 16-Oct-20 2:21am View
I think your use of terminology confuses quite a lot. Interfaces do not consume endpoints - they define things. Controllers exposes endpoints so that is indeed what you need here (and can also consume other endpoints defined elsewhere, but in your case this is not needed as far as I can see). You seem already having the start of "something", so what is the current problem exactly. Is it not doing what you expect? Is it doing what you expect so far, but you do not know how to proceed - in that case, what would be the next step you try to achieve?
lmoelleb 26-Mar-20 4:45am View
C# is a programming language that can be used in a lot of environments (command line, WinForm, WPF, Unity3D (and other game engines), websites, Xamarin (mobile), ...
Drawing something differs between all of these environments, so you need to provide information on which environment you want to use. We do not want to spend half an hour telling you how to do something in a web site, just to be told it is a WinForm application you want. :)
lmoelleb 18-Feb-20 2:44am View
Maybe an unhandled exception?
And your using statement only works as expected with C# 8, so check you are not compiling with an older language version.
By the way, 65535 is rather suspicious. This is the maximum length that can be represented with 16 bits and extremely small for a screenshot. Not sure where you see it is 65535, but I would doublecheck it.
lmoelleb 3-Feb-20 4:37am View
Hint on how to debug: Place the breakpoint inside the lambda (so the call to x.GetType()...)
Once it hits, try running x.GetType().GetProperty(...) in the intermediate window of Visual studio. Observe the data it returns. It will not be what you expect....
lmoelleb 31-Jul-19 8:09am View
What does "open exe" mean? Running it? If so, where is it supposed to run? On the same computer? If so, look into the Process class - that can be used to run an exe file. If this is not the solution you are looking for, you need to provide WAY more details.
lmoelleb 30-Jul-19 8:08am View
This is unlikely to be related to your C# code. More likely it is the tool building the installer that is causing issues. So start by googling the problem - including the name of whatever you use to create the MSI. If you can't find a solution, then ask with details on how you build your MSI.
lmoelleb 29-Jul-19 3:33am View
This is all client side stuff. So debug it as such. Use the browser DOM navigator to see if the expected elements are present, if they contain the expected values, and if the stle is as expected. The browser will allow you to change values and styles directly so you can experiment easily without rerunning the code. Once you know why the field is not displayed, you are either able to fix it, or you can ask a more precise question here.
lmoelleb 6-Jul-19 11:09am View
No. It appears you believe you are using a forum. You are not. You are using the Q&A section. You should edit your original question to make it clear, not keep repeating yourself in the comments. And stop writing words in capitals, makes it hard to read. I am just trying to help you understand how to increase the chance of getting answers to your questions. If you do not want to follow the advice fine, I guess it is not important to you to get an answer.
lmoelleb 4-Jul-19 3:49am View
Writing in all capitals is not a nice thing to do, stop it. I do not know how to do what you are requesting, so I am trying to give you advise on how you can improve the chance of someone else being able to help you. You are on the questions and answer page, but you appear to think it is a forum. It is not. Make it EASY for people to help you by ensuring the actual question (not comments, the question at the very top) is not filled with irrelevant stuff an clearly identify what you have tried and where you are stuck - with as little code as possible (for example, you do not want to loop over pages, so why is it in your example code).
lmoelleb 3-Jul-19 7:09am View
I recommend updating the question to be specific, don't just write comments here - why should people read that? Change the question to ask how to get text inside a rectangle in a PDF, and remove all the unimportant things like updating textbox as you clearly already know how to do that (your original code did it). The more specific you are, the more likely someone with the required knowledge can reply (or even more likely: you can google it).
lmoelleb 2-Jul-19 11:45am View
If you can't see where the code loops over the pages and process them one by one, then you need to go back to the c# tutorials - and run it through th debugger line by line. Copying code samples from various sources is fine, but always examine the code and learn how it works.
lmoelleb 2-Jul-19 6:47am View
Start by being specific in your question. What do you want instead of all pages? A single page? A section of a page - if so, how is that section specified? If it is a single page and you do not know how to adjust this example, then I recommend you follow basic C# tutorials so you understand each line in this simple example - if you understand what each line is doing it is trivial to change it to a single page.
lmoelleb 2-Jul-19 3:16am View
And why is a VB.NET question tagged with C#?
lmoelleb 2-Jul-19 3:15am View
What exactly is "a setup in visual studio"? A WIX project, your own custom command line program, a WinForm application, one of those old setup projects old versions of Visual Studio used to support, ...
lmoelleb 27-Jun-19 14:26pm View
Yes, you are in trouble. Few people use an SDK for hardware like that, and as only a small percentage of developers answer questions on forums like this, specifically when the question is "I know nothing, tell me everything", I do not think you should put your hopes too high. For SQL, the main problem for you would be to choose between the few million tutorials you find by googling for C# and the name of your database. If you try to follow one of those tutorials and run into a specific problem you can easily get help here, but don't expect any help if you can't even say which tutorials you have been trying.
lmoelleb 27-Jun-19 7:22am View
Don't think of it as one problem. Solve two sub problems: 1) How do I get a fingerprint template from the device, 2) How do I store data in the SQL database. As soon as you combine the two (rather unrelated tasks) it becomes harder to google for solutions.
lmoelleb 25-Jun-19 5:20am View
And what did the debugger show on that line you tried?
lmoelleb 24-Jun-19 5:58am View
There is only one internet, so it should be easy: Hardcode "The Internet". But I guess this is not what you want, so you should probably provide more information - I am certainly not going to install DU Meter to see what it is doing. Do you want to display Ethernet adapter name, wifi network name, the name Windows assigned to your network, something else?
lmoelleb 23-Jun-19 11:57am View
Typically GetMethod returns null if the binding flags are not correct. But if you get the value of the property and you know it implements IWrite - why not just cast it to IWrite and call SaveToFile directly?
lmoelleb 20-Jun-19 6:54am View
I gave you a list of 3 options to choose from to tell us where you are stuck. We do not want to waste our time telling you something, just to be told you already know that part. So please update your question with details based on these three options.
lmoelleb 20-Jun-19 6:48am View
I am not sure what you are asking? 1) How to write any test? 2) How to run the test? 3) How to test this specific method (meaning you can already run a dummy test that does nothing)
lmoelleb 17-Jun-19 6:58am View
One of your lines appears to add 10. The other one does nothing. As we do not know where you store the number on the card, we can't tell you how to read it. Typically you would have the current card stored in a variable somewhere, in that case you can just add currentCard.Points or similar - but then you of course need to set currentCard when it becomes current. :)
lmoelleb 15-Jun-19 8:51am View
And what does debugging show you? Incoming data on the backend as expected? Outgoing data? Where does the JavaScript encounter "nothing"? What did you expect this "nothing" to be? In case you think debugging is an advanced topic you will learn later, you are wrong. Debugging is simple and extremely useful. I can't think of a more important skill, no matter if you are just starting programming or have 30+ years experience. Learning to use a debugger takes 5-10 minutes. With both JavaScript and C# backend code, you need to learn VS and browser debugging. So then you might be looking at spending a whopping 10-15 minutes on a skill that will save you hours on even the smallest project.
lmoelleb 9-Jun-19 4:53am View
In a lot of cases it is not advisable to use a transaction scope anywhere :). Where the correct level is for your application is impossible to say - you do not have the experience to determine it, we do not have enough insight into your application to determine it. So the best approach is to implement it in the least complicated way, then be ready to change it if needed. The last option I give (generate invoices on read) or the comment I made about high scale systems using a background queue both could satisfy the requirement of not needing transactions in the business layer. Saving the invoice data can be handled by a single transaction in the data layer. Generating an invoice in the data layer in order to avoid transactions in the business logic is not an option, as you would just move business logic into your data layer - meaning you would still have transactions in your business logic AND you would have business logic code in your data layer code. Worst of both worlds.
lmoelleb 5-Jun-19 9:16am View
Looks more like something for the forum than the Q&A section. So consider asking in there.
lmoelleb 4-Jun-19 7:17am View
That's a lot of code. Where did you find the suspicious parts when using the debugger?
lmoelleb 3-Jun-19 15:15pm View
Main window. And be prepared to move things around, you will learn as you go.
lmoelleb 3-Jun-19 14:55pm View
Any reason you can't use WCF and read the headers like specified here: - while my hate towards WCF is quite noticeable, manually parsing SOAP messages isn't too high on my wish list either :)
lmoelleb 3-Jun-19 4:43am View
Thomas already provided an answer, but for the future: You can set breakpoints in the lambdas. This will allow you to examine the call to substring with a debugger.
lmoelleb 29-May-19 8:20am View
From what I can see with a quick glance (I am not going to read all of that in detail) non-uniform just means you have 3 or more layers and do not use the same approach to communicate between them, while in uniform it use the same approach between all layers. From my quick view I do not agree with his definition of entity and DTO, so I will not comment on that.
lmoelleb 29-May-19 3:06am View
How much can you replace? This looks like something you would do with a message bus, but there are other options (UDP as already used, named pipes, …). There is no problem instantiating COM objects from multiple applications at the same time, so it is something implementation specific you encounter, not a general limitation of COM in .NET. And I just need to know... why VS2008? It is kind of... old...
lmoelleb 29-May-19 2:54am View
I can't solve the issue for you (no idea what gupta is), but I can say you should not be spending too much time investigating Windows versions. All current versions of Windows supports Russian text without any problems.
lmoelleb 24-May-19 2:09am View
Include details on which line the error is on - please do not waste our time by not providing readily available information provided straight from the compiler giving you the error. Also please change the title to match what you are asking. You are NOT asking how to do contrast stretching of an image. You are just stating you get an error (and I assume, would like help on that?)
lmoelleb 22-May-19 13:51pm View
No idea. I needed it back in the .NET 1.0 days, so I had to write my own, I just googled the format. PCM (uncompressed). Maybe NAudio can do it, not sure.
lmoelleb 22-May-19 6:19am View
You need to ask a question. Telling what you want and dumping some code on us is not asking a question. Debug your code, find out which line does not behave as you expect. Examine any errors (google them if you do not understand). If you still do not know why it fails, then ask a question including all details - the error you get, which line you get it on, what you expected the code to do, ...
lmoelleb 22-May-19 1:24am View
Great. For doing it block by block, this is beyond what you would do with a single regex. Loop over the blocks and then use your regex with the text of each block. You can use another regex to identify the blocks - or often string.IndexOf and string.SubString will do.
lmoelleb 22-May-19 1:23am View
Great. For doing it block by block, this is beyond what you would do with a single regex. Loop over the blocks and then use your regex with the text of each block. You can use another regex to identify the blocks - or often string.IndexOf and string.SubString will do.
lmoelleb 21-May-19 15:20pm View
Copy the source text of the web page from the debugger and paste it into the Test String field on Now start typing the regex. Observe how will show you what is matched. Hover the mouse over the colored parts of the regex, and it will give you a sentence telling you what it matches. If you just keep trying stuff in C# you will never get it right. If you are not willing to use or a similar tool, then regex is not for you, and you should write the code with IndexOf and Substring etc. Once you have it working on regex101, move it to C# (making sure to escape it as you did earlier). Still can't figure it out, google "regex tutorial" - there are tons of them. If all you want is someone to supply you the regex, then you are better of avoid regexes in that case. They are useful, but you need to invest time in learning how to use them.
lmoelleb 21-May-19 14:05pm View
So search replace " -> "" is a hell of a lot of editing - I have some bad news about how simple that editing is in the context of programming. :)

Did you look careful at the source text? Copy paste it from the debugger into regex101 and check it match. When I look at the source from the website, I find HTML escaped text. So it is not "width". It seems code project is automatically adjusting the text we write, hence the example in your post no longer match the source). So either change HTML decode the source first, or adjust the regex to match " instead of ". Regex101 can help you with this - just copy the source text over, start building up the regex based on my example. Do NOT copy over the entire regex, type from the start and see the match changing as you go. If you copy all at once, nothing will match and you can't see when you make the regex either better or worse.
lmoelleb 21-May-19 8:24am View
At this point you have to start debugging. If you don't know how to use a debugger, you need to learn it. It is the single most important skill for a programmer. Also remove empty catch statement. How are you supposed to find out why things are not working when you ignore errors?
lmoelleb 21-May-19 6:15am View
Let me guess. Your current solution is included here:
lmoelleb 21-May-19 5:24am View
Next step is to debug your problem. If you do not know how to use a debugger, learn it. It is the most important skill for any programmer, more important than knowing how to call an API.
lmoelleb 21-May-19 5:08am View
Don't just throw a bunch of code here and expect people to do your work. Use the debugger, isolate the line where the result is not what you expect. Then spend time trying to figure out why it behaves as it is doing. Once you have done that, update this question. be specific on what you expect to happen and what actually happens on the line where it goes wrong. If you do not know how to debug, learn it. Programming without debugging is a waste of time.
lmoelleb 20-May-19 23:58pm View
I click the link to regex101 and see no errors. Where do you see errors, and what are the errors. Please never report something like "load of errors", always include at least one precise example of what the error text is and where you see it. The regex contains " and \, which must be escaped when you copy it as a string into your c# source - is that the problem? I can't say for sure without precise information.
lmoelleb 20-May-19 14:00pm View
I added an example regex - the included link to will take you to a site where it is already filled in allowing you to play around with it easily.
lmoelleb 18-May-19 3:03am View
Quoting from the very link you are providing: "It does not specify whether the cloning operation performs a deep copy, a shallow copy, or something in between". There is no built in interface that guaranties deep clones in .NET. Sure you can use ICloneable for it, just be aware that simply because an object implements ICloneable, you can't guarantie it is a deep copy without further information (you wrote it yourself, it is documented, you read the code, …). You call that an imaginary problem. I call it something to be aware of so it does not become a real problem. I have done my share of cloning, including everything from cloning in the constructor over ICloneable, custom IDeepCloneable etc all the way to emitted code with reflection. Can you please point me in the direction of what additional information I can study on this subject?
lmoelleb 17-May-19 13:14pm View
Implementing it as a deep copy is your preference. It is not something that is prescribed by the interface nor its documentation (on the contrary). This means every time you see the interface you have to think "is this one of my deep clones, or do I reference something written by another guy who might have done something else". To me, the interface just isn't worth using when I have to deal with potential future problems.
lmoelleb 17-May-19 13:14pm View
Implementing it as a deep copy is your preference. It is something that is prescribed by the interface nor its documentation (on the contrary). This means every time you see the interface you have to think "is this one of my deep clones, or do I reference something written by another guy who might have done something else". To me, the interface just isn't worth using when I have to deal with potential future problems.
lmoelleb 17-May-19 10:58am View
Be careful with ICloneable - it does not specify if a clone is deep or shallow.
lmoelleb 2-Apr-19 4:42am View
I do not consider my personal preference to be the definition of "normal". :D
But as mentioned - if you really want a warning here, that would be something for a code analyzer, not the core compiler.
lmoelleb 2-Apr-19 4:37am View
Personally I prefer avoiding the style, but I would not go so far as saying it is not normal, nor that it should be avoided in all cases. Maybe you can find (or write) a code analyzer if you prefer avoiding it? That way you will get a warning.
lmoelleb 2-Apr-19 4:24am View
Make some HTTP requests :) Observe the requests made from your browser to see how it retrieves the data you want. It will probably be in violation of the terms of service of google maps and they are likely to have something in place to block you if you download too much. If you distribute the data to others, I would expect it to be in violation of copyright laws as well.
lmoelleb 2-Apr-19 4:19am View
The operation is doing exactly what this operation has been doing for many decades across multiple languages - so what exactly should the warning be? Something like "If you do not know how this operation works it might give a different result than you expect"... but that goes for everything. :)
lmoelleb 28-Mar-19 6:08am View - it was not exactly hard to google.

This is XAML where the view is defined, so doesn't matter if you use VB or C#. There is one peace of C# example code, but it is very simple - just checking the window width and calling a method.
lmoelleb 28-Mar-19 6:01am View
Hard to say without the use case known. Are users of Excel also executing the macro? Are macros meant to be written by people who know Excel, but do not have the knowledge to program C# - or even access a development system. If they use Office 2000, it is probably not the most progressive environment this is needed in. :)
lmoelleb 26-Mar-19 4:39am View
Isn't it Office 2013 that is version 15? So your office installation on the machine is 13 years too old for the COM wrapper you use?
lmoelleb 26-Feb-19 4:33am View
Please update your question with this information, and as much detail as possible (what exactly do you see then debugging your model if setting for example 01/02/2020), what regional settings do you use. And from what you write here it has nothing to do with the database? So remove the part about inserting/saving to the database it just makes the question less clear.
lmoelleb 25-Feb-19 9:49am View
Googling "ironpython wpf" or "itonpython opengl" shows several results - if you tried using these resources, please provide details on where you are stuck or why you need more information. If you didn't try... why not? :)
lmoelleb 27-Nov-18 3:37am View
Run a debugger so you can see the exact line it fails on, then google the error message if it is not clear from the location and variable values (yes, even us professionals do that on the more obscure errors). If it does not solve it, make a smaller peace of code that reproduce the problem, then post it in a question using proper formatting so we can read it.
In general debugging is the primary skill to learn - you will spend more time in the debugger than typing code... so make learning it a priority.
lmoelleb 27-Nov-18 3:33am View
Option 1: The code is valuable enough to migrate it to proper C#. This can't be done by any copy-paste converter. Option 2: The code is not worth anything, throw it away.
lmoelleb 26-Nov-18 5:28am View Search for CONTRACTS_FULL which can be used to force generating the calls, even for release builds.
lmoelleb 19-Nov-18 3:11am View
As far as I know calls to the code contract classes are removed by the compiler. So there is no performance penalty from Contract.Ensures
lmoelleb 29-Oct-18 5:45am View
Sorry, it seems I made a mistake by answering the question asked, so I guess I deserve a low vote. :P
I would choose a different test as well, but if I wanted to run the test originally asked, this is a way. Or just use a test framework that allows the user to cancel the test if it is running in an infinite loop (which is pretty much all of them as far as I know).
lmoelleb 20-Jun-18 4:24am View
This sounds like an x-y problem. You want to achieve something (x). You think you can do it in a certain way (y). You do not know how to do (y), so you ask here. Maybe you should simply ask how to do (x) instead?
Typically you will run the app constantly and have it listening for commands somehow (REST service, message queue, USB,...) and respond to it. You would not start and stop it. And as an alternative to Windows IOT, you can consider using .NET Core on a standard Linux distro - this allows you to run all the standard Raspberry PI programs and services next to your C# code - but does not allow a UI - so again, more information about the actual problem is needed to recommend anything.
lmoelleb 28-May-18 5:34am View
Hard to say as you do not provide the types, and to be honest I don't know much about how VB reacts as I never used it. But there is a general design philosophy difference in C# and VB as far as I remember. C# is "never do anything that is not clearly the intend of the developer". VB is "if there is a reasonable option that is likely to be the intend of the developer, then do it". The VB approach is really nice.... until you have spend a lot of time tracking down when it got it wrong... then you lean to hate computers trying to be smart. :)
lmoelleb 19-Jan-11 8:14am View
No. Silverlight code executes client side.