.net

Converting a binary file to a string and vice versa

Hi, I created a webservice which returns a (binary) file. Unfortunately, I cannot use byte[] so I have to convert the byte array to a string. What I do at the moment is the following (but it does not work): Convert file to string: byte[] arr = File.ReadAllBytes(fileName); System.Text.UnicodeEncoding enc = new System.Text.UnicodeEnco...

What is the best way to defer code execution?

I have many methods calling each other that each have to certain tasks, some of them asynchronous, that all operate on a DOM (so only one thread must access the DOM at any time). For example: object A() { /*...A() code 1...*/ var res = B(); /*...A() code 2 that uses res...*/ } object B() { /*...B code 1...*/ var re...

Which database to use locally in a desktop application?

I have two different options using database in a desktop application. I prefer the Service-based database even locally. But should I use the Local database instead? ...

Using .NET RegEx to retrieve part of a string after the second '-'.

Hey guys, This is my first stack message. Hope you can help. I have several strings i need to break up for use later. Here are a couple of examples of what i mean.... fred-064528-NEEDED frederic-84728957-NEEDED sam-028-NEEDED As you can see above the string lengths vary greatly so regex i believe is the only way to achieve what ...

Highlighting text while typing in a text box in asp.net

Hi All, Can anyone help me out with this problem. I want to highlight the text while typing in a TextBox. How can I do this? ...

What could lead to the creation of false EOF in a GZip compressed data stream.

We are streaming data between a server (written in .Net running on Windows) to a client (written in Java running on Ubuntu) in batches. The data is in XML format. Occasionally the Java client throws an unexpected EOF while trying decompress the stream. The message content always varies and is user driven. The response from the client is ...

Where to place my .sdf file when testing application through Emulator

I am work on smartApplication, Here when am trying to connect to my SQL Server CE 2005 database, I get the exception The path is not valid. Check the directory for the database. [ Path = D:\SmartProject\DBFile.sdf ] My connection string is Data Source=D:\SmartProject\DBFile.sdf;Password=test123 and the code to connect is like stri...

Changing the opacity of individual form controls in .NET

Ok, so what I'm trying to do is have two imageboxes overlapping so that I can align the images in them (based on user input). The problem is I'm not sure if I can adjust the opacity of individual controls so I can only see the topmost control. Of course, I could do image processing and combine the two images into a single image (with the...

PInvokeStackImbalance - invoking unmanaged code from HookCallback

my goal i want to translate a left click to a right click my approach i register a low-level hook via SetWindowsHookEx (user32.dll) filter left-mouse-clicks check if i want to translate THAT specific click in case that i really want to do not pass on the message create a new mouseclick via mouse_event (user32.dll too) the problem...

connect to mysql with c#.net

hi every body.how can i connect with MySql in app?and what software,i must install for mysql?thanks. ...

Reduce Flicker of .NET FlowLayoutPanel

I'm clearing and adding multiple LinkLabel's to FlowLayoutPanel, every couple of seconds. It works fine, but flicker is quite noticeable. Is there any way to reduce it? I tried to set Form.DoubleBuffering, it didn't help. UPDATE: Managed by creating a custom control derived from FlowLayoutPanel and setting its styles as shown below: P...

How can I separate string array via REGEX?

I separated "A320-789-890" according to "-" and i get a list below: "A101C", "B7CL", "E7CL", "D7CL" Everything is ok. My result set above it is my solution result. But i have 2 question: how can I do that with regex? if I can do that with regex, can I use regex with linq? which is more effective according to performance like my meth...

Overriding a Procedure in a Parent from a child control

I'm developing this usercontrol which requires I override the WndProc of the control's parent [which for all practical purposes is a Windows Form] and I'm stumped. Ordinarily, I could drop the user on the form and manually override the forms WndProc. Since my entire development team and possibly others I don't know of right now could be...

WebServiceBindingAttribute is required on proxy classes.

I created a soap based web service and create a function named SetclientCredential which set the client credential using Microsoft.Web.Services3.Security.Tokens.UsernameToken the code sample is given below: <SoapDocumentMethod(Action:="http://tempuri.org/SetClientCredential", _ RequestNamespace:="http://tempuri.org/", _ RequestElement...

Actual uses of bit flags in .NET framework

Was looking at how enums can be used as bit flags by decorating them with the flags attribute and bitwize operators (see below). Are there any places in the .NET framework that this pattern is used? I like this but want to see some more real life examples [Flags] enum Days2 : int { None = 0x0, Sunday = 0x1, Monday = 0x2, Tuesd...

Using .NET to validate XML against a schema

I want to test (true or false) whether an arbitrary XML file matches a given schema. For what it's worth, the schema is the Word 2003 WordML schema, which Microsoft defines using a list of about 7 *.xsd files. One of these files also includes the W3C xml.xsd file, by including the following statement: <xsd:import id="xml" namespace="h...

How to Import a C/C++ dll to .NET application

Hi, In my new project I want to use a existing C C++ functions . For that I would need to add the C/C++ dlls to C# project. My C/C++ projects is of type UnManaged and it is not a COM Project. I have seen few articles after from MSDN and tried: [DllImport("user32.dll", EntryPoint="MessageBoxA")] But I am not sure Where should I place...

XMLReader to read a text

<xhtml:li> content1content1content1content1content1content1content1content1 <xhtml:a href="234455" doc.type="mt">titlex</xhtml:a> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX <xhtml:a href="23452345#23556::ah_234555" doc.type="xx">ZZZZZZZZZZZZZZZZ</xhtml:a> </xhtml:li> Hi, From the above xml how to extr...

How does the reference assembly is verfied to check whether it is tampered?

This question is about verifying the assembly to check whether it is tampered for malicious activity. When an assembly is created, metadata is generated. Metadata includes tables like type definition tables, type reference tables and manifest tables. Reference tables contain an entry for each assembly reference and the entry includes ref...

is a static method using the same variables for different calls

I have this method: public static IEnumerable<T> ExecuteReaderSp<T>(string sp, string cs, object parameters) where T : new() { using (var conn = new SqlConnection(cs)) { using (var cmd = conn.CreateCommand()) { cmd.CommandType = CommandType.StoredProcedure; cmd...