.net

C# - integration of limited web/js/jQuery local browser with "connected to Internet check"

I need some suggestions on libraries and such to use for a simple website-to-desktop wrapper project in Visual Studio 2010. The website has been "compiled to HTML", so that the only serverside functionality needed is an AJAX call to send data on user prompt (if there is no valid sever response after X seconds, a javascript timer indica...

Performance cost of a try/catch block

Possible Duplicate: Performance Cost Of try I am being told that adding a try catch block adds major performance cost in the order of 1000 times slower than without, in the example of a for loop of a million. Is this true? Isn't it best to use try catch block as much as possible? ...

Range DataAnnotation Doesn't Seem to Be Working in .Net 3.5

Using .Net 3.5 I have a Range Attributes (System.ComponentModel.DataAnnotations) on a Property... [Range(0, 5, ErrorMessage = "Weight must be between 0 and 5")] public virtual double Weight{ get; set; } And I have a Validate method in the class that checks validation attributes... protected virtual void Validate() { var t...

How to highlight focused row in DevExpress gridview on click?

Hi I have a devexpress gridview one of the column contains url. I need on url clik highlight this row and if user click another url in another row highlight and unselect previous. ...

Am I undermining the efficiency of StringBuilder?

I've started using StringBuilder in preference to straight concatenation, but it seems like it's missing a crucial method. So, I implemented it myself, as an extension: public void Append(this StringBuilder stringBuilder, params string[] args) { foreach (string arg in args) stringBuilder.Append(arg); } This turns the follo...

ClickOnce install with no start menu entry

Is it possible to deploy several windows apps using click once, but not to have them all create icons on the start menu? The reason for doing this (if you're interested) is that we are distributing several windows applications within our company, the main one will allow the user to log in and depending on their permissions build a men...

Error 10061 while trying to connect to my server

I'm working on a client/server and I'm having trouble getting them to communicate over the internet. If I'm running them on the same computer, it works fine if I have the client connect to localhost or to my network address (192.168.1...), but it doesn't work (Error 10061: connection actively refused) if I have the client connect to my e...

System.Net.WebRequest not respecting hosts file

Is there a way to get a System.Net.WebRequest or System.Net.WebClient to respect the hosts or lmhosts file? For example: in my hosts file I have: 10.0.0.1 www.bing.com When I try to load Bing in a browser (both IE and FF) it fails to load as expected. Dns.GetHostAddresses("www.bing.com")[0]; // 10.0.0.1 WebRequest.Create("http://1...

Self Tracking Entity - Loading Navigation Property of a Navigation Property

I am curious what the best practice is for this situation in Entity Framework 4.0. I have the following Entity Map: Entity A -> Entity B -> Entity C Where Entity A contains a list of Entity B's which each contains a list of Entity C's. I am using self tracking entities and when I load Entity A I am doing something similar to this: Ent...

How initialize and define const string with reflection.emit

i need help with .net reflection.emit Need create simple Assembly with public struct and string field in it. Field must be constant and i also need define it. In all i need get Assembly that hold inside something like this: namespace n { struct Alpha { public const string DATA = "Alpha"; } } I don't understand how cre...

What resources should I use to port my .NET application to Mono or Moonlight?

I have a few applications that might qualify for porting over to a Linux/Mac platform, but first I need to know what baseline of technology is safe for compatibility, what is marginal, and what is unsupported. Is there a consolidated list somewhere that helps me determine if my app even qualifies? What other resources should I be aware...

This XmlWriter does not support base64 encoded data

I have a class like this: public class Data { public string Name { get; set; } public int Size { get; set; } public string Value { get; set; } [NonSerialized] public byte[] Bytes; } When a List<Data> hits the serialization method below, it occasionally dies with InvalidOperationException "This XmlWriter does not...

Generate an concatenated SMS UDH and prepend it to message text.

In order to send SMS (7-bit) longer than 160 chars, you have to break the message up into 153 character messsage data parts and prefix each of these with a 5 octect UDH (user data header), explaining that these are parts of a multipart SMS and should be 're-assembled' by the receiving device. As the UDH is sent as part of the message da...

.NET List best approach

I have a list which is declared below, at the start I default the list items to { -1, - }. please note that throughout the program the list size is fixed at 2. List<int> list = new List<int>(new int[] {-1, -1}); My question is regarding, what would be the best approach if I need to overwrite the two values in the list. int x = GetXVa...

Winforms - Embedding form inside a form or container causes form controls to behave differently

EDITED: When I load a form dynamically inside another form or container control, the editing behaviour of all the form's components is different. Text editing, in a TextBox or ComboBox, does not allow me to select partial text with the mouse, though I can double click to select all the text in the control. FormChild form = new For...

How to link a .NET 2.0 assembly in a .NET 4.0 solution

I have a project built with .NET 4.0. I have a lot of code that would be painful to convert back to 2.0. I try to import a Dll built with .NET 2.0. Everything works until I try to execute code from that DLL. It says that it cannot load the specified module or one of its dependency I used dumpbin.exe to check what dependencies it can ha...

Testing Code With Threads in .NET

I need to test my vigorously tested code works when called by many threads So I am calling the code in a loop in a TestMethod using TreadPool.QueueUserWorkItem however there does not seem to be anyway of holding the current thread while all the threads kicked off are still running. i.e. pretend code.... using Microsoft.VisualStudio.T...

OPOS PosExplorer.GetDevice() returns null when executed in Windows Service

The code snippet below makes use of OPOS .NET to open a POS printer for printing. It works fine when executed as part of a standalone application. When executed by a Windows Service the call to GetDevice(...) always returns null. explorer = new PosExplorer(); device_info = explorer.GetDevice(DeviceType.PosPrinter, PrinterName); printer ...

ASP.NET MVC 2 Validate SelectList

Let's say I have the following selectlist (Countries) in a ViewModel: //.. private static string[] _countries = new[] { "USA", "Canada", "Japan" }; //... SelectList Countries = new SelectList(_countries, dinner.Country); //... And I render a dropdown list in the following fashion: <%: Html.DropDownListFor(m => m.Dinner.Country, Model...

Why doesn't Math.Round/Floor/Ceiling return long or int?

Every time I use Math.Round/Floor/Ceiling I always cast to int (or perhaps long if necessary). Why exactly do they return double if it's always returning an integer. ...