.net

Converting .NET App to x86 native code

There's a program written entirely in C# that targets .NET Framework 2.0. Is there a way I could somehow compile (translate) managed EXE to a native one so it could be .NET-agnostic? I know there are probably commercial products for that purpose... but they are a bit expensive. The problem is that we are to deploy the program on compute...

What is the best way to thread work in c#?

What's the best way to thread work (methods) in c#? For example: Let's say I have a form and want to load data from db. My form controls: - dataGridView (to show data from DB), - label (loading status) and - button (start loading). When I click the button my form is frozen until the task is done. Also the loading status does...

Does it make sense to distribute pre-NGEN-ed assemblies?

I've found a few interesting links on using NGEN as a final step in an installer from this post. Is there a reason it is preferred to NGEN your assemblies at setup time, instead of at build time? I'm not particularly concerned with setup time, but it just seems like an unnecessary step that could be automated by my build. ...

How to take all but the last element in a sequence using LINQ?

Hi everyone, Let's say I have a sequence. IEnumerable<int> sequence = GetSequenceFromExpensiveSource(); // sequence now contains: 0,1,2,3,...,999999,1000000 Getting the sequence is not cheap and is dynamically generated, and I want to iterate through it once only. I want to get 0 - 999999 (i.e. everything but the last element) I rec...

ValidateUser of Forms Authentication issue

Hello everyone, I am using SharePoint 2007 Enterprise + Publishing portal template + Windows Server 2008. And I am developing using ASP.Net + C# + .Net 3.5 + VSTS 2008 on SharePoint Server 2007. I am developing a custom Forms authentication based on Forms authentication interface. I am learning using Forms Authentication with SharePoint...

Best way to create button displaying selected color

You know those color picker buttons with a little rectangle in it, displaying the currently selected color? Like in MS Office products. I would like to implement one using C# / .NET. So I've got a nice little icon with a magenta-colored rectangle (which is to display the color) and a transparent background. I can think of two ways how ...

How to make a select list item selected in asp.net mvc?

Hi I have the following code but it never selects the value I want. List<SelectListItem> list = new List<SelectListItem>(); SelectListItem one = new SelectListItem() { Text = "MyTest", Value = "MyTest"}; SelectListItem two= new SelectListItem() { Text = "Test2", Value = "Test2" }; if (id == "MyTest") { ...

JavaScript Code injected into my website pages

I need to know if there is any way of writing additional code to JavaScript files already deployed on the server. I am facing a problem with an ASP.NET 2.0 website and it is related to the JavaScript files which I have on some of the pages. The problem is that when I upload the JavaScript files along with other files it works fine, but...

Question about Environment.ProcessorCount

I am curious as to what the .NET property Environment.ProcessorCount actually returns. Does it return the number of cores, the number of processors or both? If my computer had 2 processors, each with 4 cores, would Environment.ProcessorCount return 2, 4, or 8? ...

Why do MSTests Assert.AreEqual(1.0, double.NaN, 0.0) pass?

Short question, why do Assert.AreEqual(1.0, double.NaN, 0.0) pass when Assert.AreEqual(1.0, double.NaN) do not? Is it an error in MSTest or am I missing something here? Best regards, Egil. Update: Should probably add, that the reason behind my question is, that I have a bunch of unit tests that unfortunately passed due to the result o...

Dataadapter update performance - do I need to use datatable.Getchanges?

This is a simple question, but I'm having trouble finding the answer. I have a large datatable of which I have updated many, but not all rows. I am using a dataadapter to update these changes to SQL server. Does the dataadapter send update queries only for the updated rows from the datatable, or does it send one for every row, and esc...

Assign different IP for different threads in a .net program

The computer that runs my program has 6 different IP addresses assigned to it. I need that each thread will use a different IP address for its communication. Specifically I'm using the WebRequest object for communicating. so is there away assign each thread a different IP address to use instead of the default one? Thanks, Eden ...

How to Setup Cell Phone Call-Diverts Programatically in .Net Compact Framework

I am working on an application which needs to divert phone calls to other cell phones programatically using the compact framework. These need to network or carrier redirects so that if the phones loose battery/etc the diverts will still function. I need to be able to enable and disable these call diverts easily and programatically with...

Speechlib on Shared hosting - ASP.NET

I am trying to use SpeechLib on my personal website. It's a very simple app that saves some text to a wav file - standard stuff. Works great on the dev machine. But all hell breaks loose when I deploy it to the shared host. Sometimes I get prompted for user name and password at the time of writing the wav file. Sometimes, I get the "Sec...

How can i get value of delay for tap-and-hold on Windows Mobile?

How can i get value of delay for tap-and-hold on Windows Mobile? I.e. the delay between tap and the circles being drawn and/or the context menu appearing. ...

Can't get Linq to NHibernate to work

Hi all, I'm struggling with getting Linq To NHibernate to work. I have referenced NHibernate, NHibernate.Linq and NHibernate.ByteCode.Castle . Also I have all other dependencies in the same folder. Code / Error message: Public Function GetProjectsByName(ByVal ProjectName As String) As List(Of Project) Return (From x In _session....

Converting Linq to XML result to generic list in VB.Net. Odd error.

I have a function that works great in C# that I'm converting to VB.Net. I'm having an issue converting the result set to a generic list in VB.net. The code: Public Function GetCategories() As List(Of Category) Dim xmlDoc As XDocument = XDocument.Load("http://my_xml_api_url.com") Dim categories = (From category In xmlDoc.Descendan...

keeeping a checkbox open in default

i have a page with a checkbox. it has the related .cs code --> protected void chkShowAll_CheckedChanged(object sender, EventArgs e) { ctrlTime.ShowAllProjects = chkShowAll.Checked; } on clicking on the checkbox, a table appears. How do i keep that checkbox open by default so that the table appears WITH the page rather than checki...

Redirecting Console Output to winforms ListBox.

Hi There, I have built a library that dumps most of its debug text using Console.WriteLine(); I am now I am the process of using the library in a Windows Forms Application, and still need access to the Console output. ( To Display in a List/RichText box ) I Noticed I can override the standard out of the console to a TextWriter, b...

C#: Accessing and Modifying Values in a WebBrowser Control

I have a WebBrowser control where I want to edit a field in the HTML and then submit a form. Let's say that the field is called txtUname and that the submit button is called submit in form form1. How can I do this? I'm currently thinking of using something like this, but I haven't tested it: //Change value webBrowser1.Document.getElem...