.net

Why is in .net the String.Format(fmt, args,..) function "shared"

Is there any sane reason why the function String.Format in .net (for C# and VB.net at least) shared and not like .split, .substring or whatever a normal function. What would be bad about Dim a as String = "1+2={0}".format(1+2) (would be good) vs. Dim a as String = String.Format("1+2={0}",1+2) (the way it works) It always bugs me w...

Value getting changed in the iteration before the call begins

I've the following code in my app. MyEventHandler handler = null; //Declare the handler foreach (string pname in group) { handler = getHandler(pname); //Get the handler if(handler == null) { throw new KeyNotFoundException("No user " + pname + " could be found"); } //invoke the handler handler.B...

Choose appropriate platform dependent DLL at runtime

I'm currently working on project for the .NET Compact Framework which uses DotNetZip for reading ZIP-files. The project is split into two parts. One platform-independent library which should be available for both, a CF project and a desktop project. This common library contains the code for extracting ZIP-files. The problem is that there...

Draw dashed line in a WPF adorner

Hi there, I have found several articles on the Web regarding drawing a dashed line in WPF. However, they seem to revolve around using the Line-class, which is a UIElement in WPF. It goes something like this: Line myLine = new Line(); DoubleCollection dashes = new DoubleCollection(); dashes.Add(2); dashes.Add(2); myLine.StrokeDashArray ...

Need a library for barcode scaning for windows mobile devices

Hi there, I'm looking for an opensource library/SDK for windows mobile devices. My purpose is to scan a barcode from mobile's camera and retrieve its info. I used zxing for android but is not supported for windows mobile devices :( Any suggestion would be appreciated ...

Whats the best/most succinct way to pass multiple linked arrays as method parameters?

I have a method that I want to pass in a couple of arrays that are linked, ie item 1 in array 1 corresponds to item 1 in array 2. I can obviously just pass in 2 arrays, like this: meth({"v1", "x1"}, {"v2", "x2"}); But was wondering if C#3.0 (not able to use 4.0 here yet) had any "syntactic sugar" options to handle this, eg via anonym...

Updating NService Bus from 1.9 to 2.0?

Hi, I currently implemented NService 1.9 in one of my project. I want to update the project from NServicebus 1.9 to NServiceBus 2.0. Will there be any major changes that I need to do.. or Only configuration changes are fine? Can anybody help on this, provide me any links containing about this information? ThanksnRk ...

Which static class initialize first ?

Hello everybody Which static class initialize first if we have one more static classes in our project? For example : Below code gives null exception. class Program { static void Main(string[] args) { First.Write(); Second.Write(); } } static class First { public s...

Performance of system.runtime.caching

I have compared the performance of system.runtime.caching in .NET 4.0 and the Enterprise Library Caching Block and to my surprise it performs terribly in comparison when fetching large data collections from cache items. Enterprise Library fetches 100 objects in about 0,15ms, 10000 objects in about 0,25ms. This is fast, and natural for a...

.Net MVC2 How to add error to ModelState when using custom ValidationAttribute - Solved with IDataErrorInfo

I have the following ValidationAttribute class [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public sealed class DateValidationAttribute : ValidationAttribute { public DateValidationAttribute(string leftDateProperty, CompareOperator compareOperator, string rightDateProperty, string errorMessage) ...

.NET garbage collector

Hi All, It is written in link http://msdn.microsoft.com/en-us/magazine/bb985010.aspx "When an application creates a new object, the new operator allocates the memory from the heap. If the object's type contains a Finalize method, then a pointer to the object is placed on the finalization queue." Can someone please clarify me 1) It m...

How to achieve backwards compatibility with my .NET plugin architecture

Background: I am developing an ASP.NET application with a server side plug in architecture. I define a set of interfaces in a pluginInterfaces .NET assembly. Third party developers can develop a plugin assembly against these interfaces, place their assembly in a plugin folder, and it will be dynamically loaded to offer new functionalit...

Resume program execution after handling an unhandled exception

Question: I catch generally unhandled exceptions with AddHandler System.AppDomain.CurrentDomain.UnhandledException, AddressOf OnUnhandledException The problem now is, with this exception handler Public Sub OnUnhandledException(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs) Console.WriteLine(e.ExceptionObject.ToStri...

Keeping multiple installations of a system synchronized

We work on a large client-server system, implemented using C++/MFC/DCOM. It's planned to roll this out to multiple locations (for years it has been a single location) and have ability for some data to replicate between systems, i.e have a central server which talks to each system and is informed of changes so it can pass them on. Exampl...

NHibernate: NHibernateConfigException

Hi, I'm starting with VB.NET and NHibernate but i'm getting this exception: NHibernateConfigException was unhandled An exception occurred during configuration of persistence layer. This is the code Dim configuration As New Cfg.Configuration() configuration.Configure() configuration.AddFile("person.hbm.xml") Dim f...

mvvm-light toolkit not firing Window Loaded event

I have a Window and using MVVM light toolkit to bind to the Loaded event: <Window ... xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" ... > <i:Interaction.Trigg...

Remove corners when drawing thick lines

Result: Question: Can I round or do something with this line "appendix"? Code: private void Form1_Paint(object sender, PaintEventArgs e) { Point[] points1 = new Point[] { new Point(50, 90), new Point(60, 20), new Point(70, 120) }; GraphicsPath path1 = new Graphics...

Java Webservice returning null object to a .net client

Hi All, Can any one figure out my problem is... I'm calling a webmethod of a Java Webservice (Axis 1.4) from a .Net client. That method returns a Map object, and if i call it from an Axis client works fine, but in my c# code it´s always null. That's the WSDL: <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:apa...

How can i use FindControl method in asp.net?

How can i use findControl and how can i get id's according to FindControl method? i need to get all TextBox data there are 40 textbox. And TextBoxid data... i reall want to learn also linq method ;) protected void Button1_Click(object sender, EventArgs e) { // SetRecursiveTextBoxAndLabels(PlaceHolder1); ...

Update Panel Repositioning Screen

Ok so I have an update panel that updates conditionaly, and inside of it, I have 5 times the same control. The problem is this control also has an update panel, that keeps refreshing every 1 second, getting data from a table inside a repeater. Since I'm not that experienced with web developing, the only other solution I thought of was ...