by Dominic Zukiewicz
31. October 2007 12:18
I spent hours looking over 4 or 5 lines of code concerning these compression/decompression streams to find out why it was compressing and not decompressing. The problem resulted in the decompression stream returning a zero length byte array for the resulting data. The problem also replicated itself as being too long. What went wrong? This works! //Decompress
private static string Uncompress(byte[] compressedData)
{
MemoryStream ms = new MemoryStream(compressedData);
MemoryStream uncompressedStream = new MemoryStream();
GZipStream gZip = new GZipStream(ms,...
[More]
9a92ef0d-8e38-46af-a326-1ddb255657b8|0|.0
Tags:
Framework
by Brad
30. October 2007 09:48
Here is a typical select filter string that you might perform on a DataTable:
clients.Select(string.Format(" DisplayName = '{0}' ", ClientName));
However if ClientName in the above example contains an apostrophe the select will fail. A simple fix is to the use following code to escape it:
ClientName.Replace("'","''")
Which replaces a single apostrophe with two.
c8e409dc-0692-4f3c-9913-6f05ab58dbf7|0|.0
Tags:
C#
by Brad
30. October 2007 09:35
Here's how to create a Domain Local Group in Active Directory using C#
using (DirectoryEntry myDE =
new DirectoryEntry(LDAPPath, LDAPUsername, LDAPPassword))
{
DirectoryEntries myEntries = myDE.Children;
using (DirectoryEntry group = myEntries.Add("CN=" + Name, "group"))
{
group.Properties["sAMAccountName].Add(Name);
group.Properties["groupType].Add("-2147483644"); //DOMAIN LOCAL GROUP
group.CommitChanges();
}
}
Also one thing to note - if the Name ends in a full stop it will fail with a really non-helpful message of "A device attached to the sy...
[More]
37afd398-f492-41d9-8a2b-04b00931a7c3|0|.0
Tags:
C#
by Brad
29. October 2007 11:53
I've been using the Microsoft Excel COM object in C# to allow me to open spreadsheets, process them and then upload to a web service, all worked nicely - or so i thought! After a while i noticed the PC running slowly - so i checked Task Manager and was horrified to see hundreds of EXCEL.exe processes running!
As the Excel Application object is a COM object there's no nice Dispose() method to call, and setting to null didn't help either... after some searching i found the answer:
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
//Do some...
[More]
cafdc5b0-f203-46fe-b29b-c9a531e06609|0|.0
Tags:
C#
by Brad
23. October 2007 09:47
If you've ever got the following annoying message when trying to RDP to a remote server:
"The terminal server has exceeded the maximum number of allowed connections. The system cannot log you on. Please try again or consult your system administrator"
Then normally you've got to either ask another user to log off (not easy if its a remote server) or wait for them to. A little known trick is to use the following command line parameter when launching remote desktop: /console
From the command prompt type:
mstsc /console
This will launch it in console mode, which in layman's terms me...
[More]
by Brad
23. October 2007 09:37
The new service pack (SP1) for Microsoft Virtual Server 2005 R2 added some new functions to the COM API. There's too many to list, but the one i've found most useful allows you to return the guest machine's computer name as it appears on the network - very useful for automation scripts, or simply launching a Remote Desktop client (as i wanted).
Unfortunately the documentation on it isn't great and it took me a while to find it when using C#, (thanks mainly to a few emails to/from Ben aka "Virtual PC Guy" http://blogs.msdn.com/virtual_pc_guy). It turns out you need to cast the GuestOS proper...
[More]
by Dominic Zukiewicz
23. October 2007 08:25
The Windows Service I built needed to access a web service on another domain (and in production on another server over the internet). The admin made the service run as NetworkService to reduce the security permissions.
I received an error stating:
"System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it"
The error, in my case, was not to do with a firewall, or a connection problem with regards to TCP/IP, its purely that the NetworkService account cannot a) ...
[More]
cd3f6f62-4d29-4539-8801-c08cf75fb683|0|.0
Tags:
Misc
by Dan Matthews
19. October 2007 10:13
According to ADXSTUDIO, you need Active Directory when deploying ADXSTUDIO 2006, even if using ADAM. Fortunately, that doesn't seem to be ENTIRELY the case.
We've successfully deployed a site using the IUSR account using a local account and still managed to deploy a site fine using ADAM - to a point. Critically, the server is on a Workgroup.
Only problem is the document access and web permissions editors in the administration console. They don't like it :)
We'll be seeing if we can crack that nut next!
d87a9634-b9a1-469e-8847-11cee53ca1c4|0|.0
Tags:
ADXSTUDIO
by Dominic Zukiewicz
18. October 2007 10:06
The admin's decided to run my Windows Service under the NetworkService account to improve security.
The problem is that where I thought I was saving temporary files to the directory of my application using Environment.CurrentDirectory , it was retrieving C:\windows\system32 ????
I therefore had to change the way I retrieved the local directory to:
string directory = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName;
This means that any logging files that used to be xxx.log, now have to give their full path.
by Dan Matthews
8. October 2007 14:43
Historically we've been seen as a Microsoft shop within the UK eBusiness division - quite rightly too. As part of the wider B&D group though we have a lot of experience in the Java/Open Source arena to bring to the party as well. For example, currently we provide solutions expertise in all the following ECM/CMS systems:
SME /\ ADXSTUDIO (Closed Source / .NET)
| Pelikan (Open Source / PHP)
| EPiServer( Closed Source / .NET)
| Nuxeo (Open Source / Java)
Enterprise \/ ...
[More]
by Dominic Zukiewicz
1. October 2007 14:59
I was trying to debug an issue, where my application was using Distributed Transactions to do database access. The data was to be inserted across 4 databases in a transaction, where it was an all or nothing.
The environment was configured as 2 clusters: 4 VPCs that were all cloned (app layer). This cluster talked to another cluster of DB VPC's (data layer), each being a clone of the original image.
Anyway, here is the error I was getting:
An error occurred while enlisting in a distributed transaction
MS DTC was running on both layers, so this error wasn't very helpful.
The next...
[More]
431f98b6-7b37-4ec7-93df-2fa093ff483c|0|.0
Tags:
Misc