The variable contains a reference to the Form instance, a copy of that reference gets passed on to the Window Manager (or whatever), at which point your app and the whatever both refer to the instance, even when your reference is destroyed the whatever maintains its reference.
When ever you create a form and show it, a reference to the form is added internaly. There is a property of Application Object named "OpenForms" which returns a read only FormsCollection containing all the forms opened by the application. Since a reference is held to the form object even though your local variable is collected by gc, the form does not get collected. You can access the form through that collection and call the close method on it to close the form. Then the form is removed from the OpenForms collection and will be collected by the gc.
I am using the AddInParameter to add a Int32 value as a SQL paramter. The problem I am having is that it is possible for this value to be null. When I try using logic to return either the int value or a DBNull value as the parameter, because the parameter type is DbType.Int32 I get a build error. How can I, based on the value of the insert integer, either add the actual int value or a DBNull value in the AddInParameter method?
It occurs to me that for a library that supports .net 2 to include support for Extension Methods when compiled with later versions, I should use something like:
public static SomeType
# if SomeConstant
But is there a built-in constant to do that? I could easily define one myself, but it wouldn't be standard.
For command-line builds I can easily add a define to C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.rsp,
but that doesn't help with Visual Studio builds. I can add the define to the project properties, but I'd have to add it to each project that might contain Extension Methods, and remove it if I have to switch the target framework back to 2 (for whatever reason).
Does anyone else have a way of dealing with this issue?
Is there simply a better/more-standard way of doing this already?
Unfortunately there really aren't any built in conditional symbols like you are looking for. The best/only option is to define a symbol yourself.
If you are compiling using VS2008 and the multi-framework targeting features, check out this blog post[^] by Daniel Moth. He shows how to get extension methods to work in .NET 2.0. You would still need to define your own symbol, but you would only need to have it in one place (around the .NET 2.0 extension attribute class).
Well, I knew about the Attribute, and I really wish they had simply allowed the use of it to decorate methods directly rather than mangling the language, but they didn't ask me. And there are other things I don't like about Extension Methods, but that's just me.
Anyway, I copied his Attribute to my library, and it compiled in VS 2008!
At the command-line, using the V3.5 CSC.EXE, I got
warning CS1685: The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'c:\Projects\PIEBALD\Attributes\ExtensionAttribute.cs'
But the V2.0 CSC.EXE doesn't like the this syntax, likewise as expected.
Oh, and it's not entirely for how I build, but if/when I write a method to post here I may choose to write it as an Extension Method for the users who use them, but not have it break for the users who are using .net 2.
If I can, I should; if I can't, then I'll leave it out.
I am streaming a large file (a 900mb FLV movie) over localhost, but just past the halfway, the program throws this exception:
The specified network name is no longer available at System.Net.HttpResponseStream.Write(Byte buffer, Int32 offset, Int32 size)
We've tried the program on 5 machines (both XP and Vista), and it works on everybody's but mine.
Does anyone know why and/or have a solution?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
I am not sure but, when you open any webpages on local machine, at first time windows will ask you to "Enable Intranet Settings" for better performance on information bar. check that settings. may be its blocking larg file streaming.
Last Visit: 31-Dec-99 18:00 Last Update: 15-Jun-21 7:27