.net-2.0

ASP.Net using wrong web.config for virtual directory

戏子无情 提交于 2019-12-07 08:58:30
问题 We're running IIS 6 on Windows Server 2003 R2. We want to add a virtual directory that runs under .NET 4.0 to a site that runs under .NET 2.0. We've given the virtual directory its own app pool, and we've configured the virtual directory to run under 4.0. The parent site works fine, but the virtual directory throws errors that reference the parent site's web.config file. We need the virtual directory to use its own web.config file. The GUI in the IIS Manager says that the virtual directory is

Web service variable shared for the lifetime of the webservice?

 ̄綄美尐妖づ 提交于 2019-12-07 08:24:03
问题 How can I make a variable (object) available for the whole lifetime of the webservice? Static variable seem to work but is there an other way to do it? 回答1: Static variables exist for the lifetime of the App Domain that contains them. In the case of a web service, this is usually the ASP.Net Worker Process. What that means is that when IIS decides to cycle the worker process, your static variable will be gone. This may be what you want, in which case it is probably a good choice. (Putting

How to set TextBox cursor position without SelectionStart

女生的网名这么多〃 提交于 2019-12-07 07:01:20
问题 I have a Windows Forms textbox with background thread updating its value every second. If I place cursor inside textbox it will loose its current position at next update. Same thing with text selection. I tried to solve it like that protected void SetTextProgrammatically(string value) { // save current cursor position and selection int start = textBox.SelectionStart; int length = textBox.SelectionLength; // update text textBox.Text = value; // restore cursor position and selection textBox

Serialize in a human readable text format

ⅰ亾dé卋堺 提交于 2019-12-07 05:25:43
问题 Is there a way in .NET 2.0 (C#) to serialize object like you do using XmlSerializer in a simple / customizable human readable format thats for instance looks like PXLS or JSON? Also I know that XML is human readable, I'm looking for something with less annoying redundancy, something that you can output to the console as a result for the user. 回答1: To Serialize into JSON in .NET you do as follows: public static string ToJson(IEnumerable collection) { DataContractJsonSerializer ser = new

What should I use to serialize a DataTable to JSON in ASP.NET 2.0?

↘锁芯ラ 提交于 2019-12-07 05:06:16
问题 I'm trying to support a legacy app I made a year ago and need to use jQuery AJAX calls to get data from the server. I have a JsonHelper class that I use to serialize DataTable s and DataSet s. This normally works fine in .NET 4.0, but .NET 2.0 there is no System.Web.Script.Serialization library and therefore no JavaScriptSerializer class. I've tried to find another JSON serializer, but so far I can't get anything to work. I tried using JSON.NET 2.0 http://json.codeplex.com/releases/view/13099

How to determine which version of Windows?

拈花ヽ惹草 提交于 2019-12-06 20:29:25
问题 How to determine which version of Windows? WinXP, Vista or 7 etc. 32 or 64 bit? UPD: for .Net 2.0 - 3.5 回答1: You're looking for the Environment.OSVersion , Environment.Is64BitProcess , and Environment.Is64BitOperatingSystem properties. Before .Net 4.0, you can check whether the process is 64-bit by checking whether IntPtr.Size is 8 , and you can check whether the OS is 64-bit using this code: public static bool Is64BitProcess { get { return IntPtr.Size == 8; } } public static bool

Why can't set cast an object from Excel interop?

邮差的信 提交于 2019-12-06 20:25:31
问题 Trying to get a reference to the worksheets (using Excel interop): Excel.Application xl = new Excel.ApplicationClass(); Excel.Workbooks xlWorkBooks = xl.Workbooks; Excel.Workbook xlWorkBook = xlWorkBooks.Open(fileName, 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); // Next line crashes Excel.Worksheets xlWorkSheets = (Excel.Worksheets) xlWorkBook.Worksheets; The error is that it cannot cast it: Unable to cast COM object of type 'System.__ComObject'

How to get short “domain name” from dns domain name?

↘锁芯ラ 提交于 2019-12-06 16:28:31
Forgive me if my understanding of this topic has some shortcomings, I only know what I know about domains and active directory because of what I've picked up from working with them. There are two different "versions" of a domain name. The first is what I call the DNS domain name which would be like company.int (for the user max@company.int) and the second would be like prefixname (for the user prefixname\max) and they would both refer to the same thing. My question is, given "company.int", how do I convert that to "prefixname"? EDIT: Or given a System.DirectoryServices.ActiveDirectory.Domain

Can you create sub-applications within applications in IIS/ASP.Net

丶灬走出姿态 提交于 2019-12-06 16:09:10
We have a global application (well out of my control) that runs a lot of sites. I'd like to create a new application (as I cant extend etc) within a folder so it could be accessed as follows. http://www.domain.com/ < Global App http://www.domain.com/newapp < New App Is this actually possible or just a pipe dream; I'm aware that its possible to set additional locations for assemblies (as per: http://msdn.microsoft.com/en-us/library/4191fzwb(VS.80).aspx ) but a full app I'm not to sure. Ta Razzie You can create a new virtual application from IIS under the main application, which is very easy but

How to make a search usercontrol generic in .net2.0 winforms

你。 提交于 2019-12-06 15:14:25
I have a search usercontrol that I'd like to make generic. The control itself will contain a different collection of controls dependent on its context. For example it could be stock items, people, address as the context of the search.. How can I make it generic enough that based upon the search context it knows exactly what user controls it needs on the form? Any programmer can then just drag the user control onto their form, set it's context and we are good to go. My first thought is to create a base control for all the individual user controls and the search dialog accepts these in the