Friday, June 20, 2008

Installing Reporting Services on Vista

Explains how to get SQL Reporting services instaled on Vista, or at least getting IIS to pass the SQL installer check

Here is the knowledge base article, the original post is pointing to
http://support.microsoft.com/default.aspx/kb/934164/en-us

Monday, December 03, 2007

Cruise Control.Net cannot find NUnit

I am setting up a continuous integration server for a project that I am working on. I had an interesting problem, my nant script was building without a problem, but when I ran it under cc.net, it failed. It turns out that NUnit was registered only under my user account, whereas the cc.net service was running under the system account and didn't have knowledge of some environment variables. The fix was go to the services and right click on the cc.net service, change to log on as option to the user that has access to those environment variables, then restart the service ... simple enough

Friday, October 26, 2007

HttpModule

Something that I didn't know even exists, not that I see myself using it ever, but still one of those nice things to know:here

Monday, October 08, 2007

Web Startups

One of the best articles I have read recently:
http://www.paulgraham.com/webstartups.html

Sunday, October 07, 2007

Reflection.Emit

OK, I was interested in generating code at runtime and compiling it. Not that I really need it, I was just curious how the whole thing works.
Here is a good article on MSDN that gives a pretty decent example.
And while the concept looks pretty cool, it doesn't look like(and I sure am glad for that) that I will have a need to use this anytime soon. Maybe if I was in the business of code generation and/or compiler business I would find a good use for it, but for now I think it just is rather complicated to find a good use for it.

Reflection

OK, for this example, I would need two projects, one is a c# console application and the other one is a c# DLL project.
The DLL will be called TestLateBinding and the Console App will be called Reflection.
Here are the classes that each one has:
DLL:
using System;
using System.Collections.Generic;
using System.Text;

namespace TestLateBinding
{
class TestClass
{
private void OnlyMethod()
{
Console.WriteLine("Printing from within OnlyMethod\n");
}
}
}

And the console application has Program.cs and TestDataType.

Here are the contents of TestDataType:

using System;
using System.Collections.Generic;
using System.Text;

namespace Reflection
{
public class TestDataType
{

public void print()
{
Console.WriteLine("Printing shit\n");
}

}

}

Here are the contents of Program.cs:

using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace Reflection
{
class Program
{
static void Main(string[] args)
{
TestDataType testObject = new TestDataType();
Type objectType = testObject.GetType();

ConstructorInfo[] info = objectType.GetConstructors();
MethodInfo[] methods = objectType.GetMethods();

// get all the constructors
Console.WriteLine("Constructors:");
foreach (ConstructorInfo cf in info)
{
Console.WriteLine(cf);
}

Console.WriteLine();
// get all the methods
Console.WriteLine("Methods:");
foreach (MethodInfo mf in methods)
{
Console.WriteLine(mf);
}

MethodInfo info2 = objectType.GetMethod("print");
Console.WriteLine("Calling print:\n");
object[] parms = new object[1];
parms[0] = "d";
info2.Invoke(testObject, null);


Console.WriteLine("Testing Late Binding:\n");
Assembly a = Assembly.Load("TestLateBinding");
Console.WriteLine("Types in TestLateBinding assembly:\n");
foreach (Type t in a.GetTypes())
{
Console.WriteLine(t.Name);
if (t.Name.Equals("TestClass"))
{
MethodInfo info5 = t.GetMethod("OnlyMethod", BindingFlags.NonPublic | BindingFlags.Instance);

Object o = Activator.CreateInstance(t);
info5.Invoke(o, null);
}
}
Console.ReadLine();
}
}
}

Now in order for us to continue, you will have to build and then copy the TestLateBinding.dll from the TestLateBinding Debug Folder into the Debug folder of the console app, so we can access the members from the dll during runtime, without using compile time knowledge of the code in the library, in essence, without doing a reference to the library.

OK, so now to the code, in order for us to use reflection, we need the
using System.Reflection; reference.
So in these two lines:
TestDataType testObject = new TestDataType();
Type objectType = testObject.GetType();
I declare a new object of type TestDataType and then I use the objects, GetType method to assign it to the object objectType of type Type.
I know this is a silly example, but you can see how it would be helpful, if you were able to access methods, constructors and other information at runtime, so this is what I am trying to show here.
The next two lines get all constructors and all methods from the object using reflection:

ConstructorInfo[] info = objectType.GetConstructors();
MethodInfo[] methods = objectType.GetMethods();

