.net

Configuring transport security for WCF

I have a windows service that hosts a WCF service, and a webservice on a different machine acting as a client. I have the nettcpbinding set to Transport security using Windows authentication. Am I correct to assume that the windows user the webservice is running under must have permission to access the WCF service on the other machine?...

Making the balance print programmatically through the serial port.

How to? I am using SerialPort.Write function and it looks like it works most of the time, but out of the blue it just stops working. I also noticed that every time I send the command to print (even though I follow the manual, P with carriage return), I get string containing "ES" back - which according to the manual means error even thou...

Handling ObjectDisposedException correctly in an IDisposable class hierarchy

When implementing IDisposable correctly, most implementations, including the framework guidelines, suggest including a private bool disposed; member in order to safely allow multiple calls to Dispose(), Dispose(bool) as well as to throw ObjectDisposedException when appropriate. This works fine for a single class. However, when you subc...

Solving Erratic Behavior with HttpWebrequest in SQL 2008 CLR UDF

We're currently attempting to implement a sql server 2008 udf to do expansion of shortened urls. We have it working quite well against most of the major url shortening services. However, at seemingly random times it will "hang" and refuse to work against a certain domain (for example bit.ly) while subsequent calls to other services...

ADO.NET MVC Tutorial (with LINQ to SQL) question about schema changes

So I'm working through the new scottgu wrox book, and I create a couple tables. Then (per the tutorial) I use linq to sql to build my Models, DataCOntext, Repository, etc. (It's pretty clear that LINQ to SQL seems to be "the Microsoft Way" to generate models and similar classes from schemas.) Then I find I've neglected to include one of...

Can I validate an XPath expression against an XML schema?

You can verify an XPath expression against an XML doc to verify it, but is there an easy way to verify the same XPath expression against the schema for that document? Say I have an XSD schema like this: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" ... etc> <xsd:element name="RootData"> <xsd:complexType> <xsd:seq...

Linq to Sql: Where condition order impact

With a LINQ-TO-SQL linq query - does the SQL generated respect the 'Where conditions' order? For instance: int[] result = (from r in DB.Accounts where r.AccountID > 10 && r.Name == "Harry").ToArray(); If there are thousands of rows, and there is an Index on the Name column, will the SQL query by the Indexed column fi...

Getting data from C# to Excel 03/07

I have files with tons of real time data that I process with an C# application. After processing the data it is presented in Excel using a specific template. This is solved using Interop today. I must say I don't completely gasp the whole Interop situation. Do I have to manually install the Interop functionality on each end user termina...

Best string container: StringCollection, Collection<string>, List<string>, ArrayList, .. ?

What is the most suitable container just for strings holding in some array with non-predetermined upper boundary, which length is unknown on it's creation. For simple code like: Foo list = new Foo(); // size in unknown for()/foreach()/do()/while() // any loop { list.Add(string); } Is it StringCollection as optimized Collection for ...

Resize images in Windows Mobile

Is there anyone who knows a way to resize images on the .net 2.0 Compact Framework? I want to be able to get images, taken with the camera on my phone, from the phones memory, resize them and then upload them to a webservice so I acctually don't need to store the resized images on disk. ...

An issue with AJAX web service call: Microsoft JScript runtime error: Sys.Net.WebServiceFailedException:

I am trying to invoke an AJAX web service call from a client web site in the same machine[Win XP Home]. In doing so, I am getting the following error. Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'Greetings' failed with the following error: <html> <head> <title>Not Found</title> ...

How do you handle Foreign Key Relationships in model classes

Let's say I have a Project table with a FK CompanyId which relates the project to a company Table. In your Project model, do you add a Company object, or just the CompanyId property and retrieve the Company when needed in code? ...

WCF: How should I maintain contract classes in client and server?

I am working on a WCF application with a server and a client (naturally). In server project, I defined the classes with contract attributes. Now when the server is ready, I added the service reference and it created the proxy for me. I used it and it did work fine. The question I want to ask is, is it OK if I create a common DLL which ...

Where to log from a .net web app? - Can't use %APPDATA% because of privileges

I need a path I could specify in log4net file appender so that the log files would go there. However, aspnet or whatever account does not have write privileges to %APPDATA% folder. Is there any place I can write to without asking customer admins to give extra access privileges? Path.GetTempFile() is probably not a good idea. I need some...

Compilation failed: throw an exception or do not?

I'm writing .NET On-the-Fly compiler for CLR scripting. And have a dilemma: is it better to throw an exception on build fail or not? So what is the best-practice point of view, which approach is more suitable? try { compiler.Compile(); // do not throws an exception only if build succeed } catch(CompilerException ex) { string err = ...

Any picture Gallery Control for .NET 1.1 in WinForms?

I need a UserControl to display pictures as a Gallery in Winforms. I have my pictures as a Image Collection but no problem to change to fit Control capabilities. It could be nice if it is for .NET 1.1 but since I'm planning to migrate all our code to 2.0 if the control is in that framework it could be useful in the future If it is fre...

Open source RSS parser

Before rolling my own RSS parser, is there a really good open-source parser already written for C#? ...

How to updateTimeSheet in ms project server

Here's the situation, i want to have a user that can enter time on behalf of other (programmaticaly). When i do QueueUpdateTimeSheet a web service of ms project server, it doesn't work if a try to enter time for an other. I try the impersonification but i need to know the username and password of the person that i want to impersonate....

Split old .NET code into designer partial class

I'm working on an older .NET code base that has all the designer code stuffed into the same code file as my code (pre - partial classes). Is there a mechanism to tell Visual Studio 2008 to go back and refactor designer code into a X.designer.cs partial class file? ...

Nhibernate and MS Access

Can NHibernate be used as ORM tool for MS Access? We are using Nhibernate to access Sql Server, so wondering if it can be reused. If it can be used how has the experience been? ...