c#,mysql,.net,entity-frameworkRelated issues-Collection of common programming errors
Robbie Dee
c# inheritance
Knowing that C# doesn’t support multiple inheritance, is it considered bad form to write a utility base class?Some initial thoughts:I could create an interface and a concretion, but then the implementation isn’t portable Should the developer need to extend the class in say, a decorator pattern, they could implement this new class and inherit the base class in their new classEDIT:N.B. I’m not talking about vanilla inheritance here e.g. poodle<–dog<–mammal<–animalMore this sort of thin
p.s.w.g
c# coding-style coding-standards teamwork
I have one one software system which allows developers to specify an ID or name to create NodeReferences. Both work fine, but ID’s are not guaranteed to be the same across different environments. I’ve tried in documentation and in conversations to stress that ID’s should not be hard coded (since they will break when deployed to a different environments), but some developers are still using them. This works only in dev environment:var level = LevelReference.ById(20); var node = NodeReference.ByNa
Andrei
c# .net git debugging
When our application doesn’t work the way we expect it to (e.g. throws exceptions etc.), I usually insert a lot of debug code at certain points in the application in order to get a better overview of what exactly is going on, what the values for certain objects are, to better trace where this error is triggered from. Then I send a new installer to the user(s) that are having the problem and if the problem is triggered again I look at the logs and see what they say.But I don’t want all this debug
Ismail Gunes
mysql c#
I use this query for loading sql data from my pc to localhost mysql database.(version 5.0.10 working witj XAMPP)The query is as below:cmd = new MySqlCommand(“LOAD DATA LOCAL INFILE ‘” + filename + “‘ IGNORE INTO TABLE ” + tblname + ” CHARACTER SET UTF8″, conn);And I tried this also (enclosed tblname) cmd = new MySqlCommand(“LOAD DATA LOCAL INFILE ‘” + filename + “‘ INTO TABLE `” + tblname + “` CHARACTER SET UTF8”, conn);And one line of my sql data (loaded without problem by phpmyadmin) :INSERT I
Max Vernon
c# oracle
I have an Oracle server running on Windows Server. When an INSERT statement runs I receive an Oracle Ora-00603 error. The insert statement just tries to insert a BLOB into a table. I searched the error specification on Google and found that perhaps there are network connection issues. The suggested action is to log in again to Oracle Server. I followed this tip, however I still receive the same error.The error I receive is the following:ora-00603: ORACLE server session terminated by fatal error
MikroDel
c# refactoring unit-testing wcf
I have WCF Service. Its work fine and I want to have test coverage for it. Unit tests and acceptance. The problem is static class using in the code. How is it possible to avoid it?If it will be refactored to the code without static classes – I can use mocks for example Moq.I have also used Ninject as DI Framework so far.[ServiceContract]public interface IWorkingService{[OperationContract]Collection<Ergebnis> UpdateEntity(int entityID);}public class WorkingService : IWorkingService{private
Jamal
c# networking socket tcp
I’ve only been coding C# a few weeks and was just hoping for a little constructive criticism of a socket server I’ve been working on:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Sockets; using System.Net;namespace NetworkCommunication {public class TCPSocketServer : IDisposable{private int portNumber;private int connectionsLimit;private Socket connectionSocket;private List<StateObject> connectedClients = new List<StateObject>(
kmp
c# .net
I saw this question “Is this implementation of an Asynchronous TCP/UDP Server correct” and it is very similar to what I want to do but it goes about it in a different way so I am wondering if anyone would mind doing some constructive critism on my method please.I’m looking for any feedback along the lines of “when x happens your server will fall over because of y” or something like that.My intention is that the server should log out errors that happen and raise an event when it has data. I wan
tesicg
c#
The code I want to refactor look as following:public bool CheckPay(Int64 orderID) {vpc_OrderInfo = orderID;RequestParams =string.Format(“vpc_Version={0}&vpc_Command={1}&vpc_AccessCode={2}&vpc_MerchTxnRef={3}&vpc_Merchant={4}&vpc_User={5}&vpc_Password={6}”,vpc_Version, vpc_Command, vpc_AccessCode, vpc_MerchTxnRef, vpc_Merchant, vpc_User, vpc_Password);string[] response = SendRequest(vpc_VirtualPaymentClientURL, RequestParams).Split(‘&’);bool ResponseCode = false;bool e
Jamal
c#
I have two quite mutually exclusive desires – detailed logs and keeping my code clean. It appears that you can only get either of these. By “logging” I mean logging and not tracing, so AOP adepts wouldn’t appreciate it.What I want to have is real description of action my program does, why it does these actions and so forth. For instance, ‘failures’ could either be real failures like ‘fatal errors’, or absolutely normal behavior depending on context: I don’t like to check whether or not file exis
Timo Schneider
mysql
I can not dump my MySQL-Databeses, however here’s the error message:Cannot load from mysql.proc. The table is probably corruptedAlso mysql_upgrade seems not to work:# mysql_upgrade Looking for ‘mysql’ as: mysql Looking for ‘mysqlcheck’ as: mysqlcheck Running ‘mysqlcheck with default connection arguments mysqlcheck: Got error: 1045: Access denied for user ‘root’@’localhost’ (using password: NO) when trying to connect FATAL ERROR: Upgrade failedWhat does that mean ?
JoelFan
linux mysql debian-wheezy upgrade-issue
I upgraded debian to wheezy and got errors with mysql-server so I removed it. Now I can’t reinstall it. I get:$ sudo apt-get install mysql-server … Unpacking mysql-server (from …/mysql-server_5.5.30+dfsg-1.1_all.deb) … Processing triggers for man-db … gdbm fatal: malloc error Setting up mysql-server-5.5 (5.5.30+dfsg-1.1) … [FAIL] Starting MySQL database server: mysqld . . . . . . . . . . . . . . failed! invoke-rc.d: initscript mysql, action “start” failed. … dpkg: error processing
Spacedust
mysql database import mysql5.5
I’m trying to import 641 MB MySQL database with a command:mysql -u root -p ddamiane_fakty < domenyin_damian_fakty.sqlbut I got an error:ERROR 1064 (42000) at line 2351406: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘<br /> <b>Fatal error</b>: Maximum execution time of 300 seconds exceeded in <b’ at line 253However limits are set much higher:mysql> show global variables like “int
DTest
mysql
I am running sysbench on a RHEL 5.6 server running MySQL 5.5.16 using the following setup:sysbench –test=oltp –db-driver=mysql –mysql-user=sbench \–mysql-socket=/var/lib/mysql/mysql.sock –mysql-db=sbench \–mysql-table-engine=innodb –oltp-table-size=1000000 prepareThis creates the default sbench table like so:mysql> SHOW CREATE TABLE sbench.sbtest\G *************************** 1. row ***************************Table: sbtest Create Table: CREATE TABLE `sbtest` (`id` int(10) unsigned NOT
jitendra
mysql innodb
I have XAMPP on my Ubuntu Lucid system and everything worked fine. But there seems to be some problem now and mysql wouldn’t start. I had tried to recover a few Drupal databases and hence copied the raw files to /opt/lampp/var/mysql folder like all other database folders. And, I guess that could have caused the problem. I am pasting the last few lines of the error log. Someone please help me out. 100814 15:17:47 mysqld_safe Starting mysqld daemon with databases from /opt/lampp/var/mysql 100814
Shannon A.
mysql backup bacula
All of my Bacula backups started failing over the weekend with the following MySQL error:Fatal error: sql_create.c:XXX Fill File table Query failed: INSERTINTO File (FileIndex, JobId, PathId, FilenameId, LStat, MD5)SELECTbatch.FileIndex, batch.JobId, Path.PathId,Filename.FilenameId,batch.LStat, batch.MD5 FROM batch JOIN Path ON(batch.Path = Path.Path) JOIN Filename ON (batch.Name =Filename.Name): ERR=Duplicate entry ‘375086058’ for key ‘PRIMARY’It was fairly sudden: it seems to have happened bet
Danjah
mysql connection flash flex-builder-3
I’ve been mucking around with Flash Builder (beta 2) and trying to get some PHP services hooked up. It’s dead simple through FB assuming no hiccups. But I’ve been hiccupping for days now.I’m running the latest WAMP install with only one modification mentioned below (fresh install) on WinXPSP2.TO sum up, I have a very simple DB table set up, primary key + 4 other fields. I have a sample PHP service set up to talk communicate with MySQL and receive the table row data. However, whether I try to con
emilhem
mysql email postfix
I have a somewhat complex SQL query that I’m using to get alias forwarding e-mail in Postfix. The problem is that Postfix uses %s as it’s insert of alias mark in the SQL query. I think this causes the query to fail for Postfix while it works when inserting it directly to MySQL (replacing the %s with a test alias)SELECT email FROM members JOIN groups ON mgroup_others LIKE CONCAT(‘%,’, g_id, ‘,%’) OR member_group_id = g_id WHERE g_title LIKE CONCAT(‘%[‘, ‘%s’, ‘]%’);The Postfix error:postfix/smtpd
Arenstar
mysql macosx
So I’ve been going sort-of crazy for the past few days. I’ve got a mac, OSX 10.6.4, and I HAD mySQL running on it. At some point after the 10.6.4 update, mySQL stopped working. I got an error telling me that mySQL couldn’t find the mysql.sock file. I’ve uninstalled/reinstalled mySQL a couple of times and nothing is helping. if I run the mysqld coommand in my bin directory I get a bunch of errors that lead me to believe there was a permission error on the data directory, but data is owned by
Blackninja543
mysql fedora
I am trying to run a local MySQL server on a Fedora 17 system. I initially installed MySQL through YUM, however when I runmysql_install_db mysqladmin -u root password ‘MYPASSWORD’ service start mysqld.serivceI receive an error in /var/log/mysql121101 12:58:50 [ERROR] /usr/libexec/mysqld: Can’t find file: ‘./mysql/host.frm’ (errno: 13) 121101 12:58:50 [ERROR] Fatal error: Can’t open and lock privilege tables: Can’t find file: ‘./mysql/host.frm’ (errno: 13)After a little snooping I finally located
Chris Dunaway
ssl windows certificates .net
I have written an application (in C#) to communicate with one of our customers via a web service. Our customer requires us to use bi-directional SSL. The customer has sent us their certificate (in the form of a .p7b file). The client certificate was provided to me in the form of a .cer file.I’ve installed the certificates and in the program I use the HttpWebRequest class and add the client certificate to the ClientCertificates collection.When I run the program I get an exception:System.Net.We
Andrei
c# .net git debugging
When our application doesn’t work the way we expect it to (e.g. throws exceptions etc.), I usually insert a lot of debug code at certain points in the application in order to get a better overview of what exactly is going on, what the values for certain objects are, to better trace where this error is triggered from. Then I send a new installer to the user(s) that are having the problem and if the problem is triggered again I look at the logs and see what they say.But I don’t want all this debug
kmp
c# .net
I saw this question “Is this implementation of an Asynchronous TCP/UDP Server correct” and it is very similar to what I want to do but it goes about it in a different way so I am wondering if anyone would mind doing some constructive critism on my method please.I’m looking for any feedback along the lines of “when x happens your server will fall over because of y” or something like that.My intention is that the server should log out errors that happen and raise an event when it has data. I wan
John M
c# .net mysql
Using Windows Server 2003, MySQL 5.1.23, MySQL .NET Connector 6.2.2I am trying to use the MySQLBulkLoader class to read in a fixed width text file. An excerpt from that classes Load method is:string sql = BuildSqlCommand(); MySqlCommand cmd = new MySqlCommand(sql, Connection); cmd.CommandTimeout = 10 * 60;// Timeout; cmd.ExecuteNonQuery();The string created by ‘BuildSqlCommand’ is:LOAD DATA LOCAL INFILE ‘c:/M/D/ALLDATA_0.TXT’ INTO TABLE dk.tk FIELDS TERMINATED BY ” LINES TERMINATED BY ‘\n’ W
Daniel Rose
.net .net-3.5 fatal-error
Summary:I periodically get a .NET Fatal Execution Engine Error on an application which I cannot seem to debug. The dialog that comes up only offers to close the program or send information about the error to Microsoft. I’ve tried looking at the more detailed information but I don’t know how to make use of it.Error:The error is visible in Event Viewer under Applications and is as follows:.NET Runtime version 2.0.50727.3607 -Fatal Execution Engine Error(7A09795E) (80131506)The computer running it
samaxI92
c# .net obfuscation
The class below causing –fatal error– after obfuscating with confuser(v1.9.0.0); I’m thinking its for bad/unsafe coding. I’m a beginner programmer. So it would be great if some-one point and describe the bad part(if exists) of my code. My IDE is VS-2010. Thanks. public class Check_COMgsm {public Exception ex;public List<string> ModemName;public List<string> ModemPort;public Check_COMgsm(){this.ex = null;this.ModemName = new List<string>();this.ModemPort = new List<string&g
Chris Moutray
.net sql-server
I’ve recently started receiving this error: “Internal connection fatal error” from my application. The error occurs randomly. When it happens my application is unusable for the next few minutes. After careful analysis of the error I’ve concluded that this error happens in only one method within my application. This method fires a series of simple ordinary SQL queries but it does involve multithreading however all threads should be disposed before this block of code. The error happens always on a
spender
c# .net collections
I need to maintain a roster of connected clients that are very shortlived and frequently go up and down. Due to the potential number of clients I need a collection that supports fast insert/delete. Suggestions?
natli
c# .net linux mono json.net
Running Mono 3.2.6 on Debian 7When using Newtonsoft.Json to deserialize objects in a multithreaded application, my application crashes due to ‘segmentation fault.’ I attached gdb & here’s the output:root@ns38225:/home/stress# gdb program 30380 GNU gdb (GDB) 7.4.1-debian Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to
FreelanceCoder
c++ .net linker lnk
This question is an exact duplicate of:C and hashlib LNK errors1 answerNote that i am using Windows Forms Applications with the .NET Here is my code:#pragma once #include <cstdlib> #include <Windows.h> #include <string.h> #include <stdlib.h> #include <algorithm> #include <stdio.h> #include <string> #include <cstring> #include <iostream> #include <vcclr.h> #include <hashlibpp.h>namespace Launcher {using namespace System;using names
Patrick Peters
c# entity-framework visual-studio-2013 code-first-migrations
I have an assembly with an EF 5.0 (target framework 4.0) migrations in it.When I open the package management console and type ‘update-database’ I get an BadImageException. (note: I have one c++ native lib in the solution).I have read several post regarding this and I tried:All projects have x64 target platform Solution platform is x64, all projects have x64 as configuration No warnings during buildBut…when I added a console app, using DBMigrator class the migration works fine!What happens ?(up
SeanR
entity-framework ef-code-first
I am modeling music tracks and albums where Albums have many tracks and Tracks can be on only one album, with a join table to specify it’s position in the album listing.Here are my models:public class Track {public int Id { get; set; }public string Name { get; set; }public int AlbumTrackId { get; set; }public virtual AlbumTrack AlbumTrack { get; set; } }public class Album {public int Id { get; set; }public string Name { get; set; }public virtual ICollection<AlbumTrack> AlbumTracks { get; s
Matt Johnson
c# sql-server linq entity-framework timespan
I have the following table:SHIFT—————————————- | SHIFT_ID | SHIFT_TIME | SHIFT_DURATION | | ————————————– | | 1 | 00:00:00 | 01:00:00 | | 2 | 01:00:00 | 01:00:00 | | 3 | 02:00:00 | 01:00:00 |—————————————-Here, SHIFT_TIME and SHIFT_DURATION are of type TimeSpan.Now, when I run the following query:var query = from c in SHIFTwhere c.SHIFT_TIME + c.SHIFT_DURATION >=new TimeSp
Scott Davies
c# entity-framework
I’m working with a small model in Entity Framework 4.0. I’d like to have an instance method of the object that represents an entity persist the entity to the database. So instead of from “external” code:public static void Main(string[] args) {using (EFContext ctx = new EFContext()){context.AnEntitySet.AddObject(refToTheEntityInstance);context.SaveChanges();Instead, I want the instance of the entity to persist itself, where Contact is the entity name.public ContactInstance : Contact {public voi
czetsuya
entity-framework entity-framework-4.1 ef-code-first
Lately I’ve been working on stored procedure and encountered 1 strange problem. First, I was able to successfully call a stored procedure from the database via:IList<XXXViewModel> XXXList =_context.Database.SqlQuery(“spXXX”).ToList();But when I needed to pass parameters it failed:var parameters = new List<SqlParameter>(); parameters.Add(new SqlParameter(“param1”, param1Value)); parameters.Add(new SqlParameter(“param2”, param2Value)); IList<XXXViewModel> XXXList = _context.Database
Tim Coulter
entity-framework mocking iqueryable
I am currently writing unit tests for my repository implementation in an MVC4 application. In order to mock the data context, I started by adopting some ideas from this post, but I have now discovered some limitations that make me question whether it is even possible to properly mock IQueryable.In particular, I have seen some situations where the tests pass but the code fails in production and I have not been able to find any way to mock the behavior that causes this failure.For example, the fol
Albin Sunnanbo
entity-framework ef-migrations entity-framework-4.3
I have a class library with EF Code First. I just upgraded to EF 4.3 and now I want to enable migrations.I type Enable-Migrations -ProjectName MyProjectName in the PM console but receive the following errorPM> Enable-Migrations -ProjectName MyProjectName System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.at System.Collections.Generic.Dictionary`2.get_Item(TKey key)at System.Data.Entity.Migrations.DbMigrationsConfiguration.GetSqlGenerator(String pr
James Newton-King
wcf json entity-framework asp.net-ajax
It seems that serializing Entity Framework objects into JSON is not possible using either WCF’s native DataContractJsonSerializer or ASP.NET’s native JavaScript Jersializer. This is due to the reference counting issues both serializers reject. I have also tried Json.NET, which also fails specifically on a Reference Counting issue.Edit: Json.NET can now serialize and deserialize Entity Framework entities.My objects are Entity Framework objects, which are overloaded to perform additional business
BoltzmannBrain
c# entity-framework code-first postsharp
I’m creating a Database using the Microsoft Entity Framework and CodeFirst in C#. I want to use the Database in a WPF-Application, so the Entity-Classes should implement “INotifyPropertyChanged”. This can be done very elegantly using a PostSharp aspect, which triggers the PropertyChanged event automatically every time a property changes. If I create such an aspect and use it on my entity classes, I get the following exeption when trying to create the Database:\tSystem.Data.Entity.Edm.EdmNavigati
magicandre1981
entity-framework windows-8 ngen
As advised by the Entity Framework Team I’ve tried to create a native image of EntityFramework.dll with this command:ngen install packages\EntityFramework.6.1.0-beta1\lib\net40\EntityFramework.dllthis results in the error 0x80131F06 (no native image for mscorlib.dll). When I now try to run ngen install mscorlib.dll I get the error 0x800706BE (RPC_S_CALL_FAILED – The remote procedure call failed).I already used sfc /scannow and it reports no broken files.Any ideas what is wrong here?
Web site is in building