C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\BinWindows.web is not available in the.NET Framework Client Profile. You must pick the full.NET Frameworkto be available. To change the profile go to the project settings and changed the value forTarget framework:
After the correct framework is chosen you can findSystem.Webunder the.NETtab of theAdd Referencesdialog.
this.Stop();See: http://www.akadia.com/services/dotnet_databinding.html
An AppDomain can be thought of as a lightweight process. Multiple AppDomains can exist inside a Win32 process. The primary purpose of the AppDomain is to isolate applications from each other, and so it is particularly useful in hosting scenarios such as ASP.NET. An AppDomain can be destroyed by the host without affecting other AppDomains in the process.
Win32 processes provide isolation by having distinct memory address spaces. This is effective, but expensive. The .NET runtime enforces AppDomain isolation by keeping control over the use of memory - all memory in the AppDomain is managed by the .NET runtime, so the runtime can ensure that AppDomains do not access each other's memory.
One non-obvious use of AppDomains is for unloading types. Currently the only way to unload a .NET type is to destroy the AppDomain it is loaded into. This is particularly useful if you create and destroy types on-the-fly via reflection.
It is important to note that only type-safe code can be managed in this way (the runtime cannot guarantee isolation when unsafe code is loaded in an application domain).
Some of the advantage of using AppDomain are:
From http://mihirsolanki.com/blog/archive/2005/12/05/1891.aspx
Show() for modeless, and ShowDialog() for modal.Hide()Close() or Dispose()
private int GetValueViaModal()
{
// using lets the system know it can dispose of this as soon as it goes out of scope.
using( FormInputValue form = new FormInputValue())
{
DialogResult dr;
dr = form.ShowDialog();
if ( dr == DialogResult.OK) {
return form.GetInputtedValue;
}
}
}
CancelEventArgs's Cancel property to false to say validation failed.
using SWF = System.Windows.Forms;
public static void IsInteger( object sender, System.ComponentModel.CancelEventArgs e)
{
SWF.TextBox txt;
txt = (SWF.TextBox) sender;
try {
int.Parse(txt.Text);
} catch {
SWF.MessageBox.Show("Bad input.", "Note");
e.Cancel = true; // makes focus stay in control so user can fix problem
}
}
private Form_Load( object sender, System.EventArgs e)
{
txtField1.Validating += new System.ComponentModel.CancelEventHandler( IsInteger);
}
private Form_RemoveValidation( object sender, System.EventArgs e)
{
txtField1.Validating -= new System.ComponentModel.CancelEventHandler( IsInteger);
}
IsolatedStorageFile
public class Globals
{
public static readonly bool Trace;
static Globals()
{
try {
Trace = System.Convert.ToBoolean( System.Configuration.ConfigurationSettings.AppSettings["Tracing"] );
} catch {
Trace = true;
}
}
}
Same name as executable with .config appended to it, and
it lives in the same directory as the executable.
For example if the app is App.exe the config file is
App.exe.config
Note: In Visual Studio you can Project | Add New Item | Application Config File
to create a config file that automatically gets placed where the app
goes and will name it correctly on copy (for example: Deubug or Release
<configuration> <appSettings> <add key="Tracing" value="true" /> </appSettings> </configuration>
using T = System.Diagnostics.Trace;
try {
T.WriteLineIf( Globals.Trace, "Entering Something");
T.Indent();
T.WriteLineIf( Globals.Trace, "Doing something");
} catch {
T.WriteLineIf( Globals.Trace, ex.GetType() + ": " + ex.Message);
T.WriteLineIf( Globals.Trace, ex.StackTrace);
} finally {
T.Unindent();
T.Flush();
}
public static void Main()
{
string logfile = System.AppDomain.CurrentDomain.BaseDirectory + "TraceLog.txt";
System.IO.TextWriter log = new System.IO.StreamWriter( logfile);
if ( Globals.Trace) {
System.Diagnostics.TextWriterTraceListener logger;
logger = new System.Diagnostics.TextWriterTraceListener( log);
System.Diagnostics.Trace.Listeners.Add( logger);
System.Diagnostics.Trace.WriteLine("App starting: " + DateTime.Now);
}
}
Based upon webcasts by Joe Hummel
Equals( object obj)GetHashCode()Dispose() (and make the class inherit IDisposable )
if your objects need cleanup.IDisposable and supply Dispose()
and Close methods.IDisposable then you should have a finalizer
as well ~ClassnameICloneable and then define
Clonethis.MemberwiseClone() will return a shallow clone.ICloneable is Depricated so maybe use these 2 methods
instead DeepClone() and ShallowClonethrow new Exception("Exception Text");waitForPendingFinalizers() on the
Garbage Collector. Otherwise the program may exit before
all Dispose()'s are called
public enum Weekdays
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}
/// <summary>
/// This is an example class
/// </summary>
public class Example
{
private string m_strName;
private int m_nAge;
static int m_nSecretNumber;
public static readonly float PI = 3.14;
private int m_value1; // field used by property starting on next line
public string Value1 // property
{
get { return m_value1; }
set {
if ( m_value1 >= 0) {
m_value1 = value;
}
}
}
// readonly property:
private int m_value2; // field used by property starting on next line
public string Value2 // property
{
get { return m_value2; }
}
// writeonly property
private int m_value3; // field used by property starting on next line
public string Value3 // property
{
set {
if ( m_value3 >= 0) {
m_value3 = value;
}
}
}
public Example( string strName, int nAge) {
m_strName = strName;
m_nAge = nAge;
}
// finalizer:
~Example()
{
}
// Constructor that calls base constructor
public Example( string strName)
: this( strName, -1) {
}
// static constructor:
static Example() {
m_nSecretNumber = 42;
}
public override ToString() {
return "Example Object";
}
/// <summary>
/// Custom Equal because
/// </summary>
public override bool Equal( Object obj) {
if ( obj == null)
return false;
if ( !(obj.GetType().Equals( this.GetType())) )
return false
Example other = (Example)obj;
return
m_strName.Equals( other.m_strName()) &&
(m_nAge == other.m_nAge);
return true;
}
public override int GetHashCode() {
return m_strName.GetHashCode() + m_nAge.GetHashCode();
}
}
Provide a way to have a short name for a namespace.
using SW = System.Windows;
Disassembles to high level code
download files cache gacutil option /ldl says it Lists the contents of the downloaded files cache
I have seen an assembly in there I was concenred about.
| Tool | Use |
|---|---|
| gacutil.exe | Manage Global Assemblies, list, empty from cache, etc. |
sn -k {filename}[assembly:AssemblyKeyFileAttribute("key1.snk")];A thread that has its IsBackground property set to true, will not stop the application from exiting.
| Term | Definition |
|---|---|
| Application Domains | Effectively 'Process Boundries', but you can make code in the same app be seperated into Application Domains as well. There are ways that you can access objects in another Application Domain |
| Boxed Type | Value type that has been converted to an object (in Java this would be Integer which wraps int) |
| CLS | Common Language Specification (a set of rules that allow cross language interoperability) |
| Managed code | Code run in the CLR. It is garbage collected, must obey security polices, and is verified safe to other code (i.e. no bad pointers can damage data of other apps or things running in a different Application Domain) |
| Managed C++ | C++ supporting .NET (has garbage collection) |
| Side-by-Side Execution | Allows multiple versions of libraries to be co-exist on the same computer, or even the same process |
| Value Type | Basically a built-in type (like int or double) |