.net

Why can't IEnumerator's be cloned?

In implementing a basic Scheme interpreter in C# I discovered, to my horror, the following problem: IEnumerator doesn't have a clone method! (or more precisely, IEnumerable can't provide me with a "cloneable" enumerator). What I'd like: interface IEnumerator<T> { bool MoveNext(); T Current { get; } void Reset(); // NEW...

How do I create a C# app that decides itself whether to show as a console or windowed app?

Is there a way to launch a C# application with the following features? It determines by command-line parameters whether it is a windowed or console app It doesn't show a console when it is asked to be windowed and doesn't show a GUI window when it is running from the console. For example, myapp.exe /help would output to stdout on the...

Collection was modified; enumeration may not execute error when removing a ListItem from a LIstBox

I have two ListBoxes, lstAvailableColors and lstSelectedColors. Between each listbox are two buttons, Add and Remove. When a color or colors is selected in lstAvailableColors and the Add button is clicked, I want to remove them from lstAvailableColors and display them in lstSelectedColors. Also, if colors are selected in lstSelectedCo...

Reentrancy was detected

I'm getting "Reentrancy was detected" MDA error while setting a webbrowser control's properties. This only happens if I call "SetWindowsHookEx" to hook some dials within the same thread. Normally this hooking code works fine but it doesn't play nice with Webbrowser Control. When I ignore the exception code works fine, at least look like...

Explain this LINQ code?

I asked a question in which one of the response contained the following LINQ code: var selected = lstAvailableColors.Cast<ListItem>().Where(i => i.Selected).ToList(); selected.ForEach( x => { lstSelectedColors.Items.Add(x); }); selected.ForEach( x => { lstAvailableColors.Items.Remove(x);}); Can someone explain the above LINQ to a tota...

.net 3.5 c# works locally but not when I publish to shared account

Hi! I am new to .NET and have a problem. I have an app that creates a security token to use remote web services. When I run the app locally on my machine it works fine (in the Visual Web Developer Express 2008). I then took a shared hosting Windows account on godaddy.com. When I publish the site and then check online, I get the error: ...

Security error in ASP NET shared account

Hi, These lines cause a security exception in a godaddy account. Any suggestions how to rewrite to get this to work? File.Delete(PropsFileName); // Clean up TextWriter tw = new StreamWriter(PropsFileName); // Create & open the file tw.WriteLine(DateTime.Now); // Write the date for reference tw.WriteLine(TokenLine); // Write t...

Creating an xml file from xsd in .NET

Hi everyone, I would like to know the best method for solving this problem: I would like to create a blank template xml from a xml schema. All the required elements and attributes would be created and their values would be all empty strings. The next step is how to determine which child xml nodes a certain node could have. eg. I would s...

Can I Merge Footer in GridView?

I have a GridView that is bound with a dataset. I have my footer, whichis separated by the column lines. I want to merge 2 columns; how do I do that? <asp:TemplateField HeaderText="Name" SortExpression="Name"> <ItemTemplate> ... </ItemTemplate> <FooterTemplate > Grand Total: </div> </FooterTemplate> </asp:Templat...

Libraries for recieving Faxes for .NET platform

Can you recommend a library for .NET that can receive FAXes? Window Fax server is not enough - need to auto process and route the Fax once it is received based on the incoming Caller ID. ...

Combine two (or more) PDF's

Background: I need to provide a weekly report package for my sales staff. This package contains several (5-10) crystal reports. Problem: I would like to allow a user to run all reports and also just run a single report. I was thinking I could do this by creating the reports and then doing: List<ReportClass> reports = new List<ReportCla...

Creating an interactive shell for .NET apps and embed scripting languages like python/iron python into it

I was learning python using the tutorial that comes with the standard python installation. One of the benefits that the author states about python is "maybe you’ve written a program that could use an extension language, and you don’t want to design and implement a whole new language for your application" - My question is how would i go a...

Why does a Linq Cast<T> operation fail when I have an implicit cast defined?

I've created two classes, with one of them having an implicit cast between them: public class Class1 { public int Test1; } public class Class2 { public int Test2; public static implicit operator Class1(Class2 item) { return new Class1{Test1 = item.Test2}; } } When I create a new list of one type and try t...

Set System Time Zone from .NET

Does anyone have some code that will take a TimeZoneInfo field from .NET and execute the interop code to set the system time zone via SetTimeZoneInformation? I realize that it's basically mapping the TimeZoneInfo members to the struct members, but it does not appear obvious to me how the fields will map exactly or what I should care abou...

Appropriate .Net data type for decimal(20,0)

I've got some sql returning a decimal(20,0) data type. In SSIS I have a package with a foreach loop. In my variable mappings, what type of variable would I map it to? I've tried Int32, Int64, double, and still get the error "The type of the value being assigned to variable "User::iID" differs from the current variable type..." ...

Threaded image-scaling sub still bogs down UI

I created an image-viewing control for my boss that incorporates panning, zooming via the mouse wheel, and drawing a box to zoom to. The control needs to support very large image files (i.e. several thousand pixels on each side). It all works, but whenever the code is scaling the image the control UI becomes unresponsive. My boss had ...

Windows forms Text Changed on leave event

Maybe I'm just an idiot, but I can't seem to find an event that will fire for a textbox at the same time as the leave, but only when the contents of the textbox has changed. Kinda like a combination of textchanged and leave. I can't use textchanged cause it fires on each keystroke. Right now I'm storing the current value of the textbo...

How do I find the owner of a given database?

Using .NET's DbConnection.GetSchema(), how do I find the owner of a given database? Alternatively, if you have another solution that is not coupled to a specific impelementation of SQL, I'd like to hear that as well. ...

string.Format throws System.Format exception on HTML + javascript

I'm running string.Format on a readonly string that contains a bit of HTML + javascript but I get a System.FormatException instead. This is my format string: <script type="text/javascript"> function {0}_showHideFieldWindow() { if ({0}.IsCustomizationWindowVisible()) { {0}.HideCustomizationWindow(); } els...

Any downsides or better alternatives to calling .NET Page Methods with jQuery?

I need to come up with a smarter/simpler way of doing ajax calls in our current .net webforms app. I know jQuery basics and I like it alot. I'm thinking of proposing to my team the use of jQuery to directly call .net Page Methods as described here. Does anyone know of any problems/limitations with this approach? Is there a simpler w...