.net

.net dropdownlist if condition

I had posted this question before but didnt get the right answer - here's my code again with the if condition. Dim provider As CultureInfo = CultureInfo.InvariantCulture Dim a1 As DateTime = Nothing if date1.selectedvalue isnot nothing then insexp = DateTime.ParseExact(date1.SelectedValue, "MMMM yyyy", provider...

Saving image: A generic error occurred in GDI+. (vb.net)

I need to save an image after opening it in from an OFD. This is my code atm: Dim ofd As New OpenFileDialog ofd.Multiselect = True ofd.ShowDialog() For Each File In ofd.FileNames Image.FromFile(File).Save("C:\Users\Jonathan\Desktop\e\tmp.png", Imaging.ImageFormat.png) Next And on the line Image.FromFile(File).Save("C:\Users\Jonat...

What is the most modern way to write a file browser in C#

I found some resources about how to write a File Browser in C#, but the were all at least 3 years old. I am wondering if importing the shell32 DLL is still the best way to do this. I am a mac developer by trade so please excuse me if my question is a little strange. It just seems this method is going outside of the .NET framework and I w...

.Net adding Min\Max lenght to field attribute?

Hello and thanks for any assistance. I have a WCF project that contains a Customer class object. Currently, I use svcutil to generate the WSDL and XSD's that I give to the client. When the XSD's are generated they are pretty simple. For some of the fields I want to add Min and Max Length Attributes, so that the XSD has the <xs...

Is there is .NET implementation of HtmlPurifier(php)

Is there a comprehensive Html cleaner/Anti-Xss library for .NET that also has a defined whitelist. I know that Microsofts Anti-Xss is a good place to start, but it needs a good whitelist for allowed html tags and css. Does anyone know of something? ...

Get the name of the current method

This is kind of a silly question, but is it possible to get the name of the method that is currently being executed from within that method? Public Sub SomeMethod() Dim methodName as String = System.Reflection.[function to get the current method name here?] End Sub Thanks ...

Why Browsable attribute makes property not bindable?

Hi, I'm trying to use System.Windows.Forms.PropertyGrid. To make a property not visible in this grid one should use BrowsableAttribute set to false. But adding this attribute makes the property not bindable. Example: Create a new Windows Forms project, and drop a TextBox and PropertyGrid onto Form1. Using the code below, the width of...

What does using(object obj = new Object()) mean?

What does this statement means in C#? using (object obj = new object()) { //random stuff } ...

An object reference is required for the non-static field, method, or property

Hi , I recieve an error when building my vs2008 .net 3.5 solution Error 1 An object reference is required for the non-static field, method, or property 'System.Web.UI.Page.Request.get' String _XSLTPath = Page.Request.Url.Scheme + "://" + Page.Request.Url.Authority + Page.Request.ApplicationPath.TrimEnd('/') + '/...

Howto programmatically generate pretty printed SQL from .net?

The title says it all, is there a library or source code that's GPL that can turn a SQL statement into beautified HTML? I'd even settle for some PHP or Java code that I can port to .NET Tried google, but couldn't find any free sample code. Thanks. ...

Cyclic dependencies - yet again

I am struggling with avoiding cyclic dependencies. I know I need to hide the implementation with interfaces, but how do I handle a situation with two assemblies, where each either needs to instantiate classes from the other or call a static method from there? Edit: I understand this can be fixed by using just a single assembly. We have...

Exclude property from getType().GetProperties()

Hi i'm working in a class library using C#, and i have some classes with some properties. I just wanna know if i can add something to exclude some properties form the getType().GetProperties(). An example of what i want: class Test { public string one { get; set; } public string two {get ; set;} } and if i do t...

How will migrating from .Net 3.5 to 4.0 affect my WCF components?

From your own personal experience, how much of an impact will migrating to .Net 4 have on my existing WCF components? Is there a big risk that I may need to re-write a lot of code? ...

save context menu items in my.settings vb.net

How can I store the items in a context menu strip in the Settings so they are in the context menu when the application is next started? Or is there a better way than using settings? (they are recently opened files in the cms) ...

.net System.Threading.Timer needs to access Silverlight 3 UI component in callback

I have a Silverlight 3 page. I use a System.Threading.Timer to perform an Asynchronous WCF service call. I make the call by passing in the Silverlight page class ("this") in as the "state" object in the timer constructor, and accessing the service client proxy through it. By doing it this way, the callback from the WCF service fires f...

.Net Why can't I get more than 11GB of allocated memory in a x64 process?

I thought that the maximum user space for a 64bit process was 8TB, but I did a little test and the maximum I could get is 10-11GB. Note: I don't need that much memory in a process, I just want to understand why out of curiosity. Here is my test program: static void Main(string[] args) { List<byte[]> list = new List<byte[]>(); ...

Books about .NET cross-cutting concerns APIs

Are there any good books about .NET and: security, configuration, logging, health monitoring, globalization / localization, resources / satellite assemblies, etc. I'm NOT asking for books on application frameworks, e.g. Windows, WPF, ASP.NET, etc. I'm NOT asking for books on programming languages, e.g. C#, VB.NET, F#, etc. I'm NOT as...

How to handle special DateTime values - example Present

DateTimes are usually some number of ticks from some starting date. These are usually displayed by some type of tool such as a calendar or the like. It seems to me that sometimes an application would like to store a DateTime with a special meaning, like "When evaluated" or "Never" or "Unknown". For example I worked in a company where ...

Serialize enum as int

I am looking to return the following class through a web service, which includes an enum type as one of its members. [Serializable, XmlRoot("GeoCoordinate")] public class GeoCoordinate { public enum AccuracyLevel { Unknown = 0, Country = 1, Region = 2, SubRegion = 3, Town = 4, Post...

Why does enum.ToString() give a different result than what's shown in the debugger tooltip?

Test program (.NET 2.0): [Flags] enum MyEnum { Member1 = 1, Member2 = 2, } class Program { // Inspecting r shows "Member1 | Member2" MyEnum r = MyEnum.Member1 | MyEnum.Member2; // s = "Member1, Member2" string s = r.ToString(); } I would have expected .ToString() to return a string with the members separated b...