.net-4.0

Visual Studio chooses wrong constructor when a library isn't referenced?

ⅰ亾dé卋堺 提交于 2020-08-27 07:22:26
问题 I am using Visual Studio 2010 with two projects. One contains a project referencing Microsoft's Exchange.WebServices dll(ver1.2) for accessing ExchangeServices. I created a class which contains some helper methods and wrappers to carry out various tasks while connected to an Exchange server(through the ExchangeService API). The ExchangeService constructor can accept an enum of ExchangeVersion, to specify the server version info. So I created two constructors within my class. public class

How to Dispose ManualResetEvent

戏子无情 提交于 2020-07-20 09:10:54
问题 Hi When i use following code: myManualResetEvent.Dispose(); Compiler gives this error: 'System.Threading.WaitHandle.Dispose(bool)' is inaccessible due to its protection level. howevr following line works fine: ((IDisposable)myManualResetEvent).Dispose(); is it the correct way to dispose or at runtime it might crash in some scenerios. Thanks. 回答1: The designers of the .NET Base Class Library decided to implement the Dispose method using explicit interface implementation: private void

Setting column widths for listbox in a data template

╄→гoц情女王★ 提交于 2020-06-23 12:22:12
问题 This is my Employee class and its collection. public class Employee { public string LastName { get; set; } public string FirstName { get; set; } public bool IsHardWorking { get; set; } public string Description { get; set; } } List<Employee> Employees = new List<Employee>() { new Employee() { IsHardWorking = false, LastName = "Silly", FirstName = "Dude", Description= "this due is a mess" }, new Employee() { IsHardWorking = true, LastName = "Mean", FirstName = "Person", Description= "funny" },

Using Connection: Close in webserver SOAP requests

夙愿已清 提交于 2020-05-28 04:45:49
问题 The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. We're getting this exception frequently when using .Net 4.0 web service client to communicate with an ONVIF network device. Looking at the packet captures, this seems to be a device that is non compliant with the HTTP spec and closing a connection after sending the response, against the HTTP/1.1 default of keeping it alive. This results in the client (WCF) trying to reuse the

Using Connection: Close in webserver SOAP requests

╄→尐↘猪︶ㄣ 提交于 2020-05-28 04:45:02
问题 The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. We're getting this exception frequently when using .Net 4.0 web service client to communicate with an ONVIF network device. Looking at the packet captures, this seems to be a device that is non compliant with the HTTP spec and closing a connection after sending the response, against the HTTP/1.1 default of keeping it alive. This results in the client (WCF) trying to reuse the

Get special folder for different user without credentials

给你一囗甜甜゛ 提交于 2020-05-08 14:30:07
问题 I'm writing an uninstaller, and as part of the process, I want to clean up caches, temporary files, etc. for all local users. The app will run elevated for this to work. The files I'm looking for are found in special folders such as AppData\Local , so I need the paths. For the currently logged in user, this is trivial to do with Environment.GetFolderPath . However, this won't work for a different user. According to referencesource.microsoft.com, GetFolderPath ultimately calls into

Make a new DataTable with the same columns as another DataTable

生来就可爱ヽ(ⅴ<●) 提交于 2020-04-06 04:27:47
问题 I want to create a new DataTable that has the same columns as another DataTable. Currently, I do the following: DataTable myTable = new DataTable(); myTable = table.Copy(); myTable.Clear(); Then, I import rows into myTable as needed. Is there a more efficient way of doing this? Right now if table is large, then there is a lot of unnecessary copying of rows going on. Thanks. 回答1: Try to use myTable = table.Clone() 回答2: Use the Clone method - it creates a copy of the schema (columns) only. See

WPF DataGrid horizontal scrollbar not showing

夙愿已清 提交于 2020-04-05 11:52:10
问题 I have created simple DataGrid with 4 columns, which go outside the bounds of DataGrid, and horizontal scrollbar is not showing. I tried setting width to each column but nothing changed. Here is my XAML: <Window x:Class="WPFTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <DataGrid Height="200" Width="200" HorizontalScrollBarVisibility="Visible"> <DataGrid