I then print them out to the console. And I am also getting the method information for a particular method, in this case, print:

MethodInfo info2 = objectType.GetMethod("print");

In this case, the method does not accept any parameters, so I am just calling it:

info2.Invoke(testObject, null); However, if it required parameters, I could have done it so:
object[] parms = new object[1];
parms[0] = "d";
info2.Invoke(testObject, parms);
Note the above is actually quite silly, but it addresses the point that I am trying to make.

Next we can call an external assembly by using the Load method from the Assembly class:

Assembly a = Assembly.Load("TestLateBinding");

where "TestLateBinding" is the name of the assembly(our dll)

Then I am getting all types in the assembly and calling a private method from within the class:

foreach (Type t in a.GetTypes())
{
Console.WriteLine(t.Name);
if (t.Name.Equals("TestClass"))
{
MethodInfo info5 = t.GetMethod("OnlyMethod", BindingFlags.NonPublic | BindingFlags.Instance);

Object o = Activator.CreateInstance(t);
info5.Invoke(o, null);
}
}
Note the use of BindingFlags.NonPublic | BindingFlags.Instance, without those flags, the private method will not be reflected, I don;t know why, don't ask me.
If the method is public, you will not need to pass any flags.

I hope this helped

Developer Tools

http://www.windevpowertools.com/ToolList/Tag/Chapter%2013

Friday, October 05, 2007

SAMBA setup

yum install samba system-config-samba samba-client samba-common samba-swat smbldap-tools

SAMBA config file:

# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options (perhaps too
# many!) most of which are not shown in this example
#
# For a step to step guide on installing, configuring and using samba,
# read the Samba-HOWTO-Collection. This may be obtained from:
# http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# Many working examples of smb.conf files can be found in the
# Samba-Guide which is generated daily and can be downloaded from:
# http://www.samba.org/samba/docs/Samba-Guide.pdf
#
# Any line which starts with a ; (semi-colon) or a # (hash)
# is a comment and is ignored. In this example we will use a #
# for commentry and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command "testparm"
# to check that you have not made any basic syntactic errors.
#
#======================= Global Settings =====================================
[global]

# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
workgroup = SAFE

# server string is the equivalent of the NT Description field
server string = DigiData Digital SAFE

# Security mode. Defines in which mode Samba will operate. Possible
# values are share, user, server, domain and ads. Most people will want
# user level security. See the Samba-HOWTO-Collection for details.
security = share

# This option is important for security. It allows you to restrict
# connections to machines which are on your local network. The
# following example restricts access to two C class networks and
# the "loopback" interface. For more examples of the syntax see
# the smb.conf man page
; hosts allow = 192.168.1. 192.168.2. 127.

# Uncomment this if you want a guest account, you must add this to /etc/passwd
# otherwise the user "nobody" is used
; guest account = pcguest

# this tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/%m.log

# Put a capping on the size of the log files (in Kb).
max log size = 50

# Use password server option only with security = server
# The argument list may include:
# password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]
# or to auto-locate the domain controller/s
# password server = *
; password server =

# Use the realm option only with security = ads
# Specifies the Active Directory realm the host is part of
; realm = MY_REALM

# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
; passdb backend = tdbsam

# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting.
# Note: Consider carefully the location in the configuration file of
# this line. The included file is read at that point.
; include = /usr/local/samba/lib/smb.conf.%m

# Configure Samba to use multiple interfaces
# If you have multiple network interfaces then you must list them
# here. See the man page for details.
; interfaces = 192.168.12.2/24 192.168.13.2/24

# Browser Control Options:
# set local master to no if you don't want Samba to become a master
# browser on your network. Otherwise the normal election rules apply
; local master = no

# OS Level determines the precedence of this server in master browser
# elections. The default value should be reasonable
; os level = 33

# Domain Master specifies Samba to be the Domain Master Browser. This
# allows Samba to collate browse lists between subnets. Don't use this
# if you already have a Windows NT domain controller doing this job
; domain master = yes

# Preferred Master causes Samba to force a local browser election on startup
# and gives it a slightly higher chance of winning the election
; preferred master = yes

# Enable this if you want Samba to be a domain logon server for
# Windows95 workstations.
; domain logons = yes

# if you enable domain logons then you may want a per-machine or
# per user logon script
# run a specific logon batch file per workstation (machine)
; logon script = %m.bat
# run a specific logon batch file per username
; logon script = %U.bat

