From: Gareth <gar...@gm...> - 2009-02-28 16:09:10
|
How about this method for initializing the process name, I don't know if a static field / property / method in FbConnectionInternal is unfavourable or not. This should work as there is only one process. The "processName" field will be initialized when required and will not need to be initialized for the life of the process. In BuildDpb dpb.Append(IscCodes.isc_dpb_process_name, ProcessName); static string processName; private static string ProcessName { get { return processName ?? (processName = GetProcessName()); } } private static string GetProcessName() { #if (NET_CF) // for CF we can implement GetModuleFileName from coredll #else try { return Process.GetCurrentProcess().MainModule.FileName; } catch(System.ComponentModel.Win32Exception) { try { return AppDomain.CurrentDomain.FriendlyName; } catch { } } #endif return String.Empty; } -- Gareth |
From: Jiri C. <di...@ci...> - 2009-02-28 16:43:33
|
First, I don't wanna to catch there exception, it's too slow. Let user to modify it in connection string isn't good idea, it's used for process identification, not for custom stuff - even Firebird tools are not allowing to modify it. On the other hand, I was thinking about, instead of showing stricly process name - which is for ASP.NET almost useless, we may show the path to current application. This may be helpful to see what site is having what connection. The only problem is, how to detect this in advance. I haven't looked to it deeply yet, but maybe there's a way to detect ASP.NET environment easily. What do you think? -- Jiri {x2} Cincura (CTO x2develop.com) http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com |
From: Gareth <gar...@gm...> - 2009-03-04 06:00:58
|
The processName field is static so it only needs to be initialized once per application domain, during the first connection. The GetProcessName() method is static to allow access to the static processName field. Inside GetProcessName() we check if the processName field is initialized or not, if not we do the try/catch otherwise we just return the processName field (no try/catch at every new connection, only the first one). I do not know enough about asp.net of compact framework to handle those parts. private DatabaseParameterBuffer BuildDpb(IDatabase db, FbConnectionString options) { ...... dpb.Append(IscCodes.isc_dpb_process_name, GetProcessName()); return dpb; } static string processName; #if (NET_CF) // for CF we can implement GetModuleFileName from coredll private static string GetProcessName() { if (processName == null) { try { StringBuilder path = new StringBuilder(1024); if(GetModuleFileName(IntPtr.Zero, path, path.Capacity) > 0) { processName = path.ToString(); return processName; } } catch{} processName = String.Empty; } return processName; } #else private static string GetProcessName() { if (processName == null) { try { try { processName = Process.GetCurrentProcess().MainModule.FileName; return processName; } catch{} try { processName = AppDomain.CurrentDomain.BaseDirectory + "-" + AppDomain.CurrentDomain.FriendlyName; return processName; } catch{} } catch{} processName = String.Empty; } return processName; } #endif On Sat, Feb 28, 2009 at 6:43 PM, Jiri Cincura <di...@ci...> wrote: > First, I don't wanna to catch there exception, it's too slow. Let user > to modify it in connection string isn't good idea, it's used for > process identification, not for custom stuff - even Firebird tools are > not allowing to modify it. > > On the other hand, I was thinking about, instead of showing stricly > process name - which is for ASP.NET almost useless, we may show the > path to current application. This may be helpful to see what site is > having what connection. > > The only problem is, how to detect this in advance. I haven't looked > to it deeply yet, but maybe there's a way to detect ASP.NET > environment easily. > > What do you think? > > -- > Jiri {x2} Cincura (CTO x2develop.com) > http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Firebird-net-provider mailing list > Fir...@li... > https://lists.sourceforge.net/lists/listinfo/firebird-net-provider > -- Gareth |
From: Jiri C. <di...@ci...> - 2009-03-13 10:20:39
|
On Wed, Mar 4, 2009 at 07:00, Gareth <gar...@gm...> wrote: > The processName field is static so it only needs to be initialized > once per application domain, during the first connection. > The GetProcessName() method is static to allow access to the static > processName field. > Inside GetProcessName() we check if the processName field is > initialized or not, if not we do the try/catch otherwise we just > return the processName field (no try/catch at every new connection, > only the first one). Well, there are two problems. First you're using exceptions to guess, that's running under ASP.NET. But that's not 100% correct. There may be different reasons for exception (you're not even checking whether it's security problem). The other one is that your catch blocks are empty. If there will be exception like OutOfMemoryException, your code will continue and developer/user will not notice this, and that's really bad. I think, only good way is to detect runnning on restricted trust and then ASP.NET env. to put there i.e. URL. -- Jiri {x2} Cincura (CTO x2develop.com) http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com |
From: Jiri C. <di...@ci...> - 2009-03-21 11:40:34
|
Hi, I've found how to check whether we're running in ASP.NET. Can you please check weekly build and try to run it? I think still some props will not be accessible in a not full trust env. Hence we'll need to do there couple of more tweaks. -- Jiri {x2} Cincura (CTO x2develop.com) http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com |
From: Jiri C. <di...@ci...> - 2009-03-22 10:38:34
|
Hi, I've found just one small problem. :) If I'm going to show path for ASP.NET apps. this may be wrong, because of connection pooling. I don't know whether it's acceptable or we have to find another solution (probably showing hardcoded string). What do you think? -- Jiri {x2} Cincura (CTO x2develop.com) http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com |
From: Gareth <gar...@gm...> - 2009-04-08 17:21:17
|
I will try to test this on 2003 server under IIS next week, 15/04/2009. This looks like it will fix my issue under IIS, thanks. I personally like the static field and single initialization, If you are creating many connections in a single application only the first connection needs to initialize the process name. On Sun, Mar 22, 2009 at 12:38 PM, Jiri Cincura <di...@ci...> wrote: > Hi, I've found just one small problem. :) If I'm going to show path > for ASP.NET apps. this may be wrong, because of connection pooling. I > don't know whether it's acceptable or we have to find another solution > (probably showing hardcoded string). > > What do you think? > > -- > Jiri {x2} Cincura (CTO x2develop.com) > http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com > > ------------------------------------------------------------------------------ > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > Firebird-net-provider mailing list > Fir...@li... > https://lists.sourceforge.net/lists/listinfo/firebird-net-provider > -- Gareth |
From: Gareth <gar...@gm...> - 2009-04-15 20:02:06
|
Works well, I changed it to add the site name in, this seems more informational to me. "return System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + System.Web.Hosting.HostingEnvironment.SiteName;" I don't think that connection pooling will affect the path. If one site has 10 open connections they will all show the same path and site name, this is the same as a single application which has 10 connections to the same database, the path and application name will be the same as well. The main thing here is that it works and does not throw an exception (For websites this is better, with the old method (MainModule.FileName) when running under IIS you would get the IIS process for all connections over all sites). On Wed, Apr 8, 2009 at 7:21 PM, Gareth <gar...@gm...> wrote: > I will try to test this on 2003 server under IIS next week, 15/04/2009. > > > On Sun, Mar 22, 2009 at 12:38 PM, Jiri Cincura <di...@ci...> wrote: >> Hi, I've found just one small problem. :) If I'm going to show path >> for ASP.NET apps. this may be wrong, because of connection pooling. I >> don't know whether it's acceptable or we have to find another solution >> (probably showing hardcoded string). >> >> What do you think? >> >> -- >> Jiri {x2} Cincura (CTO x2develop.com) >> http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com >> >> ------------------------------------------------------------------------------ >> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are >> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and >> easily build your RIAs with Flex Builder, the Eclipse(TM)based development >> software that enables intelligent coding and step-through debugging. >> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com >> _______________________________________________ >> Firebird-net-provider mailing list >> Fir...@li... >> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider >> > > -- > Gareth > -- Gareth |
From: Jiri C. <di...@ci...> - 2009-04-18 13:01:11
|
On Wed, Apr 15, 2009 at 22:01, Gareth <gar...@gm...> wrote: > I don't think that connection pooling will affect the path. If one > site has 10 open connections they will all show the same path and site > name, this is the same as a single application which has 10 > connections to the same database, the path and application name will > be the same as well. If one ASP.NET worker process is serving two applications, you'll see path for the first one to connect as the worker process is the one to load the assembly and has no idea what application is accessing the pool. At least I think so, didn't tested. But that's probably the limitation of it, similar as static fields and thread safety. -- Jiri {x2} Cincura (CTO x2develop.com) http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com |
From: Gareth <gar...@gm...> - 2009-04-27 07:46:03
|
I don't think that the worker process would use the same library for two different applications. What if your ClientLibrary.dll is named the same but differs by version number, the worker process would be expected to load both versions, one for each web application. Even if the same ClientLibrary.dll is loaded for two web applications, the ApplicationDomain should differ, therefore there would be 2 versions of static data available. Anyway, I will try to test this theory within the next two weeks. On Sat, Apr 18, 2009 at 3:01 PM, Jiri Cincura <di...@ci...> wrote: > On Wed, Apr 15, 2009 at 22:01, Gareth <gar...@gm...> wrote: >> I don't think that connection pooling will affect the path. If one >> site has 10 open connections they will all show the same path and site >> name, this is the same as a single application which has 10 >> connections to the same database, the path and application name will >> be the same as well. > > If one ASP.NET worker process is serving two applications, you'll see > path for the first one to connect as the worker process is the one to > load the assembly and has no idea what application is accessing the > pool. At least I think so, didn't tested. > > But that's probably the limitation of it, similar as static fields and > thread safety. > > -- > Jiri {x2} Cincura (CTO x2develop.com) > http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com > > ------------------------------------------------------------------------------ > Stay on top of everything new and different, both inside and > around Java (TM) technology - register by April 22, and save > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > 300 plus technical and hands-on sessions. Register today. > Use priority code J9JMT32. http://p.sf.net/sfu/p > _______________________________________________ > Firebird-net-provider mailing list > Fir...@li... > https://lists.sourceforge.net/lists/listinfo/firebird-net-provider > -- Gareth |
From: Jiri C. <di...@ci...> - 2009-05-03 09:49:35
|
On Mon, Apr 27, 2009 at 09:45, Gareth <gar...@gm...> wrote: > I will try to test this theory within the next two weeks. Let us know about results. -- Jiri {x2} Cincura (CTO x2develop.com) http://blog.vyvojar.cz/jirka/ | http://www.ID3renamer.com |