.net

What's the difference between Uri.Host and Uri.Authority

System.Uri has Host, Authority, and DnsSafeHost. MS provides a nice example of when Host and DnsSafeHost are different here. I'd like a similar example/explanation for Host and Authority. ...

Rules for when .NET referenced assembly is put in bin\debug

How does .NET (or Visual Studio) build decide whether or not to copy a referenced assembly to your bin/debug or bin/release directory? (This is an .exe console program.) On my machine, I had the referenced assembly in the GAC. A co-worker copied my bin/release to their machine, and it wouldn't run because the referenced asssembly was...

Adding and removing users from Active Directory groups in .NET

I am writing the following methods to add and remove users from active directory in C#. void AddUserToGroup(string userId, string groupName); void RemoveUserFromGroup(string userId, string groupName); How best to implement these methods? Here is some code from CodeProject. I can't see where the AD server is specified in these example...

How can I have Decimal.TryParse parse 0.0?

Is there a way to get Decimal.TryParse to parse a string value of "0.0" or "00.00" or "000.000" as 0? I have tried setting NumberStyles to Any. ...

What is the simplest way to print a series of full-page images from a WPF application?

I have a series of images (just stored locally on disk) that I would like to print, one-per-page, possibly scaled up/down if necessary and centered. What is the most straightforward method of doing this from a WPF application? Is it to somehow create an XPS document and if so then how? If not, what other possibilities are there? (e.g...

Port Windows CE app to Windows Mobile

I have a rather complex application that was originally built for Windows CE (using Visual Studio 2008, C# 2.0). I'm now trying to get it to run on a Windows Mobile device. There are a few UI quirks, however. I notice that the background color is all white and there doesn't appear to be any borders around a lot of the controls like th...

Problem with web service in IIS vs Cassini

We have a web application written in ASP.NET 2.0 which works fine in Cassini but when we switch it to IIS the 401 authentication seems to go away. We have checked Directory Security in IIS and removed anonymous access but still it does not work in IIS vs Cassini. This project is organized as such: A web application which references a c...

C# DateTime.Now precision

I just ran into some unexpected behavior with DateTime.UtcNow while doing some unit tests. It appears that when you call DateTime.Now/UtcNow in rapid succession, it seems to give you back the same value for a longer-than-expected interval of time, rather than capturing more precise millisecond increments. I know there is a Stopwatch cl...

C# Flash - ExternalInterface

We are hosting the ActiveX control in a WinForms application to embed flash. Is there a good way to get the list of visible ExternalInterface functions that are available for any given swf file? We are working with a 3rd party swf file, and do not have access to source. If it's not possible from C# (or code), is there a tool out there...

.NET XML Serialization and Null Collections

I have a class with some collections in them, and I would like to serialize instances of this class to XML without having to initialize the collections to be empty, and without having to implement IXmlSerializable. I don't care if it creates empty elements, or doesn't create the elements at all. Just that it works without having to ini...

Where in Query with Array in LINQ

I have array number = {2,3,4,5,6} Now i have to select rows from table "dtlRecord" where this number is a column. Number count 2 10 3 23 4 20 So what i need is select sum(count) from dtlRecord where number in (2,3,4,5,6) group by number I need above query in LINQ to SQL ...

How do you make height of context menu items not be fixed (ie scale to size of the particular item) in .Net?

See the two images below. I don't want each item in the menu to be the height of the largest. It should size to fit the contents. I've played around with a number of properties and haven't been able to prevent this behavior. Is it possible? ...

List with multiple indexes

Given a generic List I would need some kind of index (in the database sense) that would allow me fast retrieval. The keys for this index would not be unique, so I can't use a dictionary. Here's what I have in mind: Given a class Foo { P1, P2, P3 } that may have data like this { "aaa", 111, "yes" } { "aaa", 112, "no" } { "bbb", 111, "no"...

ICollection<T>.Contains on custom types

If I have a (reference - does it matter?) type MyType which does not override the Equals method, what heuristics will be used when determining if an ICollection<MyType> contains a given instance of the type? What's the best way to use my own heuristics (e.g. check for the equality of the Id property value)? ...

Why can't I call OrderBy in a class that extends List?

I have a class, Deck, that contains a method called Shuffle. I'm working on refactoring Deck to extend List<Card>, rather than having List<Card> Cards as a property. However, while Cards.OrderBy (a => Guid.NewGuid ()) worked, OrderBy (a => Guid.NewGuid ()) does not: Error CS0103: The name 'OrderBy' does not exist in the current context...

C# question - how do I convert a PageURI & Href to an absolute URL/URI?

Hi, How do I convert a PageURI & Href to an absolute URL/URI in C#? i.e. I am scanning a web page at a given PageURI and in the HTML have link/node with a HREF, and want to translate this HREF into a valid absolute URI. Background - note the trouble I was having here ...

How would you change my Heartbeat process written in C#?

I'm looking at implementing a "Heartbeat" process to do a lot of repeated cleanup tasks throughout the day. This seemed like a good chance to use the Command pattern, so I have an interface that looks like: public interface ICommand { void Execute(); bool IsReady(); } I've then created several tasks that I want...

How to return a windows process list in C#?

Using C#, how can I get a list of all running processes on the current machine, including image name, description and process id? I'm after something similar to what you would see under the task manager "Process" tab, though without the resource information. ...

Best way to create unique identities for distributed data that will be merged?

I have a centrally hosted database (MS SQL Server) and distributed clients save data to it over the Internet. When the Internet connection goes down the client starts storing new data locally into a SQLite instance. When the Internet connection comes back online the accumulated local data is moved to the central db (inserted). What's th...

Mobile Application Question

Hi Sir, I have To develop one sample mobile applciation for ( meter reading )... In this i stored the data in sqlce ,,,, then i want to integrate the sqlce data to any ERP like accpac,crm... Pls give idea about that integration... Thank u Regards ...