How should you diagnose the error SEHException – External component has thrown an exception

Yes. This error is a structured exception that wasn’t mapped into a .NET error. It’s probably your DataGrid mapping throwing a native exception that was uncaught. You can tell what exception is occurring by looking at the ExternalException.ErrorCode property. I’d check your stack trace, and if it’s tied to the DevExpress grid, report the problem … Read more

Can I control the location of .NET user settings to avoid losing settings on application upgrade?

I wanted to add this quoted text as a reference for when i have this problem in the future. Supposedly you can instruct the ApplicationSettings infrastructure to copy settings from a previous version by calling Upgrade: Properties.Settings.Value.Upgrade(); From Client Settings FAQ blog post: (archive) Q: Why is there a version number in the user.config path? … Read more

How to create a simple proxy in C#?

I wouldn’t use HttpListener or something like that, in that way you’ll come across so many issues. Most importantly it’ll be a huge pain to support: Proxy Keep-Alives SSL won’t work (in a correct way, you’ll get popups) .NET libraries strictly follows RFCs which causes some requests to fail (even though IE, FF and any … Read more

datetime.parse and making it work with a specific format

DateTime.ParseExact(input,”yyyyMMdd HH:mm”,null); assuming you meant to say that minutes followed the hours, not seconds – your example is a little confusing. The ParseExact documentation details other overloads, in case you want to have the parse automatically convert to Universal Time or something like that. As @Joel Coehoorn mentions, there’s also the option of using TryParseExact, … Read more

Compression/Decompression string with C#

The code to compress/decompress a string public static void CopyTo(Stream src, Stream dest) { byte[] bytes = new byte[4096]; int cnt; while ((cnt = src.Read(bytes, 0, bytes.Length)) != 0) { dest.Write(bytes, 0, cnt); } } public static byte[] Zip(string str) { var bytes = Encoding.UTF8.GetBytes(str); using (var msi = new MemoryStream(bytes)) using (var mso = … Read more

How do I get and set Environment variables in C#?

Use the System.Environment class. The methods var value = System.Environment.GetEnvironmentVariable(variable [, Target]) and System.Environment.SetEnvironmentVariable(variable, value [, Target]) will do the job for you. The optional parameter Target is an enum of type EnvironmentVariableTarget and it can be one of: Machine, Process, or User. If you omit it, the default target is the current process.

Editing dictionary values in a foreach loop

Setting a value in a dictionary updates its internal “version number” – which invalidates the iterator, and any iterator associated with the keys or values collection. I do see your point, but at the same time it would be odd if the values collection could change mid-iteration – and for simplicity there’s only one version … Read more

Invalid postback or callback argument. Event validation is enabled using ”

Do you have code in your Page_Load events? if yes, then perhaps adding the following will help. if (!Page.IsPostBack) { //do something } This error is thrown when you click on your command and the Page_load is being ran again, in a normal life cycle it would be Page_Load -> Click on Command -> Page_Load … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)