Prev: VB.NET and sql server
Next: contextmenu
From: Nathan Sokalski on 8 Mar 2010 15:16 I think that you are talking about a Generic Handler. I cannot use a Generic Handler or *.ashx file because I want everything to end up being part of my *.dll once I compile my Class Library. -- Nathan Sokalski njsokalski(a)hotmail.com http://www.nathansokalski.com/ "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. > > >
From: Ralph on 8 Mar 2010 15:56 "Nathan Sokalski" <njsokalski(a)hotmail.com> wrote in message news:BF3AF714-A1B0-40CC-B907-5776168D8710(a)microsoft.com... > I think that you are talking about a Generic Handler. I cannot use a > Generic Handler or *.ashx file because I want everything to end up being > part of my *.dll once I compile my Class Library. > -- > Nathan Sokalski > njsokalski(a)hotmail.com > http://www.nathansokalski.com/ Yes I referring to a Generic Handler. You can still put your class that implements IHttpHandler in your dll. I believe you would just need something similar to the following in an .ashx file <%@ WebHandler Language="C#" Class="YourHandler" %> So yes you would need one item outside of the .dll If the users of your handler have access to the bin files of their webs I would assume they have access to the other folders also. > > "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. >> >> >>
From: Nathan Sokalski on 8 Mar 2010 17:07 I understand that, and I would assume they do also. However, the philosophy I am going by here is convenience; I want to only need to give the user one file. Also, because I don't know what folders the user will have in their Web Application or which one they will put it in, I don't know where to tell the control that uses the handler to look for the *.ashx file. -- Nathan Sokalski njsokalski(a)hotmail.com http://www.nathansokalski.com/ "Ralph" <ralphd42(a)hotmail.com> wrote in message news:#ZZeZHwvKHA.4636(a)TK2MSFTNGP06.phx.gbl... > "Nathan Sokalski" <njsokalski(a)hotmail.com> wrote in message > news:BF3AF714-A1B0-40CC-B907-5776168D8710(a)microsoft.com... >> I think that you are talking about a Generic Handler. I cannot use a >> Generic Handler or *.ashx file because I want everything to end up being >> part of my *.dll once I compile my Class Library. >> -- >> Nathan Sokalski >> njsokalski(a)hotmail.com >> http://www.nathansokalski.com/ > > Yes I referring to a Generic Handler. > You can still put your class that implements IHttpHandler in your dll. > I believe you would just need something similar to the following in an > .ashx file > > <%@ WebHandler Language="C#" Class="YourHandler" %> > > So yes you would need one item outside of the .dll > If the users of your handler have access to the bin files of their webs I > would assume they have access to the other folders also. > > > > > > >> >> "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. >>> >>> >>>
From: Cubaman on 9 Mar 2010 11:57
On Mar 7, 11:11 am, Michel Posseth <N...(a)Vbdotnetcoder.com> wrote: > 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" <Arn...(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 Hello: Good code, just a point. To get if your dll is currently loaded in a web app is better tu use: HttpContext.Current != null Best regards, Oscar Acosta |