.net-4.0

Is there an equivalent of Mac OS X Document modal sheet in .NET?

北战南征 提交于 2019-12-30 11:22:27
问题 My application has been getting more and more requests to have certain dialogs behave similar to Mac OS X Document modal Sheet functionality, where a dialog is modal to just the parent control/dialog, and not the whole application (see http://en.wikipedia.org/wiki/Window_dialog). Current windows ShowDialog() is insufficient for the needs of my application, as I need to have a dialog be modal to another dialog in the application, but still allow the user to access other areas of the

Winforms ProgressBar Takes time to Render

↘锁芯ラ 提交于 2019-12-30 11:20:29
问题 I have noticied that when using the PorgressBar. If I set the value to x, the value displayed is not immediately updated, it takes a small amount of time to draw it as the bar is animated from its current value to the new value. This is easy to see in the following code: Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Label1.Text = "" Dim progressHandler = New Progress(Of Integer)(Sub(value) ProgressBar1.Value = value) Dim progress = CType

Thread order execution?

血红的双手。 提交于 2019-12-30 09:42:09
问题 I have this simple code : ( which i run in linqpad ) void Main() { for ( int i=0;i<10;i++) { int tmp=i; new Thread (() =>doWork(tmp)).Start(); } } public void doWork( int h) { h.Dump(); } the int tmp=i; line is for capture variable - so each iteration will have its own value. 2 problems : 1) the numbers are not sequential , while thread execution is ! 2) sometimes i get less than 10 numbers ! here are some executions outputs: questions : 1) why case 1 is happening and how can i solve it ? 2)

Thread order execution?

拟墨画扇 提交于 2019-12-30 09:41:09
问题 I have this simple code : ( which i run in linqpad ) void Main() { for ( int i=0;i<10;i++) { int tmp=i; new Thread (() =>doWork(tmp)).Start(); } } public void doWork( int h) { h.Dump(); } the int tmp=i; line is for capture variable - so each iteration will have its own value. 2 problems : 1) the numbers are not sequential , while thread execution is ! 2) sometimes i get less than 10 numbers ! here are some executions outputs: questions : 1) why case 1 is happening and how can i solve it ? 2)

The Invulnerable XMLException

余生颓废 提交于 2019-12-30 09:32:29
问题 Background I serialize a very large List<string> using this code: public static string SerializeObjectToXML<T>(T item) { XmlSerializer xs = new XmlSerializer(typeof(T)); using (StringWriter writer = new StringWriter()) { xs.Serialize(writer, item); return writer.ToString(); } } And deserialize it using this code: public static T DeserializeXMLToObject<T>(string xmlText) { if (string.IsNullOrEmpty(xmlText)) return default(T); XmlSerializer xs = new XmlSerializer(typeof(T)); using (MemoryStream

SQL Server Management Objects

大兔子大兔子 提交于 2019-12-30 08:47:08
问题 Am getting the same error on the code below using either trusted or SQL logins: VS2010, Console app .NET4, Win XP. SQL2005 Full. Bombs on the transfer.TransferData ERROR : errorCode=-1073548784 description=Executing the query "" failed with the following error: "Retrieving the COM class factory for component with CLSID {19E353EF-DAF4-45D8-9A04-FB7F7798DCA7} failed due to the following error: 80040154.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly,

Why do my tests fail with System.Security.VerificationException?

混江龙づ霸主 提交于 2019-12-30 07:21:12
问题 I'm in the process of migrating one of my projects from VS2008 to VS2010. Now that I converted all of my projects in the solution to .NET 4.0 (Client Profile) when I run the test harness, almost all tests fail with the following exception: System.Security.VerificationException: Operation could destabilize the runtime. I've been unable to determine why this exception occurs. The tests run all fine when I run them in debug mode. The entire solution is available for download here. Can anyone

When to use which for?

折月煮酒 提交于 2019-12-30 06:40:25
问题 EDIT Additional options and a slightly extended question below. Consider this contrived and abstract example of a class body. It demonstrates four different ways of performing a "for" iteration. private abstract class SomeClass { public void someAction(); } void Examples() { List<SomeClass> someList = new List<SomeClass>(); //A. for for (int i = 0; i < someList.Count(); i++) { someList[i].someAction(); } //B. foreach foreach (SomeClass o in someList) { o.someAction(); } //C. foreach extension

How to allow a generic type parameter for a C# method to accept a null argument?

人走茶凉 提交于 2019-12-30 04:43:10
问题 private static Matcher<T> EqualTo<T>(T item) { return new IsEqual<T>(item); } How do I modify the above method definition such that the following are valid/allowed. EqualTo("abc"); EqualTo(4); EqualTo(null); // doesn't compile. EqualTo<string>(null) does Trying to port some Java code where null seems to be acceptable value for a T parameter. Update Thanks: for all the answers - especially Eamon and Jason. I didn't want the method calls to bother with type-inference. The following overload

Can a build server with .NET 4.5 installed successfully deploy a project targeting 4.0 to a server with only .NET 4.0 installed?

余生长醉 提交于 2019-12-30 04:28:26
问题 We've recently installed .NET 4.5 onto our continuous integration build server so that it can support new projects that utilize features of .NET 4.5. This build server is also used to build and deploy older projects, as well, some of which target .NET 4.0. Projects that target .NET 4.0 being built on this server, then deployed to a target server that has only .NET 4.0 installed are now failing with the following error: Method not found: 'Int32 System.Environment.get_CurrentManagedThreadId()'.