.net

Reason for .Net UI Element Thread-restriction

We know that it is not possible to execute code that manipulates the properties of any UI element from any thread other than the thread the element was instantiated on... My question is why? I remember that when we used COM user interface elements, (in COM/VB6 days), that all UI elements were created using COM classes and co-classes...

How to get if the object is already retrieved in inject

Is it possible to know that particular dependency already has been satisfied by ninject kernel? To be clear: Let's suppose we have this module: Bind<IA>().To<A>(); Bind<IB>().To<B>(); And some "client"-code: var a = kernel.Get<IA>(); // how to get here "true" for assumption: "IA was requested (once)" // and "false" for: "IB was not...

Removing an Entity from an EntitySet during Iteration...

I've got this code... seems nice and elegant, but apparently the framework don't like it when i mess with a collection while iterating through it: foreach (KitGroup kg in ProductToTransfer.KitGroups) { // Remove kit groups that have been excluded by the user if (inKitGroupExclusions != null && inKitGroupExclusions.Contains(k...

Default value for public attributes

I have a public attribute in some class. I want a default value -1 for this attribute without an private variable like _MyAttr(because too many attributes, i won't add them one by one). public int MyAttr { get; set; } [DefaultValueAttribute] is not working for this issue i think. Any ideas? Thanks. ...

Best way to handle Integer overflow in C#?

Handling integer overflow is a common task, but what's the best way to handle it in C#? Is there some syntactic sugar to make it simpler than with other languages? Or is this really the best way? int x = foo(); int test = x * common; if(test / common != x) Console.WriteLine("oh noes!"); else Console.WriteLine("safe!"); ...

Best book / content for .NET 3.5

Hi, I want to study new .NET 3.5 concepts like WPF, WCF for work as well as for interviews. I am aware of .NET 2 but do not have any detailed knowledge of .NET 3.5 and newly added features in .NET 3.5 and C#. is there any good book/ online resource which would help me? ...

Replacing cells in DataGridViewComboBoxColumn()

In my DataGridViewComboBoxColumn, I want to replace null value cells with DataGridViewTextBoxCell cells that basically say "this cell cannot be changed". The following code does this exactly the way I want: foreach (DataGridViewRow row in dgv.Rows) { if (row.Cells[9].Value == DBNull.Value) { DataGridViewTextBoxCell cell...

Who is working with VS 2010 professional ? IS it stable as 2008 ?

All I want to know is if .NET frameworks 2.0, 3.0 and 3.5 are available in VS 2010 Professional. I have installed VS 2010, but only .NET framework 4.0 is there when making a C# project. Does anyone else have the same problem ?? I am also working on my Final Year Project. I also would like to know if VS 2010 Professional is stable enou...

How do I create directory if doesn't exist to create file?

i have a piece of code here that breaks if the directory doesn't exist System.IO.File.WriteAllText(filePath, content); is it possible to do in one line (or a few lines) to check the directory leading to the new file doesn't exist and if not, to create it before creating the new file. i'm in .NET 3.5 here. ...

IoC and DI framework for .Net applications

Hi Can you please explain how the following three are different in their intent? 1) Policy Injection Application Block 2) Structure Map IoC 3) Managed Extensibility Framework In terms of the common tasks they do, which is simpler/aligned with generics and C# 3.0 ? Thanks Lijo ...

New HandleProcessCorruptedStateExceptions attribute in .NET 4

I'm trying to crash my WPF application, and capture the exception using the above new .NET 4 attribute. I managed to manually crash my application by calling Environment.FailFast("crash");. (I also managed to crash it using Hans's code from "How to simulate a corrupt state exception in .NET 4?".) The application calls the above crashin...

Winforms App Not Displaying Graphical Elements in Design Mode

I wrote a bunch of code in the .cs file in c# for a winforms application. The application runs fine, and everything is in it's place. Something like this: using.. namespace Temp { public class Temp : Form { Button b1; TextBox t1; Temp() { b1.Text = "Some Text"; b1.Size = new Size(50,20); ... ...

How can I tell if a candidate is a good Sharepoint Architect / Developer ?

I need to interview some people for a position as a Sharepoint Architect / Developer role. While I am proficient in .NET, I have worked very little with Sharepoint, so I am unsure how to test the candidates Sharepoint skills. Do you have any suggestions for tests I can throw at the candidates ? Please suggest questions I can ask the c...

How to display an image when aAsynch post back is happening

I have an Ajaxable application which has some UpdateProgress for each postBack events. everything is good and working great. I want to display another Indicator in my SiteMapPath bar which shows a post back is happening no matter what. For example when user clicks on a button an UpdateProgress display an Indicator Image in central part...

web service client authentication

I want to consume Java based web service with c#.net client. The problem is, I couldnt authenticate to the service. it didnt work with this: mywebservice.Credentials = new System.Net.NetworkCredential(userid, userpass); I tried to write base class for my client method. public class ClientProtocols : SoapHttpClientProtocol { ...

Is a .NET image completely black?

Hi, Given a .NET Image object, how do I check if it represents a picture that's completely black? (C#) 10x! ...

How can I add array data in winform datagridview?

I generated Personel[] type array from Biz.Bal.GetPersonelById("1") but if I want to add winforms, I do that like below. Is there a simpler method? Like GridView.dataSource=myArray? private void Form1_Load(object sender, EventArgs e) { Form_init(); Model.Personel[] list = new Model.Personel[0]; ...

Fast search in XMl files in .NET (or How to index XML files)

I have to implement a search feature which is able to quickly perform arbitrary complex queries to XML-data. If the user makes a query, all XML files must be searched to find possible matches. The users will have lots of XML-Files (a few 10000 or more) which are typically a few kilobytes in size. All the XML-files have almost the same st...

Using Rx to synchronize asynchronous events

I want to put Reactive Extensions for .NET (Rx) to good use and would like to get some input on doing some basic tasks. To illustrate what I'm trying to do I have a contrived example where I have an external component with asyncronous events: class Component { public void BeginStart() { ... } public event EventHandler Started; } ...

How get to work ShapeContainer.Scale methods?

Microsoft.VisualBasic.PowerPacks How should I get to work ShapeContainer.Scale methods? Are they implemented? private void button1_Click(object sender, EventArgs e) { // this works for the common form controls this.Scale(new SizeF(1.1f, 1)); // // but has any effect on the powerpacks.Shapes ...