.net

Why am I getting this error:"Cross-thread operation not valid: Control lbFolders accessed from a thread other than the thread it was created on."?

This is baffling me, maybe somebody can shine the light of education on my ignorance. This is in a C# windows app. I am accessing the contents of a listbox from a thread. When I try to access it like thisprgAll.Maximum = lbFolders.SelectedItems.Count; I get the error. However, here is the part I don't get. If I comment out that line...

What's the Best way to Generate a Dynamic XML for Web Service?

For my web service component, I need to generate a relatively large XML (~500 lines) according to many factors. I am facing a few different choices here: 1. StringBuilder 2. XmlWriter class 3. C# object with serialization??? Which one should I use. Is there any other ways that I am not aware of? ...

Using "ref" and/or "out" for Object type

I'm stuck with .Net 1.1 application (i.e. I can not use the generics goodies from 2.0 for now), and I was trying to optimize some parts of the code. As it deals a lot with runtime callable wrappers, which need to be released, I ended up to create a utility method which loops until all references are released. The signature of the method ...

.NET: How to know when serialization is completed?

When I construct my control (which inherits DataGrid), I add specific rows and columns. This works great at design time. Unfortunately, at runtime I add my rows and columns in the same constructor, but then the DataGrid is serialized (after the constructor runs) adding more rows and columns. After serialization is complete, I need to cl...

Dictionary<string, MyObject> or List<MyObject> with C# 3.5?

I often use Dictionary in C#2.0 with the first key as string that was containing a unique identifier. I am learning C#3.0+ and it seems that I can now simply use a List and simply do LINQ on that object to get the specific object (with the .where()). So, if I understand well, the Dictionary class has lost its purpose? ...

Can you modify CPU registers from within VS2008 IDE?

Was just wondering if there was a way to edit the CPU registers (i.e. EAX, EBX, ECX, etc) or flags (OV, UP, erc) from within the Visual Studio IDE. I know you can view them using the Registers pane (ctrl-shift-G) and you can cycle through them with TAB or ENTER, but I don't seem to be able to change any of them while debugging (yes, pro...

JIT ramp up time for .NET web services

How do I overcome JIT compilation ramp-up time for infrequently used web service methods in my .NET enterprise solution? Some of my infrequently used business processes rely upon 5-6 web internal web service calls. Each "JIT" can add 2-3 seconds per call adding roughly 10-15 seconds to a process. ...

Serialize a nullable int

I have a class with a nullable int? datatype set to serialize as an xml element. Is there any way to set it up so the xml serialializer will not serialize the element if the value is null? I've tried to add the [System.Xml.Serialization.XmlElement(IsNullable=false)] attribute, but I get a runtime serialization exception saying there ...

How to physically obtain all the versions of an Assembly stored in GAC?

I have 3 versions of the same assembly in the GAC (Global Assembly Cache), but i physically need a specific version, when going into the framework folder i.e. c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\ the assembly located in the folder is the latest version. Can i physically retrieve the first version that was added into the GAC...

400: BadRequest with .Net Mass Downloader 1.5.0.1

Has anybody else had trouble with getting the .Net Framework source code? Google doesn't have anything to say about this error message, and neither does the CodePlex issue tracker. Here is the command I'm using to get the source code for the modules that make up mscorlib.dll. Am I doing something obviously wrong? NetMassDownloader.ex...

Add close button (red x) to a .NET ToolTip

I'm looking for a way to add a close button to a .NET ToolTip object similar to the one the NotifyIcon has. I'm using the tooltip as a message balloon called programatically with the Show() method. That works fine but there is no onclick event or easy way to close the tooltip. You have to call the Hide() method somewhere else in your cod...

Localization, MUI and the CLR

I am having some strange behavior when attempting to view my app in a different language. When using a box with a MUI installed (German in this case) and I switch the language to German (the setting is "Language used in menus and dialogs" in the regional and language options) all my forms and controls are translated into pseudo-German (...

Ascertaining a shutdown is closing my application

Is it possible in .NET to ascertain whether my application is closing due to Windows being given a shutdown command (as opposed to any old application closing) in order to either write out some temporary cache files or even block the shutdown long enough to prompt for user input? Whilst my current scope involves a Winform app and a wind...

.NET: From String to Object

I read some properties from an xml file, amongst which is a string that refers to an llblgen object for example 'article'. For now I have set up a rather long Select Case myString Case "article" return New ArticleEntity() Etc. which is getting rather ugly as it gets longer and longer ;). Is there a better way to do this ? (the...

wcftestclient.exe - Editing the default configuration

WCFTestClient tool doesn't seem to work if the size of maxNameTableCharCount is greater than default value (16384). Is there any way to modify the settings of the config file generated by this tool, BEFORE the tool generates it? I can modify the config file contents AFTER the service connection is established. But I am getting an er...

Controlling ffdshow from .Net

ffdshow has this awesome little API for controlling playback of video files. It allows you to change subtitles, fast forward, get the name of the file playing, etc... Its implemented as a windows message loop that accepts user messages and posts data back using WM_COPYDATA. I would like a c#/vb class that will allow me to perform all ...

Indexing into a String in C# as an L-Value

I have the following intentionally trivial function: void ReplaceSome(ref string text) { StringBuilder sb = new StringBuilder(text); sb[5] = 'a'; text = sb.ToString(); } It appears to be inefficient to convert this to a StringBuilder to index into and replace some of the characters only to copy it back to the ref'd param. ...

Where & How Castle Windsor sets up logging facility

Hi guys I'm fairly new to Castle Windsor and am looking into the in's and out's of the logging facility. It seems fairly impressive but the only thing i can't work out is where Windsor sets the Logger property on my classes. As in the following code will set Logger to the nullLogger if the class hasn't been setup yet but when Resolve is...

What's the best way to check for errors before leaving a row in a DataGridView

As far as I can tell, the best way to do this is do it in the DataTable.RowChanging event. But what if I want to cancel the action? There is no EventArgs.Cancel option... ...

ILMerge and 3rd party assemblies

I have a project with quite a few dependencies and would like to cut down on the number of assemblies being distributed. My project depends on external 3rd party dependencies such as Oracle.DataAccess and log4net. I am thinking if I could distribute this as one assembly as this is a sort of common utilities library and used in several o...