Refactored C# attachment setup.