.net

Which exceptions should I watch for in a WebRequest call?

I'm working on a small but vital batch application which has a step in it to download an image from a remote website I don't have any control over. This is quite simple and I got it working already but I'd like some input on the error-handling. The remote server doesn't always have the image requested so a 404 Not Found is actually alri...

Problem with loading resources from referenced assembly in Expression Blend

I have problem with loading resources for UserControl from referenced assembly in Expression Blend Here is the relevant code: <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/Referenced.Assembly;component/Resources/ResourceDic...

Does the order of attributes have any guarantees?

If multiple attributes are applied to a member, e.g. [Foo] [Bar] void Baz() { ... } Then are any guarantees made by the CLR/.NET specifications as to what order they will be retrieved in when retrieved by reflection (e.g. Attribute.GetCustomAttributes)? The documentation for these methods does not make it explicit, and while it does s...

One-to-one association and filtering in Linq

Hello, Let's say I have two tables (Address and Phone) in sql which have one-to-one relationship. I have created corresponding linq to sql classes and changed the association to OneToOne I want to retrieve both objects by filtering child object. e.g I have the following query which works fine: var n = db.Addresses.Where(t => t.Phone.N...

Authentication and Authorization scheme for an application exposed as WCF Service Layer?

Hi, I know this question must have been discussed million times in your organization. One more go. Designing a LOB application which has its business operations exposed as services. These services would be accessed by our own web application(ASP.Net MVC), smart desktop clients, mobile clients, as well as, our partners via either thei...

Cache byte[] in a hashtable vs MemoryStreams.

We are reading huge files in to memorystream and reusing them across mulitple locations in the code. Just wondering if it is a better idea to get byte[] of files and store them in a hashtable for such a scenario. This way we could close the memorystream when we are done and just recreate one from hashtable when needed. Just wondering if ...

Table valued parameter in a stored procedure gets execute permissions denied error

I get the following error when calling a stored procedure that has a table valued parameter as one of the parameters The EXECUTE permission was denied on the object 'ValidationErrors' ValidationErrors is a TVP created with the following statement: CREATE TYPE [dbo].[ValidationErrors] AS TABLE( [ErrorMessage] varchar NOT NULL ) ...

Downloadable WPF tutorial

Hello, I'm flying to New Zealand next week and figured that it would be a good chance to learn the basics of WPF. I've been flicking through this tutorial which seems really good but there is a lack of wifi in the stratosphere. Does any one know of a similar, easily downloadable tutorial for WPF or do I need to save all the pages on the...

How to integrate EPABX with .net appliaction?

Hello Friends, My requirement is to make a phone call from ASP.NET using EPABX. Can anyone help me, how to integrate .net application with EPABX. Thanks ...

Strange problem with Assembly.Load*

Hi, dear community! I have strange problem with loading assembly from file and unfortunately I can't reproduce it with simple easy-to-share code. I describe what I'm doing right below. I have 4 applications: "Complex Invoker" - the foreign(not mine) open source application, which is the computer game actually, for which I'm writing a...

LINQ query against GridView filled with SqlDataSource

I need to make a LINQ query against GridView filled with SqlDataSource - to create a Dictionary from rows. So I have: <asp:GridView runat="server" ID="gridCurrency" DataSourceID="sourceCurrency" OnDataBound="gridCurrency_DataBound" <asp:SqlDataSource runat="server" ID="sourceCurrency" ConnectionString="<%$ ConnectionStrings:MyConnStr %...

DataContractJsonSerializer not seeing DataMemberAttribute

I've derived from ( the excellent ) PropertyBag class and then want to serialize to Json using DataContractJsonSerializer. Unfortunately the dynamic properties are not showing up in the JSON despite being created with a DataContractAttribute. How can i serialize these dynamic properties? using System; using System.ComponentModel; using...

Multi level .Net Regex

If I have input string in C#, how can I do series of Regex / linq operations on it to do Regex match on one piece of string and then another Regex on all pieces of string which are not matched by 1st Regex. In other words, for input string: <!-- Lorem ipsum dolor sit amet, consectetur adipiscing elit --> <!-- The quick brown fox jump...

I want to close a file

I have a file i want to close the file programmatically which is used by another process. The thing is i want to free the file from another process whichever is using that and then delete it.. Anyway to do that programmatically? i am using c#.. how to delete this?? i have done a code like, if (File.Exists(filePath)) File.Delete(fi...

String comparison in .Net: "+" vs "-"

I always assumed that .Net compares strings lexicographically, according to the current culture. But there is something strange when one of the strings ends on '-': "+".CompareTo("-") Returns: 1 "+1".CompareTo("-1") Returns: -1 I get it an all cultures I tried, including the invariant one. Can anyone explain what is going on, and how...

how to use XmlAttributeOverrides when serializing an array?

I have an array called _updatedComponents of objects that are of class NetworkComponent. I have to serialize it in the way that the name and namespace of the root element (=array) is changed and individual NetworkComponent-item's name is changed to component. I have a code below that causes an enception: System.InvalidOperationException...

Set Default Datbase for an OBDC DSN Connection .Net

Is there any way to set the default database of an ODBC DSN, using the ODBC connection string in an OdbcConnection? Edit: If I already have a DSN setup and a normal connection works. OdbcConnection connection = new OdbcConnection("DSN=TestDSN;UID=ADMIN;PWD=****;"); Is there a way I can change the default connection that is set ...

Object does not match target type using C# Reflection

Hi everyone! I am trying to get a value of a Window as follows this refers to the main window (window1) Type type = this.GetType(); PropertyInfo pi = type.GetProperty("Left"); object obj = pi.GetValue(type, null); But I get an "Object does not match target type using" error. What is wrong? ...

LIVEMESSAGING Using " FaceBook API " in Silverlight Application.

I'm using a Silverlight Application and want to use LIVEMESSAGE class for Instant Messaging through FaceBook API. Can any body tell me how to use this LIVEMESSAGE for Messaging by using an Example? Thanxs In Advance, Ravi Joshi ...

How to serialize a DataTable to a string?

Recently I was in the need to serialize a DataTable as a string for further processing (storing in a file). So I asked myself: How to serialize a DataTable into a string? ...