.net

XML Serialization of an Object Containing invalid chars

I'm serializing an object that contains HTML data in a String Property. Dim Formatter As New Xml.Serialization.XmlSerializer(GetType(MyObject)) Dim fs As New FileStream(FilePath, FileMode.Create) Formatter.Serialize(fs, Ob) fs.Close() But when I'm reading the XML back to the Object: Dim Formatter As New Xml.Serialization.XmlSerialize...

Opaque dictionary key pattern in C#

I've run across a number of cases where a pattern for accessing items in a keyed collection (like a dictionary) is encumbered by the fact that the type of the key is not a simple type (string, int, double, etc) and isn't something that you would want to promote to an actual named class. C# 3.0 introduces the concept of anonymous types ...

Can .NET XmlSerializer class deserialize InnerXml as a string?

I have a very specific deserialization need, see example below: say I have following class: [Serializable] public class Person { public string Name { get; set; } public string PersonXml { get; set; } } and following XML <Person> <Name>John</Name> <PersonXml><someXmlFragment>text</someXmlFragment></PersonXml> </Person> Wh...

redirect to a custom page for a list in sharepoint

I have provisioned a custom list in sharepoint. how can i redirect to a different custom page when a user selects list > new item or edit item ...

[OpenOffice & C#] Mailmerge using OpenOffice

Hello all. I'm currently trying to do a mailmerge, using C# and OpenOffice. I have a list of destanatary in my DB. I would like this to be possible : the user edit an OO document, put fields like "name" "adresse" "city" and some standard text (e.g. : "Hello Name how are you ?", edit the style, etc etc, then go to my application, cli...

Update before screenshot

I want to capture an image of the screen, however there are some wpf controls in my application that I do not want to appear in the screenshot. Using the code below, the hidden controls will sometimes still appear in the screenshot. How do I ensure that this doesn't happen? Window window = new Window(); Button button = new Button(); vo...

ASP.NET SecurityException looking for AspNetHostingPermission During Page Parsing

I am getting the following error while i debugging my project in VS 2008 developer edition Server Error in '/' Application. -------------------------------------------------------------------------------- Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant th...

Creating the GetHashCode method in C#

What is the best way to create your own GetHashCode method for a class in C#? Suppose I have a simple class (which overrides the Equals method), as follows: class Test { public string[] names; public double[] values; public override bool Equals(object obj) { return (obj is Test) && this.Equals((...

How can I post something to a Wall using Facebook Developer Toolkit?

Does anyone have experience using the Facebook Developer Toolkit? I am trying to post something to a Facebook user's Wall, but can't figure out how to use the API? Could someone could give me an example or point me to some documentation on the API's usage? ...

ClickOnce error: Value does not fall within the expected range

Getting this error on ALL ClickOnce application launches for a certain user. This started happening after a version upgrade (but happens to no one else). I've tried subsequently changing the version number, add/remove, registry scrub, clearing Local Settings\Apps folder, etc... Still no luck. This article points to a user profile cor...

.NET XMPP libraries under Apache, MIT or MS-PL licenses?

I am looking for a liberally licensed (MIT, X11, Apache, etc) version of the XMPP protocol for .NET and Mono. There are a handful of libraries under the GPL, LGPL and LGPL v2 for .NET and Mono, but none of those are suitable for the kind of application that I have in mind (integrating it with Mono's stack where we go for no-strings atta...

Should I use string constants or string literals

By default I use string constants in my code when I have a string of text that will be output to the screen via a messagebox, label, etc. My main reason for doing so is that I do not want these strings to change at runtime and this way nobody really touches them. My question is: It seems that from a memory point of view, this approach ...

Efficient function for reading a delimited file into DataTable

Hi all, I was wondering if anyone knew of an efficient c# function for reading a tab delimited file into a datatable? Thanks ...

NHibernate HQL Query: Expressions in the Select clause

Is there any way to use expressions in the Select clause? E.g.: select u.Age/2 from User u I'm having this exception right now: NHibernate.QueryException: ',' expected in SELECT before:/ [select u.Age/2 from Business.Entities.User u] ...

How to Inject code in c# method calls from a separate app

I was curious if anyone knew of a way of monitoring a .Net application's runtime info (what method is being called and such) and injecting extra code to be run on certain methods from a separate running process. say i have two applications: app1.exe that for simplicity's sake could be class Program { static void Main(string[] ...

Null argument values passed from HTML form to WCF REST function

I have created a RESTful WCF service with a method that will be used to save data using a POST. I want to test this method from an HTML form. The following HTML form and interface definition (and related .cs code) result in the SaveTest function getting called when I hit the form Submit button, however the one argument id is always set t...

What are the best reads to know more about the .NET CLR ?

What are the best resources to read/learn about the internal details about the .NET CLR? ...

How do I ensure my entire team has exactly the same version of the .Net runtime?

My team is writing an ASP.Net webapp in VS2008 targeting .Net3.5 SP1. Some of us have the .Net runtime version 2.0.50727.3082 installed, and others have 2.0.50727.3053. Everyone's Windows Update reports no available updates, even the people with the lower build number, and I wouldn't care at all except that all .designer.cs files include...

Cache Function results

For fun, I'm playing with a class to easily cache function results. The basic idea is that you can take any function you want though you'd only want to use it for relatively expensive functions and easily wrap it to use relatively inexpensive dictionary lookups for later runs with the same argument. There's really not much to it: pu...

ASP.NET MVC Controllers and Extending the Framework

Is there any way to catch a "controller not found" event from the framework? Maybe this event doesn't exist. But if I just pick a URL to throw at the routing system of the framework like: http://localhost:54321/foobar The final result without modification is a 404 error. Is the easiest way to catch this through a custom ControllerFact...