Prev: VB.NET and sql server
Next: contextmenu
From: Michel Posseth [MCP] on 7 Mar 2010 04:08 Actually i created something for that ,, let me switch to my dev computer ( be back in a moment ) Michel "Mr. Arnold" <Arnold(a)Arnold.com> schreef in bericht news:%234G$gOavKHA.5340(a)TK2MSFTNGP04.phx.gbl... > Nathan Sokalski wrote: >> I did notice the app.config file in the Class Library, but when I moved >> the registration from the Web Application's Web.config to the Class >> Library's app.config, it didn't seem to do anything. Is there anything >> that needs to be different in any way when the registration is in >> app.config? Thanks. > > The Web.config is the root of all configs and the app.config is going to > be ignored by the Web application. > > You should make a Console project and add the classlib project to the > solution and try the app.config there.
From: Michel Posseth on 7 Mar 2010 05:11 Op 7-3-2010 10:08, Michel Posseth [MCP] schreef: > Actually i created something for that ,, let me switch to my dev > computer ( be back in a moment ) > > Michel > > > > "Mr. Arnold" <Arnold(a)Arnold.com> schreef in bericht > news:%234G$gOavKHA.5340(a)TK2MSFTNGP04.phx.gbl... >> Nathan Sokalski wrote: >>> I did notice the app.config file in the Class Library, but when I >>> moved the registration from the Web Application's Web.config to the >>> Class Library's app.config, it didn't seem to do anything. Is there >>> anything that needs to be different in any way when the registration >>> is in app.config? Thanks. >> >> The Web.config is the root of all configs and the app.config is going >> to be ignored by the Web application. >> >> You should make a Console project and add the classlib project to the >> solution and try the app.config there. > and here it is : Imports System.Configuration Imports System.Web.Configuration Namespace My Partial Friend NotInheritable Class MySettings Private DllSettings As ClientSettingsSection Private DllConfigDoesNotExist As Boolean Default Public Overrides Property Item(ByVal propertyName As String) As Object Get Dim oValue As Object = Nothing Try If RunsOnWeb() Then ' do we have the value in the web config Dim ret As String = Nothing Try ret = WebConfigurationManager.AppSettings(propertyName) Catch ex As Exception End Try If String.IsNullOrEmpty(ret) Then Try oValue = WebConfigurationManager.ConnectionStrings(propertyName).ConnectionString Catch ex As Exception End Try End If Else 'If the .dll.config file has already been loaded, use it to obtain the value... If DllSettings IsNot Nothing Then oValue = DllSettings.Settings.Get(propertyName).Value.ValueXml.InnerXml ElseIf Not DllConfigDoesNotExist Then If Me.LoadDllConfigFile() Then oValue = DllSettings.Settings.Get(propertyName).Value.ValueXml.InnerXml End If End If End If Catch ex As Exception End Try Try If oValue Is Nothing Then oValue = MyBase.Item(propertyName) End If Catch ex As Exception End Try Return oValue End Get Set(ByVal value As Object) MyBase.Item(propertyName) = value End Set End Property Public Function RunsOnWeb() As Boolean Dim strPN As String = System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToLower Return (strPN = "w3wp" OrElse strPN = "aspnet_wp") End Function Private Function LoadDllConfigFile() As Boolean Dim bDllConfigLoaded As Boolean = False Dim cfgDll As System.Configuration.Configuration Dim cfmDllCfg As New ExeConfigurationFileMap() Dim sAssemblyPath As String = Reflection.Assembly.GetExecutingAssembly().Location Dim strNamespace As String = GetType(MySettings).FullName strNamespace = strNamespace.Substring(0, strNamespace.IndexOf("."c)) cfmDllCfg.ExeConfigFilename = sAssemblyPath & ".config" Try cfgDll = ConfigurationManager.OpenMappedExeConfiguration(cfmDllCfg, ConfigurationUserLevel.None) Dim csgApplicationSettings As ConfigurationSectionGroup = cfgDll.GetSectionGroup("applicationSettings") Me.DllSettings = DirectCast(csgApplicationSettings.Sections(strNamespace & ".My.MySettings"), ClientSettingsSection) bDllConfigLoaded = True Catch ex As Exception 'bestaat niet DllConfigDoesNotExist = True End Try Return bDllConfigLoaded End Function End Class End Namespace
From: Nathan Sokalski on 7 Mar 2010 12:45 I probably made a bad choice of words there. What I meant was I want people to be able to add the *.dll to their web application and use the handler without needing to register it in their Web.config. The reason I created the handler is because it is used by one of the controls in my class library (it generates a *.gif image), so I need the handler to be available to the control at a known location (unless there is some alternative way for me to have the *.gif's generated and returned from a URL). Any ideas? -- Nathan Sokalski njsokalski(a)hotmail.com http://www.nathansokalski.com/ "Cor Ligthert[MVP]" <Notmyfirstname(a)planet.nl> wrote in message news:#IdiyUdvKHA.5940(a)TK2MSFTNGP02.phx.gbl... > A DLL in Net is a Class Library not something that is independent working. > > If you want the later you can use a service (or a webservice of WFC). > > Success > > Cor > > > "Nathan Sokalski" <njsokalski(a)hotmail.com> wrote in message > news:47168E65-BCFE-4795-9A7D-4C8934D0D464(a)microsoft.com... >> I have a Solution that contains a Web Application and a Class Library. >> The Class Library contains an HTTP Handler, which implements IHttpHandler >> and needs registered in the config file. I want the *.dll for the Class >> Library to be available and work independently of the Web Application. >> The handler works when I register the handler in the <httpHandlers> >> section of the Web.config file in the Web Application, but how can I >> register it using the Class Library? Thanks. >> -- >> Nathan Sokalski >> njsokalski(a)hotmail.com >> http://www.nathansokalski.com/ >
From: Ralph on 8 Mar 2010 14:56 "Nathan Sokalski" <njsokalski(a)hotmail.com> wrote in message news:CD8DA8CB-988C-4AFC-95F2-094624F3C4DD(a)microsoft.com... > I probably made a bad choice of words there. What I meant was I want > people to be able to add the *.dll to their web application and use the > handler without needing to register it in their Web.config. The reason I > created the handler is because it is used by one of the controls in my > class library (it generates a *.gif image), so I need the handler to be > available to the control at a known location (unless there is some > alternative way for me to have the *.gif's generated and returned from a > URL). Any ideas? > -- > Nathan Sokalski > njsokalski(a)hotmail.com > http://www.nathansokalski.com/ > > "Cor Ligthert[MVP]" <Notmyfirstname(a)planet.nl> wrote in message > news:#IdiyUdvKHA.5940(a)TK2MSFTNGP02.phx.gbl... >> A DLL in Net is a Class Library not something that is independent >> working. >> >> If you want the later you can use a service (or a webservice of WFC). >> >> Success >> >> Cor >> >> >> "Nathan Sokalski" <njsokalski(a)hotmail.com> wrote in message >> news:47168E65-BCFE-4795-9A7D-4C8934D0D464(a)microsoft.com... >>> I have a Solution that contains a Web Application and a Class Library. >>> The Class Library contains an HTTP Handler, which implements >>> IHttpHandler and needs registered in the config file. I want the *.dll >>> for the Class Library to be available and work independently of the Web >>> Application. The handler works when I register the handler in the >>> <httpHandlers> section of the Web.config file in the Web Application, >>> but how can I register it using the Class Library? Thanks. >>> -- >>> Nathan Sokalski >>> njsokalski(a)hotmail.com >>> http://www.nathansokalski.com/ >> Name your file .ashx and it should work without registering.
From: Ralph on 8 Mar 2010 15:01
"Ralph" <ralphd42(a)hotmail.com> wrote in message news:44002549-E9FA-48B4-B98E-A0EA9C279E65(a)microsoft.com... > "Nathan Sokalski" <njsokalski(a)hotmail.com> wrote in message > news:CD8DA8CB-988C-4AFC-95F2-094624F3C4DD(a)microsoft.com... >> I probably made a bad choice of words there. What I meant was I want >> people to be able to add the *.dll to their web application and use the >> handler without needing to register it in their Web.config. The reason I >> created the handler is because it is used by one of the controls in my >> class library (it generates a *.gif image), so I need the handler to be >> available to the control at a known location (unless there is some >> alternative way for me to have the *.gif's generated and returned from a >> URL). Any ideas? >> -- >> Nathan Sokalski >> njsokalski(a)hotmail.com >> http://www.nathansokalski.com/ >> >> "Cor Ligthert[MVP]" <Notmyfirstname(a)planet.nl> wrote in message >> news:#IdiyUdvKHA.5940(a)TK2MSFTNGP02.phx.gbl... >>> A DLL in Net is a Class Library not something that is independent >>> working. >>> >>> If you want the later you can use a service (or a webservice of WFC). >>> >>> Success >>> >>> Cor >>> >>> >>> "Nathan Sokalski" <njsokalski(a)hotmail.com> wrote in message >>> news:47168E65-BCFE-4795-9A7D-4C8934D0D464(a)microsoft.com... >>>> I have a Solution that contains a Web Application and a Class Library. >>>> The Class Library contains an HTTP Handler, which implements >>>> IHttpHandler and needs registered in the config file. I want the *.dll >>>> for the Class Library to be available and work independently of the Web >>>> Application. The handler works when I register the handler in the >>>> <httpHandlers> section of the Web.config file in the Web Application, >>>> but how can I register it using the Class Library? Thanks. >>>> -- >>>> Nathan Sokalski >>>> njsokalski(a)hotmail.com >>>> http://www.nathansokalski.com/ >>> > > > Name your file .ashx and it should work without registering. opps I met without having to add to web.config. |