Wednesday, November 12, 2008
Microsoft.mshtml.dll cannot be referenced in VS 2008 3.5 project
When doing this I checked the Client-only Framework subset option. When I compiled I had errors indicating that the compiler could not reference Microsoft.mshtml.dll.
When I checked the project references this one was marked with the asterisk.
Unchecking Client-only Framework subset option corrected the problem.
Andy
Sunday, September 7, 2008
Testing Enumerations in Eco Ocl
I can never remember the Ocl syntax used to refer to the value of an enumeration.
The syntax is $enumname$::$enumvalue$
Here is a sample Ocl string to select a particular value of VehicleTypes
"VehicleSupplier.allInstances->select( Type = VehicleTypes::MotorHome)"
Monday, August 18, 2008
Using Linq extension methods with arrays
I was generating a file path and file name from user text.
This routine was vulnerable to chars illegal to the file system in the user text.
I needed to strip any illegal chars from the user text.
The Path class has two static methods which return path and file name illegal chars.
These are:
Path.GetInvalidPathChars( ) -> char[]
Path.GetInvalidFileNameChars( ) -> char[]
In order to strip both I wanted to create the set union of these two arrays.
The Linq set extension methods return IEnumerable
In the end I used the following to generate a set comprising the union of both sets of illegal chars.
List
Note that if you wish to change the file extension it is important to add '.' to the list of illegal chars. Failure to do so may result in your filename being truncated at the '.'.
Monday, June 23, 2008
Running wsewsdl3.exe in Vista 64 with VS2008.
Hi,
I ported a VS2005 project from my old XP machine to my new Vista 64 machine running VS2008.
In my project I was using Wsewsdl3.exe to generate c# code from wsdl definitions.
Wsewsdl3 refused to run with the error:
"Could not get the install directory for .NET Framework v2.0 SDK. Please install the .NET Framework v2.0 SDK."
I know that Wsewsdl3 is a pre-processor for Wsdl.exe and also knew that Wsdl.exe had changed paths between VS versions.
Luckily Wsewsdl3.exe is written in .Net and I was able to use Reflector to disassemble the source and find where it was looking for Wsdl.exe.
Here are the code fragments:
Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\.NETFramework");
key.GetValue("sdkInstallRootv2.0")
When I looked in the registry of the old machine I saw this key.
At this point I installed the .Net 2/0 SDK
http://www.microsoft.com/downloads/details.aspx?FamilyID=fe6f2099-b7b4-4f47-a244-c96d69c35dec&displaylang=en
This installed itself at:
C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0
Now I opened the registry editor RegEdit.exe, moved to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework and added a new string value with name
"sdkInstallRootv2.0" and value "C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0"
Wsewsdl3.exe now runs.
I hope this has not screwed anything else!
Hope this helps someone.
Andy
Tuesday, April 15, 2008
.Net SDK Tools movedin version 3.0 and 3.5
It used to be under:
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin
But as of Version 3 it has moved to:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
Sunday, April 6, 2008
XPathNavigator and default namespaces
<?xml version="1.0" encoding="utf-16"?><Invoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://informationage.co.nz/schema/invoicing">
<Amount>1906.50</AmountExcGst>
</Invoice>
How do I read the amount node in this xml document.
XmlDocument lXmlDoc = new XmlDocument();
lXmlDoc.LoadXml( soome source for the document above );
// Namespaces
XmlNamespaceManager lNamespaceManager = new XmlNamespaceManager( new NameTable( ) );
// Arbitrary prefix used for default namespace
lNamespaceManager.AddNamespace( "d", "http://informationage.co.nz/schema/invoicing" );
// Navigator
XPathNavigator lNavigator = lXmlDoc.CreateNavigator();
// Note that the default namespace elements must be preifxed with the namespace prefix.
XPathNavigator lNodeNav = lNavigator.SelectSingleNode( "/d:Invoice/d:Amount", lNamespaceManager );
The important thing to note here is that the XPath expression elements MUST be prefixed with the default namespace prefix
added to the namespace manager.
The expression "/Invoice/Amount" will return null.
This one wasted quite a bit of my time so I hope this helps someone else.
Andy
Sunday, February 17, 2008
Problems locating the assembly for Microsoft.Office.Core.DocumentProperties
I was trying to set document properties using code in the form:
( (Microsoft.Office.Core.DocumentProperties) mWordDocument.BuiltInDocumentProperties )[ Word.WdBuiltInProperty.wdPropertyCompany ].Value = "My Company Name";
I had referenced C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.Word.dll which was available in the GAC but I could not find the assembly which contained the definitions for Microsoft.Office.Core.DocumentProperties.
I found it at C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Office.dll
Hope this helps another frustrated searcher.
Detecting Office applications and versions
Wednesday, February 6, 2008
Converting Windows local file paths to uri and vice versa
e.g.
I wanted to convert a local windows path in the form:
"C:\Documents and Settings\William Tell\My Documents\TestClient"
to the form:
"file:///C:/Documents%20and%20Settings/William%20Tell/My%20Documents/TestClient"
This conversion is supported by the framwork System.Uri class.
Here is some code:
string localPath = @"C:\Documents and Settings\William Tell\My Documents\TestClient";
Uri uri = new Uri( localPath );
string absoluteUri = uri.AbsoluteUri;
The value of absoluteUri is:
"file:///C:/Documents%20and%20Settings/William%20Tell/My%20Documents/TestClient"
Conversely, we can convert the uri back to a local path as follows:
string absoluteUri = @"file:///C:/Documents%20and%20Settings/William%20Tell/My%20Documents/TestClient";
Uri uri = new Uri( absoluteUri );
string localPath = uri.LocalPath;
The value of local path is:
""C:\\Documents and Settings\\William Tell\\My Documents\\TestClient"
Hope somebody finds this helpful.