>>No idea if this works but :
http://www.justskins.com/forums/programatically-register-soapextensions-77036.html>>But why do you want to do this?
>
>I have added the following in my Global class:
>
>
> Private Shared Sub InjectTraceExtensionToConfig()
> Dim assBase As Assembly
> Dim webServiceConfig As Type
> Dim currentProp As Object
> Dim propInfo As PropertyInfo
> Dim value As Object()
> Dim myType As Type
> Dim objArray As Object()
> Dim myObj As Object
> Dim myField As FieldInfo
>
> Try
> assBase = GetType(System.Web.Services.Protocols.SoapExtensionAttribute).Assembly
> webServiceConfig = assBase.[GetType]("System.Web.Services.Configuration.WebServicesCon figuration")
>
> If webServiceConfig Is Nothing Then
> Throw New Exception("Error ...")
> End If
>
> currentProp = webServiceConfig.GetProperty("Current").GetValue(Nothing, Nothing)
> propInfo = webServiceConfig.GetProperty("SoapExtensionTypes")
> value = DirectCast(propInfo.GetValue(currentProp, Nothing), Object())
> myType = value.[GetType]().GetElementType()
> objArray = DirectCast(Array.CreateInstance(myType, CInt(value.Length) + 1), Object())
> Array.Copy(value, objArray, CInt(value.Length))
>
> myObj = Activator.CreateInstance(myType)
> myField = myType.GetField("Type")
> myField.SetValue(myObj, GetType(TraceExtension))
> objArray(CInt(objArray.Length) - 1) = myObj
> propInfo.SetValue(currentProp, objArray, Nothing)
> Catch ex As Exception
> End Try
> End Sub
>
>
>The Global class is called from Global.asax:
>
>
>< @ Application Language="VB" Inherits="Framework.GlobalBase"%>
>
>
>But, as is, it will not do anything. Something has to trigger this method. This is where I am not sure about the proper way to establish a trigger here. When this is in the web.config. the trigger is done by .NET. But, in the code, there is a missing link here.
Maybe Application_Start() ?
>The reason I want to put this in the code is to have the control over it. Everything that most of the people usually put in Global.asax, I put it in my Global class. Then, from Global.asax, the only thing I have to put is the one line you see above. By that, I do not have to worry about setting up web.config wherever I need a Web site or Web service application. I control everything from the framework and that makes it easier to migrate to another development environment when time comes. This Global.asax is to proprietary to .NET.
Fair enough - but you could probably use the machine.config or the root web.config to do that.....
I'd favour web.config because you can change settings on the fly without re-publishing, use hierarchies, build different web.configs for release/debug versions etc. etc....