![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | C# Create Global values in DLL? I have a C# DLL project I have created. The DLL plugs into other C#.NET applications. This DLL has several classes and methods comprised for 4 namespaces that are used by other programmer to perform common tasks. The settings for this DLL are contained within a SQL a database for easy modification. The issue I am having is the number of times the DLL has to make connections to the database to retrieve the settings information because the call is in a different class or namespace from the previous call. Ive have tried whenever possible to get the settings information at the class level rather then the method level so that all methods in the class can use the same values. However, because these classes are also used by other methods WITHIN the same DLL, the number of times needed to retrieve information from SQL continues to grow. Is there any type of Global access in DLL project that would allow be to load information one time and have its values accessible to any namespace or class in the project? -- JP ..NET Software Developer |
My System Specs![]() |
| | #2 (permalink) |
| | Re: C# Create Global values in DLL? You might want to look at: New! StockTrader 2.02 with Configuration Service Source Code http://msdn.microsoft.com/en-us/netf.../bb499684.aspx Greg wrote a "mini configuration framework" piece. Its NOT super trivial. Are the settings COMPILED into the dll? Or is the dll a wrapper to read settings from the database? (and subject to change within the db)? Can you fill in a few areas of your description of what you're doing now. "JP" <JP@xxxxxx> wrote in message news:4CE8B7DC-A508-4565-8C39-BBDCEA4771B6@xxxxxx Quote: >I have a C# DLL project I have created. The DLL plugs into other C#.NET > applications. This DLL has several classes and methods comprised for 4 > namespaces that are used by other programmer to perform common tasks. > > The settings for this DLL are contained within a SQL a database for easy > modification. The issue I am having is the number of times the DLL has to > make connections to the database to retrieve the settings information > because > the call is in a different class or namespace from the previous call. > > Ive have tried whenever possible to get the settings information at the > class level rather then the method level so that all methods in the class > can > use the same values. However, because these classes are also used by other > methods WITHIN the same DLL, the number of times needed to retrieve > information from SQL continues to grow. > > Is there any type of Global access in DLL project that would allow be to > load information one time and have its values accessible to any namespace > or > class in the project? > > -- > JP > .NET Software Developer |
My System Specs![]() |
| | #3 (permalink) |
| | Re: C# Create Global values in DLL? The setting file was originally compiled as an Embedded Resource XML document in the project, but the need to change settings without redistributing the DLL arose and now the settings are contained in a SQL table (about 40 values loaded into a string array). If it was simply loading the embedded XML document every time I wouldn’t be nearly as concerned as I am about making repetitive connections to SQL to get the information. Say for example a programmer request the use of a method in the DLL. This method will then access the DLLs database to pull some information it might need. For simplistic sake lets say this method is contained within the [Utility.Token] namespace. During the process of this method, an error occurs. This triggers the stack trace to get handed off to another method in the SAME DLL but a different namespace [Utility.Errors]. Because all the setting information is not retained across classes or namespaces, I have to connect to SQL again to reload the information to process the error that occurred. Now I potentially have two open database connections (depending on when I disposed of the first) for information I’ve already loaded once. I had pondered passing the string array with the settings from method to method, however, because these methods are used both externally by other programmers and internally by other classes in the DLL, the programmer in particular would have no idea how to get (or what) the string[] is. If I could load an array once when the DLL is loaded (something similar to Application_Start() (but for a DLL) then I could load a string array and have it be visible to all objects in the DLL regardless of namespace or class that’s trying to use it. Hope this makes since -- JP ..NET Software Developer "sloan" wrote: Quote: > You might want to look at: > New! StockTrader 2.02 with Configuration Service Source Code > > http://msdn.microsoft.com/en-us/netf.../bb499684.aspx > > Greg wrote a "mini configuration framework" piece. > Its NOT super trivial. > > > Are the settings COMPILED into the dll? Or is the dll a wrapper to read > settings from the database? (and subject to change within the db)? > > Can you fill in a few areas of your description of what you're doing now. > > > > > "JP" <JP@xxxxxx> wrote in message > news:4CE8B7DC-A508-4565-8C39-BBDCEA4771B6@xxxxxx Quote: > >I have a C# DLL project I have created. The DLL plugs into other C#.NET > > applications. This DLL has several classes and methods comprised for 4 > > namespaces that are used by other programmer to perform common tasks. > > > > The settings for this DLL are contained within a SQL a database for easy > > modification. The issue I am having is the number of times the DLL has to > > make connections to the database to retrieve the settings information > > because > > the call is in a different class or namespace from the previous call. > > > > Ive have tried whenever possible to get the settings information at the > > class level rather then the method level so that all methods in the class > > can > > use the same values. However, because these classes are also used by other > > methods WITHIN the same DLL, the number of times needed to retrieve > > information from SQL continues to grow. > > > > Is there any type of Global access in DLL project that would allow be to > > load information one time and have its values accessible to any namespace > > or > > class in the project? > > > > -- > > JP > > .NET Software Developer > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: C# Create Global values in DLL? "JP" <JP@xxxxxx> wrote in message news:4CE8B7DC-A508-4565-8C39-BBDCEA4771B6@xxxxxx Quote: > I have a C# DLL project I have created. The DLL plugs into other C#.NET > applications. This DLL has several classes and methods comprised for 4 > namespaces that are used by other programmer to perform common tasks. > > The settings for this DLL are contained within a SQL a database for easy > modification. The issue I am having is the number of times the DLL has to > make connections to the database to retrieve the settings information > because > the call is in a different class or namespace from the previous call. > > Ive have tried whenever possible to get the settings information at the > class level rather then the method level so that all methods in the class > can > use the same values. However, because these classes are also used by other > methods WITHIN the same DLL, the number of times needed to retrieve > information from SQL continues to grow. > > Is there any type of Global access in DLL project that would allow be to > load information one time and have its values accessible to any namespace > or > class in the project? Why does the settings info have to be retrieved from a database every time one of your methods is used? Can't your classes just retrieve the settings once and cache them, or is the info different every time? If all the classes use the same settings data, can you wrap the settings in a class so all your other classes can access the info from a common point? You could probably use a static class if there's only one set of setttings. Mark -- Mark Salsbery Microsoft MVP - Visual C++ Quote: > > -- > JP > .NET Software Developer |
My System Specs![]() |
| | #5 (permalink) |
| | Re: C# Create Global values in DLL? The settings need to be updated from time to time without the need of reposting or re-distributing the DLL to the people that are using it. In addition, we don’t want to create an external file for the settings that would have to be distributed with the DLL. I need a way of getting the settings to persist across all classes and namespaces in a given instance of the DLL. As it stands now, anytime I reference another class in the same instance of the DLL, I have to reload the settings. Since CLASS B cant see what CLASS A was already doing. -- JP ..NET Software Developer "Mark Salsbery [MVP]" wrote: Quote: > "JP" <JP@xxxxxx> wrote in message > news:4CE8B7DC-A508-4565-8C39-BBDCEA4771B6@xxxxxx Quote: > > I have a C# DLL project I have created. The DLL plugs into other C#.NET > > applications. This DLL has several classes and methods comprised for 4 > > namespaces that are used by other programmer to perform common tasks. > > > > The settings for this DLL are contained within a SQL a database for easy > > modification. The issue I am having is the number of times the DLL has to > > make connections to the database to retrieve the settings information > > because > > the call is in a different class or namespace from the previous call. > > > > Ive have tried whenever possible to get the settings information at the > > class level rather then the method level so that all methods in the class > > can > > use the same values. However, because these classes are also used by other > > methods WITHIN the same DLL, the number of times needed to retrieve > > information from SQL continues to grow. > > > > Is there any type of Global access in DLL project that would allow be to > > load information one time and have its values accessible to any namespace > > or > > class in the project? > > Why does the settings info have to be retrieved from a database every time > one of your methods is used? > Can't your classes just retrieve the settings once and cache them, or is the > info different every time? > > If all the classes use the same settings data, can you wrap the settings in > a class so all your other classes can access the info from a common point? > You could probably use a static class if there's only one set of setttings. > > Mark > > -- > Mark Salsbery > Microsoft MVP - Visual C++ > > Quote: > > > > -- > > JP > > .NET Software Developer > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Set/Create Registry Values | PowerShell | |||
| Modify Create Global Objects | PowerShell | |||
| how to assign values to array and how to create array via variable | PowerShell | |||
| How To: Create Global Variables within a function or Script | PowerShell | |||
| Can't create uint32 values outside int32 range? | PowerShell | |||