tags:

views:

40

answers:

1

I'm trying to create a WsHttpBinding entirely in code, within an SSIS Script Task.

The script task will not have access to an app.config file at run time so I need to create the binding manually and set the parameters in code:

WSHttpBinding binding = 
        new WSHttpBinding{ 
            Security = new WSHttpSecurity{ 
                Mode= SecurityMode.TransportWithMessageCredential,
                Message = new NonDualMessageSecurityOverHttp{
                    ClientCredentialType = MessageCredentialType.UserName,
                }
            }
        };

This compiles fine and is usable under .Net 4, however SSIS Script Task can only use Net 3.5 as its target runtime.

When trying to compile this code, I get several compiler errors stating that some of the properties above are in accessible due to their protection level.

There is obviously a fundamental change between 3.5 and 4 that allows this under 4 but not 3.5.

Can anyone offer a workaround to achieve the above in 3.5?

+1  A: 

There has been no change between .NET 3.5 and 4.0 in how properties behave.

What has changed is the accessbility of the constructors and properties that you are trying to access. In .NET 4.0, the properties and constructors that were not accessible in .NET 3.5 have been made accessible.

As for how to access the configuration settings, you should be able to place the configuration settings in the config file for the process that launches your script. It's a little hokey (as it will apply for all scripts), but you should be able to do it.

You can read about the config files you will need to change and where to find them here:

http://www.developerit.com/2010/04/12/where-is-my-app-config-for-ssis

casperOne
Yeah I read that article before I tried to hard code it, I wanted to see if I could make the package more portable by defining the binding in the script code instead of relying on the config file, looks like it might be my option now any way! Thanks for your answer.
James