c#,.net,serialization,dynamic,expandoobjectRelated 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

  • 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

  • Joachim Kurz
    java android android-intent serialization onactivityresult
    I am working on an Android app that lets users scan their contracts using their phone’s camera. When I want the user to add a new contract I start an activity that lets them take a number of pictures (which that second activity does by in turn using the MediaStore.ACTION_IMAGE_CAPTURE intent) of different pages of the contract. That seems to work fine and I try to return the completed contract object via setResult() and retrieve it in the MainActivity via onActivityResult():@Override protected v

  • Caveman
    java android serialization deserialization
    I’m trying to serialize an object and store it on the SD card. Essentially I am saving the game state. So I just serialize a single object called GameState, which itself contains various other objects and primitives, the objects are all serializable.Now serializing and saving the file works fine. No errors or exceptions in the logcat. However, about fifty percent of the time when trying to deserialize the GameState I get an exception, java.io.OptionalDataException .My deserialization method look

  • George2
    c# .net serialization datatable vsts2008
    I am using VSTS2008 + C# + .Net 3.5 to run this console application on x64 Server 2003 Enterprise with 12G physical memory.Here is my code, and I find when executing statement bformatter.Serialize(stream, table), there is out of memory exception. I monitored memory usage through Perormance Tab of Task Manager and I find only 2G physical memory is used when exception is thrown, so should be not out of memory. :-(Any ideas what is wrong? Any limitation of .Net serialization?static DataTable MakePa

  • My-Name-Is
    java json serialization resteasy
    For a REST serives (RESTeasy) I have created JUnit test cases like:@Test public void a100_insertAddressTest() throws Exception {Address addr = new Address(1, “testStreet”, “1”, (short) 1234,”testCity”);ClientRequest request = new ClientRequest(BASE_URL + “customerID/{id}”,sslExecutor_schusb);request.body(MediaType.APPLICATION_XML, addr).pathParameter(“id”, 1);ClientResponse<String> response = request.post(String.class);Assert.assertEquals(201, response.getStatus());response.releaseConnecti

  • Konstantin
    java android serialization deserialization objectinputstream
    I use the following class to deserialize a string and map the incoming classes to new ones in a different package. They contain the exact same attributes ( except the mapped equivalents ) and the same serial version uid. public class CompatibilityImporter {public void loadOldImport(final File f, final CompatibilityImportListener importListener, final String password) {new Thread(new Runnable() {@Overridepublic void run() {try {String oldExport = readFileAsString(f);ObjectInputStream ois = new Cl

  • voithos
    c# xml serialization
    Let’s say that I have two classes, a base class and a derived class. They are fairly simple classes, and mainly just act as data structures (with the derived class obviously being slightly more complex).public class BaseUserSession {// … Various properties … }public class DerivedUserSession : BaseUserSession {// … Even more properties … }These classes need to be serialized into XML. Now, this can be done simply by specifying [Serializable] above the class declarations, and the default XM

  • seba.wagner
    java serialization jpa red5 openjpa
    My framework seems to have issues with a special entity that constantly fails to get serialized with an exception.Entity: http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/persistence/beans/basic/Server.java?view=markupMy theory: The serializer uses the enhanced class from OpenJPA, and it cannot serialize it. But I have no idea how this can only happen with this entity and all other work fine.Exception:WARN: Exception: java.lang.reflect.Invocatio

  • Cuga
    json gwt serialization autobean
    I’m trying to figure out how to serialize a list using AutoBean in GWT, but I keep getting a Null Pointer Exception. Here’s what I have:GuideCreatorFactory beanFactory = AutoBeanFactorySource.create(GuideCreatorFactory.class);List<Guide> guides = new LinkedList<Guide>();Guide guide = new Guide();guide.setText(“this is the text”);guide.setTitle(“this is the title”);guides.add(guide);GuideCreatorList<Guide> impl = new GuideCreatorListImpl();impl.setGuides(guides);System.out.print

  • salocinx
    java serialization jpa glassfish-3 serialversionuid
    I am working with Glassfish 3.1.2.2, eclipse-link as JPA provider and Java JDK-6u31. My application is 3-tiered with a stand-alone Swing client running on its own JVM on the client machines. Communication with EJBs by JNDI lookups and @Remote interfaces.I have the following object inheritance structure:My super class “Document” :@Entity @Table(name = “Document”) @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) public class Document implements IUpdateableEntity {private static final long se

  • vimterd
    java gwt generics serialization polymorphism
    After resolved a problem of serialization with JAXB, I have a problem to use DTOs with GWT (version 2.5.1):@XmlRootElement public class Performance<M extends IMeasurement> implements Serializable {@XmlElementWrapper(name = “measurementsPerformance”)@XmlElements({@XmlElement(name = “measurement”, type = MeasurementStringDouble.class),@XmlElement(name = “measurement”, type = MeasurementStringInteger.class)})private List<M> measurement; public List<M> getMeasurement() {if (measu

  • ajaylouis
    multithreading dynamic blackberry
    hi i am developing a bb 7 native APP that capable of loading image and content dynamically from url.Here is the code that i usedpackage mypackage;import net.rim.device.api.system.Bitmap;import net.rim.device.api.system.Display;import net.rim.device.api.ui.Color;import net.rim.device.api.ui.Field;import net.rim.device.api.ui.Graphics;import net.rim.device.api.ui.Manager;import net.rim.device.api.ui.UiApplication;import net.rim.device.api.ui.component.BitmapField;import net.rim.device.api.ui.compo

  • Johny Jaz
    php html web-services rest dynamic
    This question is as an extension to my previous question here: “Is this web service Restfull” to an attempt to better understand the concept of a Rest Web Service. I read almost everything there is to be read about Rest and yet i am not able to understand if a certain Web Service is Rest or not , or why its not. The way i see it , everything is and is not Rest depending on the point of view…I read in a very interesting article something that may at last make me understand what is Rest. I read

  • benjimix
    java dynamic controller compilation
    I’ve got an unusual problem (well, I think that it is unusual). I need to be able to upload an uncompiled Java source file via a web interface and have the receiving controller compile it and execute a method on that compiled class.I have come some way with it – I can upload the file, and compile it successfully. However, no matter what I try I can not load the (new) class definition and instantiate it. I keep getting java.lang.ClassNotFoundException exceptions thrown.Here is my code;String fil

  • Andras Zoltan
    c# .net dynamic
    I have a type ConfigValue that exposes a dynamic interface via an implementation of IDynamicMetaObjectProvider and custom DynamicMetaObject instance.An instance of this type can be seen, of course, as it’s native type – analogous to an XML Element – but it can also be seen as an instance of any other object type, according to the contents of the XML and what kind of object it builds (it’s a proprietary IOC built by little old me).So <value>10</value>Can be seen as a ConfigValue but a

  • Metalhead89
    java dynamic properties log4j
    I want to change the path and file name of my log4j logfile dynamically.I have read a lot of pages and nearly every tell me that I should use system properties like here: how to change the log4j log file dynamically?So my log4j.properties file looks like this:log4j.logger.JDBC_LOGGER=INFO,jdbcTests log4j.additivity.JDBC_LOGGER = falselog4j.appender.jdbcTests=org.apache.log4j.FileAppender log4j.appender.jdbcTests.File=${my.log} log4j.appender.jdbcTests.layout=org.apache.log4j.PatternLayout log4j.

  • Santosh
    sql oracle dynamic types procedure
    We have created Oracle Table type. And we have created an array of it. This is done as we dont know how many values can come which may be too much for a IN clause in sql query.–Code Snippet —–create or replace TYPE “INPUTCODE” as object (pc varchar2(100) )create or replace TYPE “INPUTCODEARR” IS TABLE OF inputcode;create or replace PROCEDURE “TEST_PROC” (testCodes IN inputcodeArr, timeHorizon IN NUMBER, p_recordset OUT SYS_REFCURSOR) AS var_sqlStmt VARCHAR2(4096); BEGIN var_sqlStmt := ‘s

  • Californicated
    c# .net c#-4.0 dynamic .net-4.0
    I am using dynamic keyword to work with an outside assembly and it works fine as far as accessing it’s methods and primitive type members are concerned. So for example my class dynamically loaded class looks like followig:public class Student {public bool IsGood { get; set; }public StudentType St { get; set; }public University University { get; set; } }I can dynamically load the object from assembly by doing something like:var assembly = Assembly.LoadFrom(“//path”);Type type = assembly.GetType(“

  • Konpon96
    c++ arrays function pointers dynamic
    In main function of my program I’ve created dynamic array with number of elements specified in variable(after calculations array is deleted):cin >> bok;double **macierz; macierz = new double *[bok]; for(int i = 0; i < bok; ++i){macierz[i] = new double[bok]; }Array macierz (matrix in Polish) is used to calculate it’s determinant with another function I’ve written:#include <iostream> #include <conio.h> #include <string> #include <math.h>double determinant(double b[

  • Rachel
    javascript dynamic combobox options
    I have a combo box with one option hard coded. I will add the remaining options dynamicallyCombo box with hard coded option:<select id=”connectionname” class=”connectionname” onchange=”display();”><option>—Select—</option></select>Javascript function to create combo box options dynamically:function showDbDlg(){var newar=new Array();try{var xhrArgs = {url: “./ReadDBDetails”,content: {MODE:”DBNAMES”}, handleAs: “text”,load: function(response) {var dbNames = response.tri

  • julian guppy
    mvc iis dynamic internet-explorer png
    I have a curious problem with IE, IIS 6.0 dynamic PNG files and I am baffled as to how to fix..Snippet from Helper (this returns the URL to the view for requesting the images from my Controller.string url = LinkBuilder.BuildUrlFromExpression(helper.ViewContext.RequestContext, helper.RouteCollection, c => c.FixHeight(ir.Filename, ir.AltText, “FFFFFF”)); url = url.Replace(“&”, “&”); sb.Append(string.Format(“<removed id=\”TheImage\” src=\”{0}\” alt=\”\” />”, url)+Environment.NewLine);Thi

  • xx77aBs
    c#-4.0 asp.net-mvc-4 expandoobject
    Is it possible to convert ExpandoObject to anonymously typed object?Currently I have HtmlHelper extension that can take HTML attributes as a parameter. The problem is that my extension also needs to add some HTML attributes so I’ve use ExpandoObject to merge my attributes and attributes that user passes to the function using htmlAttributes parameter. Now I need to pass merged HTML attributes to original HtmlHelper function, and when I send ExpandoObject, nothing happens. So I guess that I need t

  • smartcaveman
    c# .net-3.5 dynamic runtime expandoobject
    How can I imitate the functionality of the ExpandoObject in a .NET 3.5 application with the least overhead? My best lead so far is to use the Lin Fu framework ( http://www.codeproject.com/KB/cs/LinFuPart2.aspx ), but I’m thinking there may be something better.To give a better idea of what I am going for here, my objective is to dynamically create the type from the parameters of a MethodInfo. So, basically I want to turn this:public class ServiceObject{public void Execute(string TransformMeInto

  • talles
    c# anonymous-types expandoobject dynamic-typing
    With dynamic we pretty much have a dynamic pointer, but not exactly a dynamic object. The true dynamic object in C# is the ExpandoObject, but that is a really unknown class for most of people. The expando allows creating and removing members at runtime, much like a hash (similar to JavaScript).Why the ExpandoObject goodness was implemented in a separate class rather than just being, let’s say, implemented as a feature of anonymous types?Maybe that wouldn’t be a good move because the lacking of t

  • Newbie

  • aravind srinivas
    c# properties dynamics expandoobject
    I want to create public object Value { get; set; }public Type Type { get; set; }public string Name { get; set; } public string “user has to give propertyname” {get;set;}at run time as per user requirement . Is it possible to do this in Csharp Using Expandos or Dynamics .I am asking that if i want to set property name in runtime linepublic string “user has to give propertyname” {get;set;} .it must be from xml r sql but i want to set property name in runtime.

  • Alex
    c# dynamic expandoobject
    I’m getting a JSON object (may contain multiple levels of JSON arrays and such) which I want to translate into an ExpandoObject.I figured out how to add simple properties to an ExpandoObject at runtime as it implements IDictionary, but how do I add nested properties (for example, something like myexpando.somelist.anotherlist.someitem) at runtime that will resolve correctly?Edit: Currently this works for simple (first level) properties well:var exo = new ExpandoObject() as IDictionary<String,

  • idlackage
    c# sql dynamic parameter-passing expandoobject
    I have some function whose prototype looks kind of like this: public void doThings(string sql, dynamic dParams);It does some kind of SQL querying with those parameters. I didn’t write it but I have to use it. It works fine when I do something like this:doThings(“select * from SomeTable where myval1=@v1 and myval2=@v2”,new{v1 = new Dapper.DbString(){Value = “yay”,IsAnsi = true,Length = 50},v2 = new Dapper.DbString(){Value = “really”,IsAnsi = true,Length = 32}});But not when I first put the dynami

  • jbtule
    c# dynamic expandoobject
    I have some code that works with ExpandoObjects populated by database calls. Invariably some of the values are nulls. When I look at the objects as an ExpandoObject, I see all the keys and values (nulls included) in the underlying dictionary. But if I try to access them through a dynamic reference, any key that has a corresponding null value does not show up in the dynamic view of the object. I get an ArgumentNullException when I try to access it via property syntax on the dynamic reference.I

  • pratap k
    c# .net dynamic expandoobject
    I have build a function:string removeFile(HttpContext context,HttpRequest r){ dynamic d = new ExpandoObject() ;d.ItemCommand = r[“itemId”].ToString();……int res = new PolicyDal().Admin_Kits_AttachFile(d); //sending here the d.on the other class/file:public int Admin_Kits_AttachFile(dynamic d){DbCommand command = _webERPDB.GetStoredProcCommand(“Admin_Kits_AttachFile”);_webERPDB.AddInParameter(command, “@ItemCommand”, DbType.String, d.ItemCommand);The following error occurs:One or more ty

  • dkackman
    c# c#-4.0 dynamic expandoobject
    I would like to dynamically add properties to a ExpandoObject at runtime. So for example to add a string property call NewProp I would like to write something likevar x = new ExpandoObject(); x.AddProperty(“NewProp”, System.String);Is this easily possible?

Web site is in building