.net-3.5

.Net - DataAnnotations - Validate 2 dependants DateTime

Let say I got the following classes : public class Post { public Date BeginDate { get; set; } [Validate2Date(BeginDate, EndDate, ErrorMessage = "End date have to occurs after Begin Date")] public Date EndDate { get; set; } } public class Validate2Dates : ValidationAttribute { public Validate2Dates(DateTime a, DateTime...

How to resize a picture to a specific file size ?

Hi, I would like to resize a picture to a specific file size. For example, no more than 200KB. What is the best approach to achieve this with C# .NET ? Thanks ! ...

how to resolve this .Net 3.5 warning/error?

I have three machines. one installed VS2008 another two installed SDK6 and Framework3.5 (one of these two is a build machine). When I use MSBuild to build our application, all of them get this warning: C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could not loca...

c# on .net 3.5 SP1 System.Security.Principal.WindowsIdentity.GetCurrent().Name returns names in different order? [Closed - configruation error]

Hello everyone, i am working on a windows forms .net 3.5 project in c# and the project uses the following line to get the current user: Created_By = System.Security.Principal.WindowsIdentity.GetCurrent().Name; On one box the result is hostname\username but on my box the result is username\hostname. Both boxes run Windows 7 Ultimate. ...

inline if and interfaces (polymorphism)

public class Foo : IFooBarable {...} public class Bar : IFooBarable {...} So why then will this not compile... int a = 1; IFooBarable ting = a == 1 ? new Foo() : new Bar(); but this will... IFooBarable ting = a == 1 ? new Foo() : new Foo(); IFooBarable ting = a == 1 ? new Bar() : new Bar(); ...

XSD: XML files pass validation, but so do XSLs and XSDs

So there's an XSD schema that validates a data file. It declares root element of the document, and then go complexType's that describe structure. The schema has empty target namespace, document nodes are not supposed to be qualified with a namespace. Recently someone by mistake sent an XSL template in place of an XML data file. That xsl...

how to redirect guest to guest.aspx from login..

I have an administrator and a guest user... When the administrator logs in he should be redirected to the default.aspx but if the guest logs in he should be redirected to the guest.aspx page... Currently it is being redirected to Default.aspx... here is my code web.config authentication mode="Forms"> <forms loginUrl="Login.aspx"...

find inside array of objects

i have a objectA public class objectA { public int Id; public string Name; } i have a list of objectA List<objectA> list; i want to find in the list any objectA with Id = 10; is there linq syntax for this or do i simply have to write a loop here. ...

WinForms StatusStrip Label and Progress Bar Not Visible When Spring is Set

I have a .Net 3.5 Winforms application that has a status strip at the bottom. The status strip contains two labels and a progress bar with the spring property set to true, the status strip layout is set to Table. But they are not showing up on Server 2008, but works fine on Server 2003, XP and Vista. Has anyone come across this? I ca...

Allow only positive number with text input mask.

Hello flok, I true to set a text input mask which only allow numbers from 0-999, or even better 1-999. So I tried the mask "##0", but unfortunately this also allows negative numbers. Is there a way to allow only positive numbers? Best regards, Enyra ...

Extension methods overloading in C#, does it work?

Having a class that has a method, like this: class Window { public void Display(Button button) { // ... } } is it possible to overload the method with another one that is more broad, like this: class WindowExtensions { public void Display(this Window window, object o) { Button button = BlahBlah(o); ...

Lambda expression example with System.Action<T> for a MEF case?

I am new to System.Action<T> and Lambda expression. Here is one case I would like to use. using System; using System.ComponentModel.Composition; public class MyClass { public static CompositionContainer Container = new CompositionContainer(); private void Initialize(Action<CompositonBatch> action) {} public MyClass() { ...

What to choose.... web service or WCF in asp.net 3.5

The current project i am working on is extensively using web services and is made in .net 3.5. Now as we are going for implementation of second phase we are confused if we should either use WCF or web service as done previously ? Further is there anything new that can be useful and is coming up with .net 4.0 regarding web services or WCF...

How to create a single executable file in Visual Studio 2008 ?

Hi, I've created a Windows Forms Application in Visual Studio 2008, .NET 3.5. Now I want to finalize my project, i.e. to create a single .exe file which I can give to someone and he will be able to run it on his computer. In my project files I found bin/Debug directory where I see a .exe file. Can I just use this file as is, or I am mi...

Basics in Resizing Pictures or What happened to Picture Size ?

Hi, I am writing a program that resizes pictures like this: Image originalImage = Image.FromFile(pathToOriginalPicture); Bitmap b = new Bitmap(newWidth, newHeight); Graphics g = Graphics.FromImage(b); g.DrawImage(originalImage, 0, 0, newWidth, newHeight); g.Dispose(); b.Save(pathToOutputPicture, ImageFormat.Jpeg); I tried to set: ...

Possible to calculate MD5 (or other) hash with buffered reads ?

I need to calculate checksums of quite large files (gigabytes). This can be accomplished using the following method: private byte[] calcHash(string file) { System.Security.Cryptography.HashAlgorithm ha = System.Security.Cryptography.MD5.Create(); FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Rea...

How to implement a Progress Bar with multiple instances of application ?

Hi, I added a key to the Registry such that when I right click on a JPG file I see a new "Transform" option that actually runs my application. I would like to implement a Progress Bar to see the progress of the Transformations of all JPGs. The problem is when I select N JPGs and apply "Transform" on them, my application runs N times (e...

apply CSS list style buttons to server created button controls

Hi, I have some CSS that uses lists to create 3D buttons styles similar to the link below: http://articles.techrepublic.com.com/5100-10878_11-5323375.html My problem is I have buttons which are server controls and thus render html buttons. The question is how would I rewrite my button code to use lists and hyperlinks so I can apply ...

How-to: Moving WCF service from localhost to production server

I worked through building a WCF web service on my development machine. I built the service, created a test client, tested everything and it works. I was starting to feel pretty good about this WCF stuff. Then I got gutsy and moved it to my production server. For now, the production server is on WinHost.com. I have my testing domain, www...

Installing .NET CF 3.5 side by side with standard framework

Hello, We have a machine that needs .NET Compact Framework installed and now we need to install standard .NET Framework 3.5. Any problems or known issues with installing both frameworks together? Thanks. ...