# Where to store roving profiles (only for Win95 and WinNT)
# %L substitutes for this servers netbios name, %U is username
# You must uncomment the [Profiles] share below
; logon path = \\%L\Profiles\%U

# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server
; wins support = yes

# WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
; wins server = w.x.y.z

# WINS Proxy - Tells Samba to answer name resolution queries on
# behalf of a non WINS capable client, for this to work there must be
# at least one WINS Server on the network. The default is NO.
; wins proxy = yes

# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups. The default is NO.
dns proxy = no

# These scripts are used on a domain controller or stand-alone
# machine to add or delete corresponding unix accounts
; add user script = /usr/sbin/useradd %u
; add group script = /usr/sbin/groupadd %g
; add machine script = /usr/sbin/adduser -n -g machines -c Machine -d /dev/null -s /bin/false %u
; delete user script = /usr/sbin/userdel %u
; delete user from group script = /usr/sbin/deluser %u %g
; delete group script = /usr/sbin/groupdel %g


#============================ Share Definitions ==============================
[homes]
comment = Home Directories
browseable = no
writable = yes

# Un-comment the following and create the netlogon directory for Domain Logons
; [netlogon]
; comment = Network Logon Service
; path = /usr/local/samba/lib/netlogon
; guest ok = yes
; writable = no
; share modes = no


# Un-comment the following to provide a specific roving profile share
# the default is to use the user's home directory
;[Profiles]
; path = /usr/local/samba/profiles
; browseable = no
; guest ok = yes

# This one is useful for people to share files
;[tmp]
; comment = Temporary file space
; path = /tmp
; read only = no
; public = yes

# A publicly accessible directory, but read only, except for people in
# the "staff" group
;[public]
; comment = Public Stuff
; path = /home/samba
; public = yes
; writable = yes
; printable = no
; write list = @staff

# Other examples.
#
# A private directory, usable only by fred. Note that fred requires write
# access to the directory.
;[fredsdir]
; comment = Fred's Service
; path = /usr/somewhere/private
; valid users = fred
; public = no
; writable = yes
; printable = no

# a service which has a different directory for each machine that connects
# this allows you to tailor configurations to incoming machines. You could
# also use the %U option to tailor it by user name.
# The %m gets replaced with the machine name that is connecting.
;[pchome]
; comment = PC Directories
; path = /usr/pc/%m
; public = no
; writable = yes

[public]
comment = Your Sync Zone
path = /safe/sync
public = yes
only guest = yes
writable = yes

[www]
comment = Web Root
path = /var/www/html
public = yes
writable = yes
create mask = 0775

# The following two entries demonstrate how to share a directory so that two
# users can place files there that will be owned by the specific users. In this
# setup, the directory should be writable by both users and should have the
# sticky bit set on it to prevent abuse. Obviously this could be extended to
# as many users as required.
;[myshare]
; comment = Mary's and Fred's stuff
; path = /usr/somewhere/shared
; valid users = mary fred
; public = no
; writable = yes
; printable = no
; create mask = 0765



make sure Linux SE allows samba to write:
setsebool -P smbd_disable_trans 1

also make sure that file system permissions allow write access

Also make sure that we have the firewall allowing samba :
run /usr/sbin/system-config-security-level-tui to open up the port for swat (901)

Other tips:
restaring samba:
/etc/init.d/smb restart
Also, it is a good idea to check for open ports in /etc/services:
netbios-ns 137/tcp # NETBIOS Name Service
netbios-ns 137/udp
netbios-dgm 138/tcp # NETBIOS Datagram Service
netbios-dgm 138/udp
netbios-ssn 139/tcp # NETBIOS session service
netbios-ssn 139/udp

and 445 add the lines if they are missing

Also, we need to add users to samba(these need to also be available as linux users)
smbpasswd -a
Now, you should be able to access the share (make sure you login under the correct name in windows)

Things SQL

http://mashable.com/2007/10/03/sql-toolbox/

Thursday, October 04, 2007

Command to start SVN as service on windows

sc create svnserve binpath= "\"C:\Program Files\Subversion\bin\svnserve.exe\" --service -r \"C:\projects\svn"" displayname= "Subversion Server" depend= Tcpip start= auto

Subversion Global Ignore Pattern

I always forget this, so I am putting it here to have a record of it;

*/bin */obj *.bak *.*scc *.user *.suo *.webinfo bin
obj *.dll *.pdb*.exe