Search Results

Search found 26126 results on 1046 pages for 'generic service contract'.

Page 104/1046 | < Previous Page | 100 101 102 103 104 105 106 107 108 109 110 111  | Next Page >

  • Approaches for generic, compile-time safe lazy-load methods

    - by Aaronaught
    Suppose I have created a wrapper class like the following: public class Foo : IFoo { private readonly IFoo innerFoo; public Foo(IFoo innerFoo) { this.innerFoo = innerFoo; } public int? Bar { get; set; } public int? Baz { get; set; } } The idea here is that the innerFoo might wrap data-access methods or something similarly expensive, and I only want its GetBar and GetBaz methods to be invoked once. So I want to create another wrapper around it, which will save the values obtained on the first run. It's simple enough to do this, of course: int IFoo.GetBar() { if ((Bar == null) && (innerFoo != null)) Bar = innerFoo.GetBar(); return Bar ?? 0; } int IFoo.GetBaz() { if ((Baz == null) && (innerFoo != null)) Baz = innerFoo.GetBaz(); return Baz ?? 0; } But it gets pretty repetitive if I'm doing this with 10 different properties and 30 different wrappers. So I figured, hey, let's make this generic: T LazyLoad<T>(ref T prop, Func<IFoo, T> loader) { if ((prop == null) && (innerFoo != null)) prop = loader(innerFoo); return prop; } Which almost gets me where I want, but not quite, because you can't ref an auto-property (or any property at all). In other words, I can't write this: int IFoo.GetBar() { return LazyLoad(ref Bar, f => f.GetBar()); // <--- Won't compile } Instead, I'd have to change Bar to have an explicit backing field and write explicit getters and setters. Which is fine, except for the fact that I end up writing even more redundant code than I was writing in the first place. Then I considered the possibility of using expression trees: T LazyLoad<T>(Expression<Func<T>> propExpr, Func<IFoo, T> loader) { var memberExpression = propExpr.Body as MemberExpression; if (memberExpression != null) { // Use Reflection to inspect/set the property } } This plays nice with refactoring - it'll work great if I do this: return LazyLoad(f => f.Bar, f => f.GetBar()); But it's not actually safe, because someone less clever (i.e. myself in 3 days from now when I inevitably forget how this is implemented internally) could decide to write this instead: return LazyLoad(f => 3, f => f.GetBar()); Which is either going to crash or result in unexpected/undefined behaviour, depending on how defensively I write the LazyLoad method. So I don't really like this approach either, because it leads to the possibility of runtime errors which would have been prevented in the first attempt. It also relies on Reflection, which feels a little dirty here, even though this code is admittedly not performance-sensitive. Now I could also decide to go all-out and use DynamicProxy to do method interception and not have to write any code, and in fact I already do this in some applications. But this code is residing in a core library which many other assemblies depend on, and it seems horribly wrong to be introducing this kind of complexity at such a low level. Separating the interceptor-based implementation from the IFoo interface by putting it into its own assembly doesn't really help; the fact is that this very class is still going to be used all over the place, must be used, so this isn't one of those problems that could be trivially solved with a little DI magic. The last option I've already thought of would be to have a method like: T LazyLoad<T>(Func<T> getter, Action<T> setter, Func<IFoo, T> loader) { ... } This option is very "meh" as well - it avoids Reflection but is still error-prone, and it doesn't really reduce the repetition that much. It's almost as bad as having to write explicit getters and setters for each property. Maybe I'm just being incredibly nit-picky, but this application is still in its early stages, and it's going to grow substantially over time, and I really want to keep the code squeaky-clean. Bottom line: I'm at an impasse, looking for other ideas. Question: Is there any way to clean up the lazy-loading code at the top, such that the implementation will: Guarantee compile-time safety, like the ref version; Actually reduce the amount of code repetition, like the Expression version; and Not take on any significant additional dependencies? In other words, is there a way to do this just using regular C# language features and possibly a few small helper classes? Or am I just going to have to accept that there's a trade-off here and strike one of the above requirements from the list?

    Read the article

  • Embedding generic sql queries into c# program

    - by Pooja Balkundi
    Okay referring to my first question code in the main, I want the user to enter employee name at runtime and then i take this name which user has entered and compare it with the e_name of my emp table , if it exists i want to display all information of that employee , how can I achieve this ? using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using MySql.Data.MySqlClient; namespace ConnectCsharppToMySQL { public class DBConnect { private MySqlConnection connection; private string server; private string database; private string uid; private string password; string name; //Constructor public DBConnect() { Initialize(); } //Initialize values private void Initialize() { server = "localhost"; database = "test"; uid = "root"; password = ""; string connectionString; connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";"; connection = new MySqlConnection(connectionString); } //open connection to database private bool OpenConnection() { try { connection.Open(); return true; } catch (MySqlException ex) { //When handling errors, you can your application's response based //on the error number. //The two most common error numbers when connecting are as follows: //0: Cannot connect to server. //1045: Invalid user name and/or password. switch (ex.Number) { case 0: MessageBox.Show("Cannot connect to server. Contact administrator"); break; case 1045: MessageBox.Show("Invalid username/password, please try again"); break; } return false; } } //Close connection private bool CloseConnection() { try { connection.Close(); return true; } catch (MySqlException ex) { MessageBox.Show(ex.Message); return false; } } //Insert statement public void Insert() { string query = "INSERT INTO emp (e_name, age) VALUES('Pooja R', '21')"; //open connection if (this.OpenConnection() == true) { //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connection); //Execute command cmd.ExecuteNonQuery(); //close connection this.CloseConnection(); } } //Update statement public void Update() { string query = "UPDATE emp SET e_name='Peachy', age='22' WHERE e_name='Pooja R'"; //Open connection if (this.OpenConnection() == true) { //create mysql command MySqlCommand cmd = new MySqlCommand(); //Assign the query using CommandText cmd.CommandText = query; //Assign the connection using Connection cmd.Connection = connection; //Execute query cmd.ExecuteNonQuery(); //close connection this.CloseConnection(); } } //Select statement public List<string>[] Select() { string query = "SELECT * FROM emp where e_name=(/*I WANT USER ENTERED NAME TO GET INSERTED HERE*/)"; //Create a list to store the result List<string>[] list = new List<string>[3]; list[0] = new List<string>(); list[1] = new List<string>(); list[2] = new List<string>(); //Open connection if (this.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { list[0].Add(dataReader["e_id"] + ""); list[1].Add(dataReader["e_name"] + ""); list[2].Add(dataReader["age"] + ""); } //close Data Reader dataReader.Close(); //close Connection this.CloseConnection(); //return list to be displayed return list; } else { return list; } } public static void Main(String[] args) { DBConnect db1 = new DBConnect(); Console.WriteLine("Initializing"); db1.Initialize(); Console.WriteLine("Search :"); Console.WriteLine("Enter the employee name"); db1.name = Console.ReadLine(); db1.Select(); Console.ReadLine(); } } }

    Read the article

  • PostgreSQL service doesn't start on Windows 7

    - by Mehrdad
    (Not sure if this should be on Stack Overflow or Super User... please move if needed.) When I start the PostgreSQL service on Windows 7 x64, it immediately stops. When I check my log folder (C:\PostgreSQL\9.1\data\pg_log\), I see new but empty log files. The Event Viewer doesn't tell me anything other than the fact that the server did not respond. I've even tried turning off my firewall (I don't have any antivirus or anything else), but nothing helps. The setup works fine when I'm on Windows XP (32-bit) (same computer, different partition). I can't figure out what's wrong, even though I've tried tracing the system calls. Is PostgreSQL compatible with Windows 7 x64 at all? Any ideas what the issue might be? More info: This problem also happens at the end of installation -- the service starts, then stops immediately, before the installer can do anything. Installation log: Starting the database server... Executing cscript //NoLogo "C:\Program Files\PostgreSQL\9.1\installer\server\startserver.vbs" postgresql-x64-9.1 Script exit code: 0 Script output: Starting postgresql-x64-9.1 Service postgresql-x64-9.1 started successfully // <==== NOT REALLY!! It stops! startserver.vbs ran to completion Script stderr: Loading additional SQL modules... Executing cscript //NoLogo "C:\Program Files\PostgreSQL\9.1\installer\server\loadmodules.vbs" "postgres" "****" "C:\Program Files\PostgreSQL\9.1" "C:\Program Files\PostgreSQL\9.1\data" 5432 Script exit code: 2 Script output: Installing the adminpack module in the postgres database... Executing 'C:\Users\HOMEUS~1\AppData\Local\Temp\rad6C20D.bat'... psql: could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? Failed to install the 'adminpack' module in the 'postgres' database loadmodules.vbs ran to completion Script stderr: Program ended with an error exit code Error running cscript //NoLogo "C:\Program Files\PostgreSQL\9.1\installer\server\loadmodules.vbs" "postgres" "****" "C:\Program Files\PostgreSQL\9.1" "C:\Program Files\PostgreSQL\9.1\data" 5432 : Program ended with an error exit code

    Read the article

  • Email deliverability -- Whitelist solution or Email delivery service?

    - by JoefrshnJoeclean
    Hey Folks -- our company is encountering the same recurring problem - email deliverability. A lot of our emails are still getting trapped in yahoo and gmail spam filters. We followed yahoo's best practices guide as well as tips Ive found on serverfault. (setting up DKIM, SPF) And even took the Email Server Test (http://www.allaboutspam.com/email-server-test/) Now my question is: has anyone had success using whitelist solutions like goodmail or EmailReach? Alternatively, Im beginning to think that going with a email delivery service like Mailchimp will save me the headache and future stress of managing our email lists. So whitelist solution or just fork up the money and send via an email delivery service? Thanks!

    Read the article

  • EC2 hosted service multi-tenant dynamic DNS solution

    - by accidental admin
    I want to change the model of my EC2 hosted service to have a separate sub domain for each tenant (ie. .example.com). My primary DNS is now with dnsmadeeasy.com, but their dynamic DNS offering seem pretty weak: it requires the API to use my full dnsmadeeasy.com account credentials, I rather have the API use a limited privilege credential that can only add/remove/modify subdomain records from what I gather it only allows to modify existing records, does not allow me to dynamically add/remove records for new tenant subdomains My question what are my alternatives? Is there something in the dnsmadeeasy API offering I misunderstood and I should just use them? Is there some other similar DNS service that has a DDNS offering that satisfies my requirements? Or should I just bite the bullet and host my own DNS (my fear is not configuration/learning/know how, my fear is reliability). If you recommend the latter, can you detail the necessary steps or a link to a good tutorial how to?

    Read the article

  • 503 Service Unavailable - What really it means?

    - by pandiya chendur
    Possible Dup: http://stackoverflow.com/questions/2529244/503-service-unavailable-what-really-it-means I am asking on behalf of original question poster because we both work in the same place... I developed a website and it loads in every other system but certainly not in mine ... WHen i used firebug my request show 503 Service Unavailable Firebug response header showed, Server squid/2.6.STABLE21 Date Sat, 27 Mar 2010 12:25:18 GMT Content-Type text/html Content-Length 1163 Expires Sat, 27 Mar 2010 12:25:18 GMT X-Squid-Error ERR_DNS_FAIL 0 X-Cache MISS from xavy X-Cache-Lookup MISS from xavy:3128 Via 1.0 xavy:3128 (squid/2.6.STABLE21) Proxy-Connection close For REF: please visit the original question and look at the answers and comments and help us out..

    Read the article

  • Virtual Disk Service Loader has stopped working

    - by Leigh Riffel
    We have several relatively recent (less than 1 week) installations of Windows Server 2008 R2 Enterprise that are getting this error whenever we open Disk Management. The application name is vdsldr.exe and the Problem Event Name is BEX64. The windows firewall was turned off and the service disabled. The Virtual Disk service was started (identical results when it is stopped). The computers are virtual machines running on VSphere, so that could be part of the problem. The strange thing is that Disk Manager worked fine when the VMs were first created.

    Read the article

  • IIS6 Indexing Service indexing asp.net codebehind (.aspx.cs) files

    - by Patrick F
    I've setup a few catalogs on an Windows Server 2003 IIS6 install, each tracking files within a website. In the Properties - Generation Dialog for each catalog, 'Index files with unknown extensions' is turned OFF. 'Inherit above settings from Service' in that dialog is also turned off. However, the index is returning results for .cs files, along with abstracts for those files. I've emptied and restarted the catalogs but the files are still appearing. My understanding was the Indexing Service would by default only index HTML, ASCII, and Office Documents. What's going on?

    Read the article

  • PostgreSQL has no service name on CentOS

    - by Kyle MacFarlane
    I installed PostgreSQL in a pretty standard way on CentOS 5.5: rpm -ivh http://yum.pgrpms.org/reporpms/9.0/pgdg-centos-9.0-2.noarch.rpm yum install postgresql90-server postgresql90-contrib chkconfig postgresql-90 on /etc/init.d/postgresql-90 initdb But for some reason I can't use it with the service command because it has no name, .e.g if I do service --status-all I get back the following: master (pid 3095) is running... (pid 3009) is running... rdisc is stopped Or even just /etc/init.d/postgresql-90 status: (pid 3009) is running... So how can I give it a name so that I don't have to type out the whole init script path each time?

    Read the article

  • Exposing the ipPhone attribute to Communicator and the OCS address book service

    - by Doug Luxem
    I am in the process of integrating OCS with our Cisco phone system using CUCIMOC. After some fiddling with the phone normalization rules, it appears that I can get PSTN numbers to be dialed though the CUCIMOC interface (yay!). However, during this process I came to realize that the ipPhone attribute in Active Directory does not appear to be exposed to Communicator (and CUCIMOC). What is strange though, is that I can see from the OCS address book service "Invalid_AD_Phone_Numbers.txt" that the attribute is processed by the address book service. My question is, how do I expose the ipPhone field in Office Communicator? Currently, Communicator maps like this - Work = telephoneNumber Mobile = mobile Home = homePhone Attributes such as otherHomePhone, ipPhone, otherMobile, otherTelephone, otherIpPhone are ignored.

    Read the article

  • Windows Live Family Safety Service keeps closing Start Menu

    - by Jim McKeeth
    Got my kids a new Toshiba Laptop for Christmas. I was setting it all up for them so it would be ready to go. Tonight I installed Windows Live Family Safety Parental Controls. In the process of testing I discovered that on all the accounts the Start Menu closes automatically within 3 seconds (or less) of opening. It seems that it happens every 3 seconds, so sometimes it is immediate, and if I open it again then it will stay open for a full 3 seconds. This of course is rather annoying, and I need to wrap it up so it is ready to go under the tree. I disabled the Windows Live Family Safety Service, and that fixed it. Enable it again and the behavior returns. Is this a feature of the service? Can I disable that feature and keep the other features?

    Read the article

  • Macbook pro asks me to "Service Battery"

    - by Uwe Honekamp
    A couple of weeks ago I checked the battery and at that point in time (after 160 load cycles) it still had a capacity of 5000 mAh. Today, my 2006 macbook pro tells me via the battery menu to "Service Battery". According to Coconut Battery the current capacity is only 1590 mAh. The corresponding help text suggests contacting an Apple Authorized Service Provider (AASP) to have the computer checked. Before I decide to throw money at the AASP I'd like to understand what the AASP could possibly do to eliminate the problem. Isn't it more likely that the battery simply broke at 160 cycles and needs to be replaced? Are there any means by software or firmware to influence battery behavior? Of course, the computer hardware might be broken but how could this result in the described effect? And yes, I'm currently trying a calibration cycle but I have some doubts that it will save the day.

    Read the article

  • IIS FTP service - download timeouts and restarts getting the data twice

    - by accel229
    We have an IIS FTP site on a Windows Server 2003 x64 machine. Application Layer Gateway service is disabled (so http://support.microsoft.com/kb/931130 does not apply). Windows Firewall service is disabled as well. Connection timeout for the FTP site (there is only one) is set to 1,200 seconds = 20 minutes. An external client can connect to the site, list directory contents and download small files. When a client attempts to download a large file (eg, if the download continues for 3 minutes, which is still under 20 minutes, but relatively long), the server sends all data, then the connection times out, the client issues REST / RETR commands attempting to restart the download since after the last byte (which I believe should succeed and receive exactly 0 bytes), and the server behaves as if the client tried to restart after byte 0, that is, it sends the entire file all over. Any ideas on how to fix this?

    Read the article

  • Apache service hung and incoming requests not accepted

    - by Gnanam
    Hi, My production server is running Apache v2.2.4 with mod_mono v1.2.4 on CentOS release 5.2 (Final). Suddenly, Apache service hung during normal usage time (approx. 1 pm EDT). Traffic is not too high at this time. This is the first time we're noticing this kind of behaviour in our server. I noticed from access log that even subsequent requests are also not received, even though there were incoming requests. I then manually tried to invoke my application call from web browser, it never returned successfully but it was still loading. I found no unusual behaviour/activity in: 1) Apache access_log and error_log 2) No kernel level errors found in /var/log/messages I've no other option but ended up restarting Apache service. Any idea on what would cause Apache to hang and thereby not allowing subsequent incoming requests? How do I debug/diagnose when this happens next time? Experts advice/recommendation on this are highly appreciated.

    Read the article

  • windows installer service could not be started

    - by Fischer
    I'm on windows 7 64 bit, i'm using the admin accouunt, i try to install some programs, but can't, i troubleshooted the error that i got, and turned out that windows installer service is stopped, i tried to start it, it says windows installer service could not be started because its disabled or it has no enabled devices associated with it. Error 1058 How to fix it? Note that the laptop has an expired bitdefender installed on it. I don't know if it's causing the problem or not, i just thought it was worth mentioning since i had many problems with misconfigured or expired antiviruses before. The MSIServer could not be started as well, and i tried to run as administrator The laptop is not mine, i'm just trying to fix it

    Read the article

  • Opening an oracle database crashes the service

    - by tundal45
    I am experiencing a weird issue with Oracle where the service started fine after a crash. The database mount went fine as well. However, when I issue alter database open; command, the database does not open, gives a generic cannot connect to the database error & crashes the service. Oracle support has not seen this issue before so it's pretty scary. The fact that there are no logs that give any leads as to what could be causing this is also scary. I was wondering if good folks over at Server Fault had seen something like this or have some insights on things that I could try. It's Oracle 10g running on Windows Server 2003. Thanks, Ashish

    Read the article

  • What is a good hosted email service?

    - by rhooligan
    I am looking for a hosted email service for a handful of email accounts. It needs to be very reliable and provide a nice web mail interface. I would like an admin where I can manage accounts. I've used Communigate before, it's functional but ugly. Exchange web mail is feature rich enough, but isn't as performant as the later two contestants. I am currently paying $50/yearly for hosted Gmail through Google. The features of the web email client are fine for personal use, but not flexible enough for professional use. The administration tools also suck. In short, I want a hosted service with a better experience than gmail or Communigate but is still speedy.

    Read the article

  • "MAS SMS-CDMA" Bluetooth service

    - by TuxRug
    I have my phone (LG Rumor Touch on Sprint) connected to my Windows 7 computer by Bluetooth. Usually, one of the services is unidentified and no driver is installed. Occasionally I have an issue that is solved by removing and re-pairing my phone with my computer. The last few times I have paired my computer and phone, the unidentified service was found and installed, as "MAS SMS-CDMA". It sounds like an interface that allows sending and reading SMS messages via Bluetooth. However, there is no software available from Sprint or LG that I have found that offers such functionality. Searching Google for "MAS SMS-CMDA" (with quotes) did not provide anything useful, only what appear to be CMDA information written in Spanish. What can I use this service for, and how do I use it?

    Read the article

  • 503 service unavailable when debugging PHP script in Zend Studio

    - by user25932
    I have a web server with apache 2.0 installed. It comes with Zend Server install pack. When I’m trying to debug my php files apache serves a blank page with 503 service unavailable. Of course slow server-side code is tying up Apache requests for far too long, but I need it to wait, until my debugging comes to end. When I call to the page from a browser it launches ZendStudio debugging my PHP script (request redirects Zend Debugger module). I debug through my script and if I finish debugging in 120 seconds, I normally return to the browser. When it takes more than 120 seconds the browser displays '503 service unavailable' and I can't return to page output. I have even forced 'max_execution_time = 300' 'max_input_time = 600' in php.ini and 'TimeOut = 500' in httpd.conf. No matter whether it is Opera, IE or Firefox. I spent two days googling it, no right answer until now.

    Read the article

  • Windows Update cannot currently check for updates, because the service is not running

    - by Lee
    This morning I attempted to run Windows Update on two of my Windows 7 PCs (both are virtual machines), and I ran into this interesting pop-up error message. I have never encountered this problem before, so I was somewhat perplexed. From the message, my first thought was to see if the Windows Update service was running. It was. As usual, the solution is never so simple. I attempted to restart the service and reboot the PCs to no avail. So, I am off to the interwebs for a solution. I did find a solution to the problem, so I thought to post it for my future reference and for anyone else who may encounter this problem. I will be posting the answer shortly. If you have alternate solutions that have worked for you, please feel free to leave a post or comment.

    Read the article

  • MySql service stops under 2008 r2 x64

    - by volody
    I have installed MySql 5.5 server under windows 2008r2 x64 Apparently I can see that MySql service stops even if is configured to start automatically What can I do to find out why this is happening? MySql database is used as backend of ASP.Net web site Is it possible that web site was not active for a while and system stop mysql service? Update: It was mysql-5.5.7-rc-winx64. I could be an issue with this version (release candidate). Now I am trying to install mysql-5.5.8-winx64 And I have an issue with configuring MySql to work using name pipes I did uncheck use of TCP/IP protocol and configuration wizard just hangs Update: I have found workaround. It is required to configure MySql to use TCP/IP first, then reconfigure to use named pipes It looks like this link also has some information about the possible problems How should I diagnose ERROR 1045 during MySQL installation?

    Read the article

  • Cannont add service account to domain group during sql cluster install

    - by Sam
    I'm installing a 2008 instance on a 2003 machine which is already running 2005. I need to set up domain groups for the security setup step: http://msdn.microsoft.com/en-us/library/ms179530.aspx On Windows Server 2003, specify domain groups for SQL Server services. All resource permissions are controlled by domain-level groups that include SQL Server service accounts as group members. Much more info on this here: http://support.microsoft.com/kb/910708 I've had problems with being able to add the windows service accounts to the groups at install time. The security admins had to make my account a domain admin - which they were hesitant to do. The account under which SQL Server Setup is running must have permissions to add accounts to the domain groups. Is there a specific security setting which would allow my account to add accounts to a group?

    Read the article

  • Intel Rapid Storage Technology service always crashes

    - by Massimo
    I'm running Windows 7 x64 on a system based on an Asus Z87-Deluxe motherboard; the storage is configured for RAID mode; there is a single SSD drive for the O.S. and two 4-TB disks in a RAID 1 setup for the data. I've installed the latest version of Intel's Rapid Storage Technology drivers, 12.8.0.1016. The program complains about its service not being running, and the service is actually stopped; if I try to start it, it crashes. I've already tried reinstalling the package, but nothing changed. All the disks work correctly, but the RST program is unusable. How can I fix this?

    Read the article

  • wmpnetwork.exe service clogs CPU usage

    - by Brenton Taylor
    We have remote locations each with 2 ASUS media extenders that stream from a computer with a shared Media Player library. Lately, several of these locations experience the "wmpnetwork.exe" service throttling the CPU to 100% usage. Killing the service only results in it starting back up, and so far the only temporary solution is to uninstall Media Player. A lot of these computers are also about 3-5 years old. Could it just be a case of outdated hardware not being able to do everything we ask them to do? Edit: all running Windows XP and Windows Media Player 11

    Read the article

< Previous Page | 100 101 102 103 104 105 106 107 108 109 110 111  | Next Page >