Daily Archives

Articles indexed Tuesday April 13 2010

Page 34/126 | < Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >

  • WMI Remote Process Starting

    - by Goober
    Scenario I've written a WMI Wrapper that seems to be quite sufficient, however whenever I run the code to start a remote process on a server, I see the process name appear in the task manager but the process itself does not start like it should (as in, I don't see the command line log window of the process that prints out what it's doing etc.) The process I am trying to start is just a C# application executable that I have written. Below is my WMI Wrapper Code and the code I am using to start running the process. Question Is the process actually running? - Even if it is only displaying the process name in the task manager and not actually launching the application to the users window? Code To Start The Process IPHostEntry hostEntry = Dns.GetHostEntry("InsertServerName"); WMIWrapper wrapper = new WMIWrapper("Insert User Name", "Insert Password", hostEntry.HostName); List<Process> processes = wrapper.GetProcesses(); foreach (Process process in processes) { if (process.Caption.Equals("MyAppName.exe")) { Console.WriteLine(process.Caption); Console.WriteLine(process.CommandLine); int processId; wrapper.StartProcess("E:\\MyData\\Data\\MyAppName.exe", out processId); Console.WriteLine(processId.ToString()); } } Console.ReadLine(); WMI Wrapper Code using System; using System.Collections.Generic; using System.Management; using System.Runtime.InteropServices; using Common.WMI.Objects; using System.Net; namespace Common.WMIWrapper { public class WMIWrapper : IDisposable { #region Constructor /// <summary> /// Creates a new instance of the wrapper /// </summary> /// <param jobName="username"></param> /// <param jobName="password"></param> /// <param jobName="server"></param> public WMIWrapper(string server) { Initialise(server); } /// <summary> /// Creates a new instance of the wrapper /// </summary> /// <param jobName="username"></param> /// <param jobName="password"></param> /// <param jobName="server"></param> public WMIWrapper(string username, string password, string server) { Initialise(username, password, server); } #endregion #region Destructor /// <summary> /// Clean up unmanaged references /// </summary> ~WMIWrapper() { Dispose(false); } #endregion #region Initialise /// <summary> /// Initialise the WMI Connection (local machine) /// </summary> /// <param name="server"></param> private void Initialise(string server) { m_server = server; // set connection options m_connectOptions = new ConnectionOptions(); IPHostEntry host = Dns.GetHostEntry(Environment.MachineName); } /// <summary> /// Initialise the WMI connection /// </summary> /// <param jobName="username">Username to connect to server with</param> /// <param jobName="password">Password to connect to server with</param> /// <param jobName="server">Server to connect to</param> private void Initialise(string username, string password, string server) { m_server = server; // set connection options m_connectOptions = new ConnectionOptions(); IPHostEntry host = Dns.GetHostEntry(Environment.MachineName); if (host.HostName.Equals(server, StringComparison.OrdinalIgnoreCase)) return; m_connectOptions.Username = username; m_connectOptions.Password = password; m_connectOptions.Impersonation = ImpersonationLevel.Impersonate; m_connectOptions.EnablePrivileges = true; } #endregion /// <summary> /// Return a list of available wmi namespaces /// </summary> /// <returns></returns> public List<String> GetWMINamespaces() { ManagementScope wmiScope = new ManagementScope(String.Format("\\\\{0}\\root", this.Server), this.ConnectionOptions); List<String> wmiNamespaceList = new List<String>(); ManagementClass wmiNamespaces = new ManagementClass(wmiScope, new ManagementPath("__namespace"), null); ; foreach (ManagementObject ns in wmiNamespaces.GetInstances()) wmiNamespaceList.Add(ns["Name"].ToString()); return wmiNamespaceList; } /// <summary> /// Return a list of available classes in a namespace /// </summary> /// <param jobName="wmiNameSpace">Namespace to get wmi classes for</param> /// <returns>List of classes in the requested namespace</returns> public List<String> GetWMIClassList(string wmiNameSpace) { ManagementScope wmiScope = new ManagementScope(String.Format("\\\\{0}\\root\\{1}", this.Server, wmiNameSpace), this.ConnectionOptions); List<String> wmiClasses = new List<String>(); ManagementObjectSearcher wmiSearcher = new ManagementObjectSearcher(wmiScope, new WqlObjectQuery("SELECT * FROM meta_Class"), null); foreach (ManagementClass wmiClass in wmiSearcher.Get()) wmiClasses.Add(wmiClass["__CLASS"].ToString()); return wmiClasses; } /// <summary> /// Get a list of wmi properties for the specified class /// </summary> /// <param jobName="wmiNameSpace">WMI Namespace</param> /// <param jobName="wmiClass">WMI Class</param> /// <returns>List of properties for the class</returns> public List<String> GetWMIClassPropertyList(string wmiNameSpace, string wmiClass) { List<String> wmiClassProperties = new List<string>(); ManagementClass managementClass = GetWMIClass(wmiNameSpace, wmiClass); foreach (PropertyData property in managementClass.Properties) wmiClassProperties.Add(property.Name); return wmiClassProperties; } /// <summary> /// Returns a list of methods for the class /// </summary> /// <param jobName="wmiNameSpace"></param> /// <param jobName="wmiClass"></param> /// <returns></returns> public List<String> GetWMIClassMethodList(string wmiNameSpace, string wmiClass) { List<String> wmiClassMethods = new List<string>(); ManagementClass managementClass = GetWMIClass(wmiNameSpace, wmiClass); foreach (MethodData method in managementClass.Methods) wmiClassMethods.Add(method.Name); return wmiClassMethods; } /// <summary> /// Retrieve the specified management class /// </summary> /// <param jobName="wmiNameSpace">Namespace of the class</param> /// <param jobName="wmiClass">Type of the class</param> /// <returns></returns> public ManagementClass GetWMIClass(string wmiNameSpace, string wmiClass) { ManagementScope wmiScope = new ManagementScope(String.Format("\\\\{0}\\root\\{1}", this.Server, wmiNameSpace), this.ConnectionOptions); ManagementClass managementClass = null; ManagementObjectSearcher wmiSearcher = new ManagementObjectSearcher(wmiScope, new WqlObjectQuery(String.Format("SELECT * FROM meta_Class WHERE __CLASS = '{0}'", wmiClass)), null); foreach (ManagementClass wmiObject in wmiSearcher.Get()) managementClass = wmiObject; return managementClass; } /// <summary> /// Get an instance of the specficied class /// </summary> /// <param jobName="wmiNameSpace">Namespace of the classes</param> /// <param jobName="wmiClass">Type of the classes</param> /// <returns>Array of management classes</returns> public ManagementObject[] GetWMIClassObjects(string wmiNameSpace, string wmiClass) { ManagementScope wmiScope = new ManagementScope(String.Format("\\\\{0}\\root\\{1}", this.Server, wmiNameSpace), this.ConnectionOptions); List<ManagementObject> wmiClasses = new List<ManagementObject>(); ManagementObjectSearcher wmiSearcher = new ManagementObjectSearcher(wmiScope, new WqlObjectQuery(String.Format("SELECT * FROM {0}", wmiClass)), null); foreach (ManagementObject wmiObject in wmiSearcher.Get()) wmiClasses.Add(wmiObject); return wmiClasses.ToArray(); } /// <summary> /// Get a full list of services /// </summary> /// <returns></returns> public List<Service> GetServices() { return GetService(null); } /// <summary> /// Get a list of services /// </summary> /// <returns></returns> public List<Service> GetService(string name) { ManagementObject[] services = GetWMIClassObjects("CIMV2", "WIN32_Service"); List<Service> serviceList = new List<Service>(); for (int i = 0; i < services.Length; i++) { ManagementObject managementObject = services[i]; Service service = new Service(managementObject); service.Status = (string)managementObject["Status"]; service.Name = (string)managementObject["Name"]; service.DisplayName = (string)managementObject["DisplayName"]; service.PathName = (string)managementObject["PathName"]; service.ProcessId = (uint)managementObject["ProcessId"]; service.Started = (bool)managementObject["Started"]; service.StartMode = (string)managementObject["StartMode"]; service.ServiceType = (string)managementObject["ServiceType"]; service.InstallDate = (string)managementObject["InstallDate"]; service.Description = (string)managementObject["Description"]; service.Caption = (string)managementObject["Caption"]; if (String.IsNullOrEmpty(name) || name.Equals(service.Name, StringComparison.OrdinalIgnoreCase)) serviceList.Add(service); } return serviceList; } /// <summary> /// Get a list of processes /// </summary> /// <returns></returns> public List<Process> GetProcesses() { return GetProcess(null); } /// <summary> /// Get a list of processes /// </summary> /// <returns></returns> public List<Process> GetProcess(uint? processId) { ManagementObject[] processes = GetWMIClassObjects("CIMV2", "WIN32_Process"); List<Process> processList = new List<Process>(); for (int i = 0; i < processes.Length; i++) { ManagementObject managementObject = processes[i]; Process process = new Process(managementObject); process.Priority = (uint)managementObject["Priority"]; process.ProcessId = (uint)managementObject["ProcessId"]; process.Status = (string)managementObject["Status"]; DateTime createDate; if (ConvertFromWmiDate((string)managementObject["CreationDate"], out createDate)) process.CreationDate = createDate.ToString("dd-MMM-yyyy HH:mm:ss"); process.Caption = (string)managementObject["Caption"]; process.CommandLine = (string)managementObject["CommandLine"]; process.Description = (string)managementObject["Description"]; process.ExecutablePath = (string)managementObject["ExecutablePath"]; process.ExecutionState = (string)managementObject["ExecutionState"]; process.MaximumWorkingSetSize = (UInt32?)managementObject ["MaximumWorkingSetSize"]; process.MinimumWorkingSetSize = (UInt32?)managementObject["MinimumWorkingSetSize"]; process.KernelModeTime = (UInt64)managementObject["KernelModeTime"]; process.ThreadCount = (UInt32)managementObject["ThreadCount"]; process.UserModeTime = (UInt64)managementObject["UserModeTime"]; process.VirtualSize = (UInt64)managementObject["VirtualSize"]; process.WorkingSetSize = (UInt64)managementObject["WorkingSetSize"]; if (processId == null || process.ProcessId == processId.Value) processList.Add(process); } return processList; } /// <summary> /// Start the specified process /// </summary> /// <param jobName="commandLine"></param> /// <returns></returns> public bool StartProcess(string command, out int processId) { processId = int.MaxValue; ManagementClass processClass = GetWMIClass("CIMV2", "WIN32_Process"); object[] objectsIn = new object[4]; objectsIn[0] = command; processClass.InvokeMethod("Create", objectsIn); if (objectsIn[3] == null) return false; processId = int.Parse(objectsIn[3].ToString()); return true; } /// <summary> /// Schedule a process on the remote machine /// </summary> /// <param name="command"></param> /// <param name="scheduleTime"></param> /// <param name="jobName"></param> /// <returns></returns> public bool ScheduleProcess(string command, DateTime scheduleTime, out string jobName) { jobName = String.Empty; ManagementClass scheduleClass = GetWMIClass("CIMV2", "Win32_ScheduledJob"); object[] objectsIn = new object[7]; objectsIn[0] = command; objectsIn[1] = String.Format("********{0:00}{1:00}{2:00}.000000+060", scheduleTime.Hour, scheduleTime.Minute, scheduleTime.Second); objectsIn[5] = true; scheduleClass.InvokeMethod("Create", objectsIn); if (objectsIn[6] == null) return false; UInt32 scheduleid = (uint)objectsIn[6]; jobName = scheduleid.ToString(); return true; } /// <summary> /// Returns the current time on the remote server /// </summary> /// <returns></returns> public DateTime Now() { ManagementScope wmiScope = new ManagementScope(String.Format("\\\\{0}\\root\\{1}", this.Server, "CIMV2"), this.ConnectionOptions); ManagementClass managementClass = null; ManagementObjectSearcher wmiSearcher = new ManagementObjectSearcher(wmiScope, new WqlObjectQuery(String.Format("SELECT * FROM Win32_LocalTime")), null); DateTime localTime = DateTime.MinValue; foreach (ManagementObject time in wmiSearcher.Get()) { UInt32 day = (UInt32)time["Day"]; UInt32 month = (UInt32)time["Month"]; UInt32 year = (UInt32)time["Year"]; UInt32 hour = (UInt32)time["Hour"]; UInt32 minute = (UInt32)time["Minute"]; UInt32 second = (UInt32)time["Second"]; localTime = new DateTime((int)year, (int)month, (int)day, (int)hour, (int)minute, (int)second); }; return localTime; } /// <summary> /// Converts a wmi date into a proper date /// </summary> /// <param jobName="wmiDate">Wmi formatted date</param> /// <returns>Date time object</returns> private static bool ConvertFromWmiDate(string wmiDate, out DateTime properDate) { properDate = DateTime.MinValue; string properDateString; // check if string is populated if (String.IsNullOrEmpty(wmiDate)) return false; wmiDate = wmiDate.Trim().ToLower().Replace("*", "0"); string[] months = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; try { properDateString = String.Format("{0}-{1}-{2} {3}:{4}:{5}.{6}", wmiDate.Substring(6, 2), months[int.Parse(wmiDate.Substring(4, 2)) - 1], wmiDate.Substring(0, 4), wmiDate.Substring(8, 2), wmiDate.Substring(10, 2), wmiDate.Substring(12, 2), wmiDate.Substring(15, 6)); } catch (InvalidCastException) { return false; } catch (ArgumentOutOfRangeException) { return false; } // try and parse the new date if (!DateTime.TryParse(properDateString, out properDate)) return false; // true if conversion successful return true; } private bool m_disposed; #region IDisposable Members /// <summary> /// Managed dispose /// </summary> public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } /// <summary> /// Dispose of managed and unmanaged objects /// </summary> /// <param jobName="disposing"></param> public void Dispose(bool disposing) { if (disposing) { m_connectOptions = null; } } #endregion #region Properties private ConnectionOptions m_connectOptions; /// <summary> /// Gets or sets the management scope /// </summary> private ConnectionOptions ConnectionOptions { get { return m_connectOptions; } set { m_connectOptions = value; } } private String m_server; /// <summary> /// Gets or sets the server to connect to /// </summary> public String Server { get { return m_server; } set { m_server = value; } } #endregion } }

    Read the article

  • NHibernate child deletion problem.

    - by JMSA
    Suppose, I have saved some permissions in the database by using this code: RoleRepository roleRep = new RoleRepository(); Role role = new Role(); role.PermissionItems = Permission.GetList(); roleRep .SaveOrUpdate(role); Now, I need this code to delete the PermissionItem(s) associated with a Role when role.PermissionItems == null. Here is the code: RoleRepository roleRep = new RoleRepository(); Role role = roleRep.Get(roleId); role.PermissionItems = null; roleRep .SaveOrUpdate(role); But this is not happening. What should be the correct way to cope with this situation? What/how should I change, hbm-file or persistance code? Role.cs public class Role { public virtual string RoleName { get; set; } public virtual bool IsActive { get; set; } public virtual IList<Permission> PermissionItems { get; set; } } Role.hbm.xml <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="POCO" namespace="POCO"> <class name="Role" table="Role"> <id name="ID" column="ID"> <generator class="native" /> </id> <property name="RoleName" column="RoleName" /> <property name="IsActive" column="IsActive" type="System.Boolean" /> <bag name="PermissionItems" table="Permission" cascade="all" inverse="true"> <key column="RoleID"/> <one-to-many class="Permission" /> </bag> </class> </hibernate-mapping> Permission.cs public class Permission { public virtual string MenuItemKey { get; set; } public virtual int RoleID { get; set; } public virtual Role Role { get; set; } } Permission.hbm.xml <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="POCO" namespace="POCO"> <class name="Permission" table="Permission"> <id name="ID" column="ID"> <generator class="native"/> </id> <property name="MenuItemKey" column="MenuItemKey" /> <property name="RoleID" column="RoleID" /> <many-to-one name="Role" column="RoleID" not-null="true" cascade="all"> </many-to-one> </class> </hibernate-mapping>

    Read the article

  • How can I select this element?

    - by Kyle Sevenoaks
    Hi, I have code blindness, it's like snowblindness, just wth far too much code. I have a div class dynamically generated, <div class="even last"> How can I select that with CSS? div.even last { background-color:#ffffff; height:100%; border-top:1px solid #F5F5F5; padding:2px; margin-top:35px; } Doesn't seem to work, and I just can't think more.. Thanks :)

    Read the article

  • FBJS in facebook

    - by gacon
    I want to use javascript in my facebook application, but I don't know how to start with FBJS to use it. Someone help me please! just something like <div onclick="greeting();">click me</div> <script> function greeting(){ alert("hello world"); } </script>

    Read the article

  • How do i start learn python for web

    - by srisar
    Hi, I am learning python for a while, now I like to learn python for web, using python as a back-end of website. where and how do I start learning this: Example usages are : connecting database and retrieve and store information from forms

    Read the article

  • adding footer value to datagridview in C#

    - by Jankhana
    I am having 2 datatables. One is having the actual value of that table selected by the user and the next is having the aggregate value for that table i.e any grand total or avg. I want to display this as the footer in C# datagridview. How can I do that??? In asp.net we have RowDataBound event like that similar something is there in C# also but what it is i'm not able to find.

    Read the article

  • mysqldump triggering repair of MySQL tables

    - by Rhodri
    I have an automated backup of a 6 Gigabyte MySQL database running very two hours. I also have a script which checks every minute for the need to repair MySQL tables. Increasingly I'm getting tables having to be repaired during the backup process with the message returned of: Auto-increment value: 0 is smaller than max used value: xx Is this being caused by corruption? Are the two scripts conflicting? Any ideas?

    Read the article

  • Get the number of tiffs in a multi-tiff with command line ImageMagick?

    - by Anders
    Is there a way to get the number of tiffs in a multi-tiff with a command line utility in ImageMagick? What I want to to is to extract (split) the multi-tiff into single files. However if the tiff only contains one tiff (is not a multi-tiff), I would like to do nothing at all... Also if I use the "%d"-option to name the output files I get the "%d" in the file name if it is only one. ...or is there another way to use ImageMagick to avoid strange filenames when converting?

    Read the article

  • Naissance du projet QExtend, un projet lancé par la rubrique Qt pour vous simplifier Qt

    Naissance de QExtend Bonjour, Nous sommes heureux de vous annoncer la création du projet QExtend : http://projets.developpez.com/projects/qextend QExtend est une bibliothèque C++ développée par l'équipe Qt de la communauté Developpez.com. Son objectif est d'étendre et de simplifier l'utilisation de Qt ainsi que celle d'autres bibliothèques (Qwt, OpenCV...). Le projet venant de commencer, il n'y a pas encore énormément de choses disponibles sur le repository. Toutefois, nous pouvons vous faire part d'une bonne liste de fonctionnalités prévues : * Pointeurs intelligents ; * Manipulateurs de layouts, signaux/slots et XML ; ...

    Read the article

  • Finding the type of an object in C++

    - by lemnisca
    I have a class A and another class that inherits from it, B. I am overriding a function that accepts an object of type A as a parameter, so I have to accept an A. However, I later call functions that only B has, so I want to return false and not proceed if the object passed is not of type B. What is the best way to find out which type the object passed to my function is?

    Read the article

  • Unit testing .Net CF apps on Windows Mobile 6.5.3 in Visual Studio 2008

    - by Johann Gerell
    Did anyone get that to work? I mean, unit testing .Net CF apps on Windows Mobile 6.5.3 in Visual Studio 2008. It works great for a WM 6 Pro target, but not for a WM 6.5.3 target. I get this error: The test adapter ('Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') required to execute this test could not be loaded. Check that the test adapter is installed properly. Not enough storage is available to process this command. Yes, I can read the error text, but I don't understand the failed run. Any clues?

    Read the article

  • Getting Tomcat user in Java

    - by wolfi
    Hey everybody, is there a way to get the logged in user name (and group) from a Tomcat system. I read something about configuring Tomcat, so it is getting the user information out of a database. But I found now information about getting the name of the user (in my GWT Project), which is logged in. I'm trying to write a little GWT project and would like to publish the user name to the front page. Thx for your help.

    Read the article

  • I need help with this ogre dependent header (Qgears)

    - by commodore
    I'm 2 errors away from compiling Qgears. (Hacked Version of the Final Fantasy VII Engine) I've messed with the preprocessors to load the actual location of the ogre header files. Here are the errors: ||=== qgears, Debug ===| /home/cj/Desktop/qgears/trunk/project/linux/src/core/TextManager.h|48|error: invalid use of ‘::’| /home/cj/Desktop/qgears/trunk/project/linux/src/core/TextManager.h|48|error: expected ‘;’ before ‘m_LanguageRoot’| ||=== Build finished: 2 errors, 0 warnings ===| Here's the header file: // $Id$ #ifndef TEXT_MANAGER_h #define TEXT_MANAGER_h #include <OGRE/OgreString.h> #include <OGRE/OgreUTFString.h> #include <map> struct TextData { TextData(): text(""), width(0), height(0) { } Ogre::String name; Ogre::UTFString text; int width; int height; }; typedef std::vector<TextData> TextDataVector; class TextManager { public: TextManager(void); virtual ~TextManager(void); void SetLanguageRoot(const Ogre::String& root); void LoadTexts(const Ogre::String& file_name); void UnloadTexts(const Ogre::String& file_name); const TextData GetText(const Ogre::String& name); private: struct TextBlock { Ogre::String block_name; std::vector<TextData> text; } Ogre::String m_LanguageRoot; // Line #48 std::list<TextBlock> m_Texts; }; extern TextManager* g_TextManager; #endif // TEXT_MANAGER_h The only header file that's in include that's not a ogre header file is "map". If it helps, I'm using the Code::Blocks IDE/GCC Compiler in GNU/Linux. (Arch) I'm not sure even if I get this header fixed, I think I'll have build errors latter, but it's worth a shot. Edit: I added the semicolon and I have one more error in the header file: error: expected unqualified-id before ‘{’ token

    Read the article

  • How to get a safecontrol entry into manifest.xml with WSPBuilder project

    - by andrew
    Upon taking the default sharepoint master page for MySite, making some changes, and making a wsp out of it with WSPBuilder, I come to these errors in my logs: http://spoint/MySite/%5Fcatalogs/masterpage/MySite.master - An unexpected error has been encountered in this Web Part. Error: The control with virtual path '_controltemplates/Welcome.ascx' is not in the safe controls list for web at URL 'http://spoint/MySite'., Source: [UnsafeControlException: The control with virtual path '_controltemplates/Welcome.ascx' is not in the safe controls list for web at URL 'http://spoint/MySite' (stack trace omitted) http://spoint/MySite/%5Fcatalogs/masterpage/MySite.master - An unexpected error has been encountered in this Web Part. Error: The control with virtual path '_controltemplates/DesignModeConsole.ascx' is not in the safe controls list for web at URL 'http://spoint/MySite'., Source: [UnsafeControlException: The control with virtual path '_controltemplates/DesignModeConsole.ascx' is not in the safe controls list for web at URL 'http://spoint/MySite' (stack trace ommited) So, this masterpage does in fact use these OOTB controls and so I guess I need to get them safecontrolled. And I guess I want to do this via the manifest.xml. But I do not see how to make WSPBuilder do this.

    Read the article

  • Specialization of template after instantiation?

    - by Onur Cobanoglu
    Hi, My full code is too long, but here is a snippet that will reflect the essence of my problem: class BPCFGParser { public: ... ... class Edge { ... ... }; class ActiveEquivClass { ... ... }; class PassiveEquivClass { ... ... }; struct EqActiveEquivClass { ... ... }; struct EqPassiveEquivClass { ... ... }; unordered_map<ActiveEquivClass, Edge *, hash<ActiveEquivClass>, EqActiveEquivClass> discovered_active_edges; unordered_map<PassiveEquivClass, Edge *, hash<PassiveEquivClass>, EqPassiveEquivClass> discovered_passive_edges; }; namespace std { template <> class hash<BPCFGParser::ActiveEquivClass> { public: size_t operator()(const BPCFGParser::ActiveEquivClass & aec) const { } }; template <> class hash<BPCFGParser::PassiveEquivClass> { public: size_t operator()(const BPCFGParser::PassiveEquivClass & pec) const { } }; } When I compile this code, I get the following errors: In file included from BPCFGParser.cpp:3, from experiments.cpp:2: BPCFGParser.h:408: error: specialization of ‘std::hash<BPCFGParser::ActiveEquivClass>’ after instantiation BPCFGParser.h:408: error: redefinition of ‘class std::hash<BPCFGParser::ActiveEquivClass>’ /usr/include/c++/4.3/tr1_impl/functional_hash.h:44: error: previous definition of ‘class std::hash<BPCFGParser::ActiveEquivClass>’ BPCFGParser.h:445: error: specialization of ‘std::hash<BPCFGParser::PassiveEquivClass>’ after instantiation BPCFGParser.h:445: error: redefinition of ‘class std::hash<BPCFGParser::PassiveEquivClass>’ /usr/include/c++/4.3/tr1_impl/functional_hash.h:44: error: previous definition of ‘class std::hash<BPCFGParser::PassiveEquivClass>’ Now I have to specialize std::hash for these classes (because standard std::hash definition does not include user defined types). When I move these template specializations before the definition of class BPCFGParser, I get a variety of errors for a variety of different things tried, and somewhere (http://www.parashift.com/c++-faq-lite/misc-technical-issues.html) I read that: Whenever you use a class as a template parameter, the declaration of that class must be complete and not simply forward declared. So I'm stuck. I cannot specialize the templates after BPCFGParser definition, I cannot specialize them before BPCFGParser definition, how may I get this working? Thanks in advance, Onur

    Read the article

  • Drupal: tags order in back-end edit-content pages

    - by Patrick
    hi, can I order alphabetically the tags in my edit content pages ? See screenshot here: http://dl.dropbox.com/u/72686/tagsOrder.png Currently the order is given by the Taxonomy Manager module (I installed in my Drupal). I would like to know if I should use jQuery to order the tags in my back-end pages. thanks

    Read the article

  • Best Pattern for AllowUnsafeUpdates

    - by webwires
    So far, in my research I have seen that it is unwise to set AllowUnsafeUpdates on GET request operation to avoid cross site scripting. But, if it is required to allow this, what is the proper way to handle the situation to mitigate any exposure? Here is my best first guess on a reliable pattern if you absolutely need to allow web or site updates on a GET request. Best Practice? protected override void OnLoad(System.EventArgs e) { if(Request.HttpMethod == "POST") { SPUtility.ValidateFormDigest(); // will automatically set AllowSafeUpdates to true } // If not a POST then AllowUnsafeUpdates should be used only // at the point of update and reset immediately after finished // NOTE: Is this true? How is cross-site scripting used on GET // and what mitigates the vulnerability? } // Point of item update SPSecurity.RunWithElevatedPrivledges(delegate() { using(SPSite site = new SPSite(SPContext.Current.Site.Url)) { using (SPWeb web = site.RootWeb) { bool allowUpdates = web.AllowUnsafeUpdates; //store original value web.AllowUnsafeUpdates = true; //... Do something and call Update() ... web.AllowUnsafeUpdates = allowUpdates; //restore original value } } }); Feedback on the best pattern is appreciated.

    Read the article

  • Rewriting a statement using LINQ(C#)

    - by Thinking
    Is it possible to write the folowing using lambda(C#) private static void GetRecordList(List<CustomerInfo> lstCustinfo) { for (int i = 1; i <= 5; i++) { if (i % 2 == 0) lstCustinfo.Add(new CustomerInfo { CountryCode = "USA", CustomerAddress = "US Address" + i.ToString(), CustomerName = "US Customer Name" + i.ToString(), ForeignAmount = i * 50 }); else lstCustinfo.Add(new CustomerInfo { CountryCode = "UK", CustomerAddress = "UK Address" + i.ToString(), CustomerName = "UK Customer Name" + i.ToString(), ForeignAmount = i * 80 }); } }

    Read the article

  • Read alphanumeric characters from csv file in C#

    - by Prasad
    I am using the following code to read my csv file: public DataTable ParseCSV(string path) { if (!File.Exists(path)) return null; string full = Path.GetFullPath(path); string file = Path.GetFileName(full); string dir = Path.GetDirectoryName(full); //create the "database" connection string string connString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=\"" + dir + "\\\";" + "Extended Properties=\"text;HDR=Yes;FMT=Delimited;IMEX=1\""; //create the database query string query = "SELECT * FROM " + file; //create a DataTable to hold the query results DataTable dTable = new DataTable(); //create an OleDbDataAdapter to execute the query OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString); //fill the DataTable dAdapter.Fill(dTable); dAdapter.Dispose(); return dTable; } But the above doesn't reads the alphanumeric value from the csv file. it reads only i either numeric or alpha. Whats the fix i need to make to read the alphanumeric values? Please suggest.

    Read the article

  • Problem with CommandFinder class...

    - by Patrick
    and I'm not sure why... Hello Everbody! I'm trying to make my first steps with SWTBot. I'm trying to test an Eclipse RCP Application. In one test i'm trying to call a command to save a dirty editor. But an assertion after the call, tells me that the editor is still dirty. An the data in the dirty editor is not showing up in the database. On the other hand, i'm not getting an Exception when calling the command... new CommandFinder().findCommand(CoreMatchers.equalTo(COMMANDNAME_SAVE)).get(0).click(); Has anyone any insperation for me, where i made a mistake?

    Read the article

  • Amazon S3 tools for Debian?

    - by Jonik
    I need to (programmatically, in a shell script) upload an EAR file to an Amazon S3 bucket on Debian (5.0.4). What, if any, Debian package provides simple, scriptable tools for that? (I want raw S3 bucket access, so please don't suggest solutions like Jungle Disk.)

    Read the article

< Previous Page | 30 31 32 33 34 35 36 37 38 39 40 41  | Next Page >