.net

Reffering to text from cell of WPF DataGrid.

I need to get datetime from SQL table but I have two problems: I need to refer to string from selected cell of DataGrid. I've tried "bksDataGrid.CurrentCell.Item" but that doesn't work. Not really problem, but the cmd will return SQL datetime as object. Is it possible to convert it to .NET DateTime? object obj = new object(); ...

Replace newlines with <p> paragraph and with <br /> tags

So I know how to replace newlines in my C# code. But replacing a newline for a <br /> tag isn't always very correct. So I was wondering what kind of strategy do others use? The correct way I guess would be to use <p> tags and <br /> tags. Here are some examples of the results I would like to get. If there is no newline I want the te...

WCF Proxy - SOAP 1.1 and 1.2 at the same time

Is it possible to configure a WCF proxy such that it is able to understand SOAP 1.1 and SOAP 1.2 messages at the same time? In other words, I want to be able to connect to a web service that may return at any time, SOAP 1.1 or 1.2 based messages. Thanks. ...

How to restore an application from the SysTray? ShowWindow doesn't help since the Handle=0

Is it possible to restore a 3rd Party application which has been minimized to the SysTray? Calling ShowWindow is fine on apps minimized to the TaskBar but where the app has been minimized to the SysTray it appears its handle gets set to zero, and of course ShowWindow can't find it. ...

Is there a better way to do a 4 bits circular shifting?

is this the optimal way of doing a 4 bits circular shifting? n << 1 ^ 0x10 | n >> 3 I was only testing with number that was actually "working"! ...

directcast in vb.net

i have 1 a.master page and 1 b.aspx with its b.aspx.vb page. I have the following property in the a.master.vb Public Property Page_Title() As String Get Return title_div.InnerHtml End Get Set(ByVal value As String) title_div.InnerHtml = value End Set End Property in the b.aspx.vb page i have DirectCast...

How can I load the following XML using LINQ-to-XML into a dictionary?

How can I load the following formatted XML document: <Settings> <MimeTypes> <MimeType Type="application/mac-binhex40" Extensions=".hqx"/> <MimeType Type="application/msword" Extensions=".doc;.docx"/> <MimeType Type="application/pdf" Extensions=".pdf"/> <MimeType Type="application/vnd.ms-excel" Extensi...

Define a .net reference to always use the latest version of a GAC'd dll?

We have a vendor who is writing an application for us who makes use of a dll I've provided to them. My boss just found out that if we ever need to make a change to one of our dll's we'd have to provide the updated version to the vendor so they could recompile their project. This causes problems because we don't have automated testing a...

WPF ribbon control: RibbonContextualTabGroup hiding title

Hi, I'm creating an application that uses Microsoft's Ribbon but I'm having issues with the RibbonContextualTabGroup. When this tab appears it changes the title text specified in the ribbon properties to "E.....", is there a way round this? Here's my code: <r:RibbonWindow x:Class="Sample.MainWindow" xmlns="http://schemas.micros...

How DID Microsoft do this? (an OO question about their .NET HttpServerUtility class)

HttpServerUtility contains a public function called UrlEncode. It is not a shared function. HttpServerUtility does not have any public constructors. Doing this fails: Dim encodeMe As String = "a string to be encoded!" HttpServerUtility.UrlEncode(encodeMe) 'Bombs out This works, and is how Microsoft says to do it: Dim instance As...

Why can't I select a single element in LINQ-To-XML?

I'm having a devil of a time selecting the value of a single element in my XML document My document looks like <?xml version="1.0" encoding="utf-8" ?> <MySettings> <AttachmentsPath>Test</AttachmentsPath> <PendingAttachmentsPath>Test2</PendingAttachmentsPath> </MySettings> I've tried to do the following: XElement mySettings = X...

Selecting a certain row from a dataset

Hi, I have a Dataset and want to display the containing rows in a WPF-Contorl. The problem is, that the control is sort of a circuit diagram. Thus I created a template to show the values and placed multiple instances of it in my circuit control. Currently the XAML-code in the circuit looks like this: <Label Content="{Binding Path=.[0]}"...

.NET: Why is TryParseExact failing on Hmm and Hmmss?

I'm trying out the DateTime.TryParseExact method, and I have come over a case that I just don't get. I have some formats and some subjects to parse that each should match one of the formats perfectly: var formats = new[] { "%H", "HH", "Hmm", "HHmm", "Hmmss", "HHmmss", }; v...

SvcUtil doesn't generate TransactionFlowAttribute

It seems that using svcutil will not generate the TransactionFlow attribute. Looking at the generated class, we see that it is missing. Is there a fix for this ? EDIT: more info, I'm running svcutil against a dll to get the metadata and then run svcutil /t:code against that metadata for code generatino. I've notice that running ...

EntityFramework v4 ApplyCurrentValues not saving referenced property changes

I have a project where I am using EFv4 to save data back to my repository. This is working as expected for the simple properties on my object but does nothing for the related objects. For example, I have a User object and a related property Roles that is a collection of Role entities. If I update the User's lastActivity date and the...

Multithreading working perfectly until I hit the com object.

I'm using com interop to talk to some physical piece of hardware. When I need the current reading from the hardware I have a nice elaborate piece of threading code that keeps it off my UI thread so that I don't lock up the UI while I query the hardware since sometimes it can take as much as 1-2 minutes (although usually more like 1-5 se...

Is StringComparer.CurrentCulture the right choice to use in this case?

I have a list of UTF-8 strings that I want to sort using Enumerable.OrderBy. The strings may contain any number of character sets - e.g., English, German, and Japanese, or a mix of them, even. For example, here is a sample input list: ["東京","North 東京", "München", "New York", "Chicago", "大阪市"] I am confused as to whether using String...

Converting Bitmap PixelFormats in C#

I need to convert a Bitmap from PixelFormat.Format32bppRgb to PixelFormat.Format32bppArgb. I was hoping to use Bitmap.Clone, but it does not seem to be working. Bitmap orig = new Bitmap("orig.bmp"); Bitmap clone = orig.Clone(new Rectangle(0,0,orig.Width,orig.Height), PixelFormat.Format24bppArgb); If I run the above code and then chec...

VSX: Programmatically disabling breakpoints at runtime

How can breakpoints be enabled or disabled at runtime? I'm writing a test workbench application that can run other .net code for the purposes of debugging plugins. The workbench app itself is not debuggable (DebuggableNonUserCodeAttribute) but the user code that it calls should be. But then, under certain circumstances at runtime, the...

Is XslCompiledTransform to blame for slow XML transformation for a large file?

I am very new to XSLT, and the first thing that i need to do is parse a 300MB file (and that's on the small end). The XSLT is not that complex for the moment, it's just removing some nodes that match a certain criteria. I have two problems: It's too slow. It takes 50 seconds to process 500,000 records and that's not fast enough. It c...