Posted by David Carroll
The basic architecture is simple. Excel 2003 and Word 2003, upon loading a document, check for two custom properties in the document: _AssemblyLocation0 and _AssemblyName0. If these properties are found, the host application loads the Visual Studio Tools for the Microsoft Office System Assembly Loader (Otkloadr.dll). This unmanaged DLL is responsible for loading the assembly that you created using Visual Studio Tools for the Microsoft Office System. The loader uses the document's custom properties to find the document's assembly, loads the assembly into memory, examines some metadata, sets up references between the host and the assembly, and then steps out of the way.
If you change the Assembly Link Location property or the name of the assembly and then rebuild your project, the _AssemblyLocation0 and _AssemblyName0 document properties will be updated during the build process. However, the build process will not update the security policy to reflect your change; security policies are updated only during the initial project creation. So, if you change either the Assembly Link Location or the assembly name, you will need to update your Microsoft .NET security settings to reflect the new file name or location.
You should also make note of the project's Copy Assembly property. If Copy Assembly is disabled or set to False, the build process will not copy the assembly to the link location. When you change the project's Assembly Link Location to a network path, the Copy Assembly property is automatically set to False. Likewise, when you change the Assembly Link Location to an HTTP path, the Copy Assembly property is disabled.
from: Smart Client Developer Center Home and Visual Studio Tools for Office
Posted by David Carroll
From Agile Software Development, Principles, Patterns, and Practices by Robert C. Martin
Design Smells, the odors associated with rotting software.
- Rigidity - System is hard to change in even the most simple ways.
- Fragility - Changes cause system to break easily and require other changes.
- Immobility - Difficult to entangle components that can be reused in other systems.
- Viscosity - Doing things right is harder than doing things wrong.
- Needless Complexity - System contains infrastructure that has no direct benefit.
- Needless Repetition - Repeated structures that should have a single abstraction.
- Opacity - Code is hard to understand.
via David Hayden
Posted by David Carroll
.NET Framework Assemblies Marked with AllowPartiallyTrustedCallersAttribute Lists the framework assemblies which allow calls from downloaded code. All others have an explicit demand for "Full Trust".
Noel Fouts, a co-worker of mine and a good friend, was investigating this issue related to some .NET WinForm controls we are using in some of our applications. He sent out the following email as a summary of his findings. It is an excellent summary of why our controls required "Full Trust."
I have conducted quite a bit of testing on our client side .Net code and thought I would share my research.
Evidence Testing - Evidence is what the .NET Framework uses to identify the code that is about to run. You create an evidence policy to link to a set of permissions to grant your code.
For downloaded exes and their dependencies all types of evidence is supported. This includes a Strongname. The customer can use the Strongname we sign our code with to identify our code. This would only work for Tranproc because it is an exe.
For hosted user controls only "Site" and "URL" types of evidence are supported. For URL, only the "http:/sitename/directory/*" format is supported. You cannot reference a specific assembly in the URL. You must use an asterick.
Permission Testing - Permissions are the rights the code is granted. Some code requires the "Full Trust" permission because it calls other libraries that do not have the "Allow Partially Trusted Callers" bit set. Any downloaded code or code that calls unmanaged code is considered "Partially Trusted."
In Framework 1.1 when code is downloaded from a URL it has some minimal rights. (1.0 gave no intial rights) Additionaly rights can be granted in situations where the code is calling other assemblies that have the "Allow Partially Trusted Callers" bit set to true. If it calls any code with that bit set to false it requires the "Full Trust" permission.
Any code that inherits from System.Windows.Forms.Usercontrol requires "Full Trust." This is true for all of Winforms and most of Tranproc. Full control is also required for those time when we use the "AxSHDocVw.dll" library to run a web browser window. This is true for several cases in both Winforms and Tranproc.
Deployment - Some .NET code can be deployed from a URL and some can be deployed to a users workstation.
The Tranproc.exe can be pre deployed to a users workstation. It can be launched from their hard drive via a "file:///” url, however the user will get a File Open/Save dialog box.
WinForm controls cannot be preinstalled. They are not an executable therefore they cannot be launched from an "" anchor tag. They are hosted by IE and IE as a security measure will not launch the container control found in the CLASSID of the Object tag from the permant GAC or the harddrive. You can however preinstall any depency assemblies in the GAC and they will load if they have been granted the correct permissions. To reiterate though, the main control that the webpage hosts cannot be loaded from the users GAC.
I hope this is helpful.
Noel Fouts, MCSD, MCDBA, MCSE
The most suprising thing to me is the requirement that all winform controls which inherit from UserControl have "FullTrust" in order to run. That seems to defeat the pitch that .NET is much safer than ActiveX controls. It means you really have to explain well the Evidence Based part which allows your machine to trust code only from this site as if it were part of your local machine. I think that if you can get this across in your pitch to a client who is at first resistant to any downloaded controls, they will accept it.
Posted by David Carroll
<%@ Import Namespace="System.Threading" %>
<%@Page Language="VB" %>
<html>
<%
Response.Write("<div id='mydiv'>Loading</div>")
Response.Write("<script language=javascript>;")
Response.Write("var dots=0;var dotmax=10;function ShowWait()")
Response.Write("{var output;output='Loading';dots++;if(dots>=dotmax)dots=1;")
Response.Write("for(var x=0;x<dots;x++)output+='.';mydiv.innerText= output;}")
Response.Write("function StartShowWait(){window.setInterval('ShowWait()',1000);}")
Response.Write("function HideWait(){mydiv.style.display='none';window.clearInterval();}")
Response.Write("StartShowWait();</script>")
Response.Flush()
Thread.Sleep(10000)
%>
<head>
<script>HideWait();</script>
</head>
<body>
<h1>Loaded</h1>
</body>
</html>
Posted by David Carroll
| Option | Description |
|---|
| Multiline | Has nothing to do with how many lines are in the input string. Rather, this simply modifies the behavior of ^ and $ so that they match BOL and EOL instead of the beginning and end of the entire input string. |
| IgnorePatternWhitespace | Allows pattern to have as much white space as desired, and also enables the use of in-pattern comments, using the (?# comment #) syntax. |
| SingleLine | Has nothing to do with how many lines are in the input string. Rather, will cause the . (period) metacharacter to match any character, instead of any character except \n, which is the default. |
Posted by David Carroll
public override bool Equals(object obj)
{
if (obj == null) return false;
if (this.GetType() != obj.GetType()) return false;
// safe because of the GetType check
Customer cust = (Customer) obj;
// use this pattern to compare reference members
if (!Object.Equals(Name, cust.Name)) return false;
// use this pattern to compare value members
if (!Age.Equals(cust.Age)) return false;
return true;
}
Posted by David Carroll
excerpted from Roger Sessions at ObjectWatch via Jason Tucker
An Service-Oriented Architecture (SOA) is an architecture that defines how autonomous systems interoperate with particular focus on:
- Asynchronous communications
- Heterogeneous transport channels
- Proof of identify
- Error management
- Workflow coordination
If two systems are autonomous, then they have no mutual dependencies. This implies that neither system interrupts its own work to wait for some other system to complete its task. This implies asynchronous communications. The first SOA principle is therefore asynchronous communications.
If two autonomous systems interoperate, then there must be a communications channel between the two that is independent of the technology used by either system. The second SOA principle is therefore heterogeneous communications channels.
If two systems are truly autonomous of each other, then there is a natural healthy mutual suspicion that must be maintained. In order to get beyond this, there must be a way for each system to convince the other that it is really who it claims to be. The third SOA principle is therefore proof of identify.
It would be great if everything worked every time. Unfortunately, things don’t always work. An architecture of interoperability must take into account what happens when things don’t work as well as when things do work. The fourth SOA principle is therefore error management across the systems matrix.
When multiple autonomous systems are communicating with each other asynchronously, keeping track of where we are in the overall workflow effort is much more complicated than when systems are working together synchronously. The fifth SOA principle is therefore workflow coordination.
Posted by David Carroll
I just learned something about XSLT. It is called an attribute value template. For example, instead of having to use the following construction to create a link:
<a><xsl:attribute name="href">
<xsl:value-of select="@url"/>
</xsl:attribute>My Link
</a>
you can simply say
<a href="{@url}">My Link</a>There is a lot of XSLT code I need to go clean up now...
Posted by David Carroll
Kevin asked about the code I was using to generate the reading plan. Here are some links to the source code and to the xml file of the Bible books and daily readings.
Enjoy!
Posted by David Carroll
ColAutoResize is an undocumented Private member of Datagrid. This is how to call it via Reflection:
Dim gridType As Type = grid.GetType()
Dim mi as MethodInfo = gridType.GetMethod("ColAutoResize", _
BindingFlags.Instance Or BindingFlags.NonPublic)
mi.Invoke(grid, New Object() {0})
Posted by David Carroll
If
(Control.ModifierKeys And Keys.Control) = Keys.Control Then
DoSomethingElse()
Else
DoSomethingDifferent()
End If
Posted by David Carroll
I use BlogLines, the web-based RSS aggregator. I wanted to be able to use my subscription list on their site to feed my BlogRoll on my site. They make available a javascript based BlogRoll which makes a call to the BlogLines website each time a page is loaded, but I wanted to be able to cache the blogRoll information so that it was only refreshed once per day. The way I did it was to read my OPML xml data from their site using the following url:
http://www.bloglines.com/export?username=davcar
Then I applied the xslt transformation to produce my blog roll which is only refreshed once per day using ASP.NET's capability to cache user controls.