.net-2.0

How big is the risk when testing a .net 3.5 Assembly using a .net 4.0 test assembly

时光毁灭记忆、已成空白 提交于 2019-12-06 13:17:35
I realise that Visual Studio 2010 sp1 allows test projects to target 3.5 now. However, for various reasons I don't fully appreciate, our test projects still target dot net 4.0. The general question is in the title. How big is the risk? Specifically, this presumably means that the tests will run in the CLR v4, whereas many of our clients will be using CLR v2. Also, the tests seem to use v4 of library components (such as System.Data), even though the application is built against v2. One method (System.Data.SqlClient.SqlBulkCopy) contains a bug in v2 which has been fixed in v4. Our testing missed

Why can't you bind the Size of a windows form to ApplicationSettings?

筅森魡賤 提交于 2019-12-06 12:27:22
问题 Update: Solved, with code I got it working, see my answer below for the code... Original Post As Tundey pointed out in his answer to my last question, you can bind nearly everything about a windows forms control to ApplicationSettings pretty effortlessly. So is there really no way to do this with form Size? This tutorial says you need to handle Size explicitly so you can save RestoreBounds instead of size if the window is maximized or minimized. However, I hoped I could just use a property

Does a class need to implement IDisposable when all members are explicitly disposed?

眉间皱痕 提交于 2019-12-06 11:16:13
Trying to understand when implementation of IDisposable is necessary: I wrote a little example. public class FileManager { private FileStream fileStream; public void OpenFile(string path) { this.fileStream = File.Open(path, FileMode.Open, FileAccess.Read); } public void CloseFile(string path) { if ( this.fileStream != null && this.fileStream.CanRead) { this.fileStream.Close(); } this.fileStream.Dispose(); } } // client var manager = new FileManager(); manager.Open("path"); manager.Close("path"); Does this class need to implement IDisposable because it has a managed resource (FileStream) which

Listing files available for download - files are stored in location accessible to the application only

心已入冬 提交于 2019-12-06 11:09:23
I have a set of pdf files stored in the location accessible only by the application - so those files cannot be accessed directly via http. The file paths are stored by the database and when the user is given the option to download a file the code as below is being executed: Response.ContentType = "Application/pdf" Response.AppendHeader("Content-Disposition", "attachment; filename=<some file name>") Response.TransmitFile(Server.MapPath("<the file path>")) Response.End() It all works fine provided I am dealing with a single file The problem: I have a stored procedure that returns a list of all

How do I fire an event safely

拟墨画扇 提交于 2019-12-06 10:23:36
问题 When there are no subscribers to an event how do I ensure that an exception will not be thrown if the event is fired. // Delegate declaration public delegate void _delDisplayChange(object sender,string option); // Event declaration public event _delDisplayChange DisplayChange; //throwing the event DisplayChange(this, "DISTRIBUTION"); 回答1: Here is the recommended way to do it: protected void RaiseDisplayChanged(string message) { var handlers = DisplayChange; if(handlers != null) handlers(this,

.Net 2.0 application from network share without FullTrust

拥有回忆 提交于 2019-12-06 09:29:51
I am trying to run a .Net 2.0 application from a network share without using the FullTrust permission set. I want to create a new permission set that has just the permissions my assemblies require, and then assign that to the exe on the shared path. Is it possible to do this? From my limited experiments, I find that I am unable to do get any application working from a network share without FullTrust. I tried creating a new perm set, and also tried the Everything and other perm sets, but none seem to work. Has anyone had any experience with this? You need to sign your assemblies with a strong

.net - Glass effect in C# 2.0 applications

时光总嘲笑我的痴心妄想 提交于 2019-12-06 09:25:13
问题 How can I give a Vista or Mac OS X style glass effects on windows forms applications in .net 2.0? 回答1: This is done using interop with the Vista DWM (Desktop Window Manager) API. For example, import these functions: [DllImport("dwmapi.dll")] static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMargins); [StructLayout(LayoutKind.Sequential)] struct Margins { public int cxLeftWidth; public int cxRightWidth; public int cyTopHeight; public int cyBottomHeight; } Then you can

Reference a .net 3.5 assembly in a Script Task in SSIS 2005?

佐手、 提交于 2019-12-06 09:06:23
I've got this to work using a very basic example(outlined below) and I want to see if other SOers have experience doing what I'm attempting...using a 3.5 framework assembly in a Script Task in SSIS 2005. I've basically followed the page found here ... except I targeted the 3.5 framework while in Visual Studio 2008. Write/compile your code (targeted the 3.5 framework) Just some simple Linq so that I'm using a greater than 2.0 framework feature using System; using System.Collections.Generic; using System.Text; using System.Linq; namespace Ext { public class Extend { public string GetValue () { /

Printing with the System.WIndows.Forms.WebBrowser control

拥有回忆 提交于 2019-12-06 07:11:25
I'm using th WebBrowser control in the .net 2.0 framework. Is it possible to change the printing behavior so it always prints to the default printer, without showing any dialog to the user? This is for a kiosk so there will always be a printer directly connected to the Kiosk, and printing should be seemless to the user. Get the default PrinterName using the method shown here http://msdn.microsoft.com/en- us/library/system.drawing.printing.printersettings.isdefaultprinter.aspx and then pass that name to the PrinterSettings property of the PrintDocument. Simply use the WebBroser.Print() method.

Alternative to SQL BULK INSERT

。_饼干妹妹 提交于 2019-12-06 06:52:41
I need to import the data form .csv file into the database table (MS SQL Server 2005). SQL BULK INSERT seems like a good option, but the problem is that my DB server is not on the same box as my WEB server. This question describes the same issue, however i don't have any control over my DB server, and can't share any folders on it. I need a way to import my .csv programatically (C#), any ideas? EDIT: this is a part of a website, where user can populate the table with .csv contents, and this would happen on a weekly basis, if not more often You have several options: SSIS DTS custom application