wcf,rest,reflection,silverlight-4.0,reflection.emitRelated issues-Collection of common programming errors
user3220513
c# c++ wcf
I run a WCF-Service in IIS-Express 8.0 and use Visual Studio 2010. The service calls a C++/CLI Wrapper, which calls the native C++ dll. If I start the client (C# Application), I am able to debug client, service and wrapper. If I try to step from the wrapper into the native C++ – Code, I fail. But from the return code I can see, that the function in the native C++ dll was called. In Addition: The native C++ dll is delay loaded from a path, I configure in the service via Global.asax-File. I also
JPReddy
c# winforms proxy wcf
I have a WCF service hosted on a server. A client application is accessing the service on a windows 7 machine. There are two users on Windows 7 machine. Windows application is a installed through Clickonce so separate instance will be there for two users. When userA accessing the service through Winforms application it works fine, but when userB on the same machine trying to access it throws following exception: Communication Exception: The remote server returned an unexpected response: (417) Ex
Kev
c# .net wcf silverlight
When I pass a list of objects out of my silverlight app using WCF everything works fine until the List grows too big. It seems that when I exceed 80 items I get the error: The remote server returned an unexpected response: (404) Not FoundI’m presuming that it’s because the List has grown too big as when the List had 70 items everyhing works fine. Strange error message though, right?In the config file I change the maxBufferSize to the highest value that it will accept but still I can’t have more
Ocelot20
c# asp.net wcf flex wcf-rest
I have the following method in my WCF service:[OperationContract] [WebInvoke(Method = “POST”, BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml)] public int GetOne(string param1, string param2) {return 1; }I am sending xml from a Flex application, and it takes an object that looks like this: { param1: “test”, param2: “test2” } and turns it into the following request:POST http://localhost:8012/MyService.svc/GetOne HTTP/1.1 Accept: ap
Zenox
wcf rest webchannelfactory
From my understanding the following should properly throw a custom error from a WCF Rest service:[DataContract(Namespace = “”)] public class ErrorHandler {[DataMember]public int errorCode { get; set; }[DataMember]public string errorMessage { get; set; } } // End of ErrorHandlerpublic class Implementation : ISomeInterface {public string SomeMethod(){throw new WebFaultException<ErrorHandler>(new ErrorHandler(){errorCode = 5,errorMessage = “Something failed”}, System.Net.HttpStatusCode.BadReq
Abhishek Mathur
c# wcf post java-me
I have this WCF service:[ServiceContract]public interface IService{[OperationContract][WebInvoke(Method = “POST”, UriTemplate = “/PostComments”, BodyStyle = WebMessageBodyStyle.Wrapped,RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]string PostComments(string ItemId, string Comments, string FullName, string Location);}[DataContract]public class Comment{[DataMember]public string ItemId { get; set;}[DataMember]public string Comments { get; set;}[DataMember]public str
Omar Kooheji
c# .net wcf
I’ve written a simple Application that utilizes WCF to communicate between client and server. When I run it locally it works fine, however when I run the server and client on two different boxes I get the following exception:Unexpected error occured, while getting the group names from the VDN server System.ServiceModel.Security.SecurityNegotiationException: The server has rejected the client credentials. System.Security.Authentication.InvalidCredentialException: The server has rejected the clien
Louis Boux
wcf monotouch protocol-buffers protobuf-net
I have been trying to use protobuf-net with MonoTouch but I have no idea how, and despite having heard that it is possible, I haven’t been able to find any tutorial or any example that actually work.It was confirmed by Marc Gravell on his blog that it does work on MonoTouch. I have also looked through the blogs of the two people he states in this article, but I haven’t found anything related to protobuf.Having no lead on the subject, i decided to download protobuf-net and try it out anyway. So I
Corey Burnett
wcf rest http-status-code-405
Can anyone shed any light on this? I feel like I have wasted the entire day today hunting and searching the internet for any scrap of information about how to do this. I have created a very simple WCF RESTful service. It is basically a proof of concept. I have a simple database behind it and I am just trying to get it working so that I can view, create, update and delete items. Right now I only have view and update working. I’ll tackle create later. For now I can’t figure out why the dele
Jørn Schou-Rode
session streaming wcf nettcpbinding
I’m trying to set up a WcfService with the use of NetTcpBinding. I use Transfer mode Streamed since I will transfer large files. I need to use Session, and I have read that NetTcpBinding supports this, but when I turn it on like: SessionMode=SessionMode.RequiredI get the error:System.InvalidOperationException: Contract requires Session, but Binding ‘NetTcpBinding’ doesn’t support it or isn’t configured properly to support it.Does anyone know what I have to do to make NetTcpBinding work with sess
user1189762
ruby-on-rails rest backbone.js ember.js frontend
I already know that ember.js is a more heavy weight approach in contrast to backbone.js. I read a lot of articles about both.I am asking myself, which framework works easier as frontend for a rails rest backend. For backbone.js I saw different approaches to call a rest backend. For ember it seems that I have to include some more libraries like ‘data’ or ‘resources’. Why are there two libraries for this? So whats the better choice? There arent a lot of examples to connect the frontend with the ba
avanderw
java rest jersey
I know there are a few questions regarding the libraries you can use to do RESTful services in Java, but what is the value in using them against vanilla implementations. I mean, if i was looking to create the url structure described by Wimwww.example.com/images www.example.com/images/id/num www.example.com/images/tag/num www.example.com/images/tag/num/num/numWould it not be easier (for future developers) and faster (to implement and learn) to map the url pattern /images to a servlet and have a l
Zenox
wcf rest webchannelfactory
From my understanding the following should properly throw a custom error from a WCF Rest service:[DataContract(Namespace = “”)] public class ErrorHandler {[DataMember]public int errorCode { get; set; }[DataMember]public string errorMessage { get; set; } } // End of ErrorHandlerpublic class Implementation : ISomeInterface {public string SomeMethod(){throw new WebFaultException<ErrorHandler>(new ErrorHandler(){errorCode = 5,errorMessage = “Something failed”}, System.Net.HttpStatusCode.BadReq
Alpha Hydrae
api rest inheritance polymorphism
I have an object hierarchy I need to expose through a RESTful API and I’m not sure how my URLs should be structured and what they should return. I could not find any best practices.Let’s say I have Dogs and Cats inheriting from Animals. I need CRUD operations on dogs and cats; I also want to be able to do operations on animals in general.My first idea was to do something like this:GET /animals # get all animals POST /animals # create a dog or cat GET /animals/123 # get animal 123
Corey Burnett
wcf rest http-status-code-405
Can anyone shed any light on this? I feel like I have wasted the entire day today hunting and searching the internet for any scrap of information about how to do this. I have created a very simple WCF RESTful service. It is basically a proof of concept. I have a simple database behind it and I am just trying to get it working so that I can view, create, update and delete items. Right now I only have view and update working. I’ll tackle create later. For now I can’t figure out why the dele
Bill the Lizard
rest client web-services hateoas
So by now I’m getting the point that we should all be implementing our RESTful services providing representations that enable clients to follow the HATEOAS principle. And whilst it all makes good sense in theory, I have been scouring the web to find a single good example of some client code that follows the idea strictly.The more I read, the more I’m starting to feel like this is an academic discussion because no-one is actually doing it! People can moan all they like about the WS-* stack’s ma
MHero
java android spring rest
I’m trying to POST to a rest service using spring for android(I’m new at this)The restful service has this structure@POST @Path(“/ider”) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public SearchOutRO hashTrackInJSON(SearchInRO in);with(shortened object code):public class SearchInRO implements Serializable {private Double latitud;private Double longitud; }public class SearchOutRO implements Serializable {private Integer searchId; }so I’m trying this(from android)St
ragulka
json api node.js rest google-chrome
I need to test my REST API backend that accepts JSON with the Advanced REST Client or Postman for Chrome. But I am running into issues: I can only send the request using the built-in form and using Content-Type: application/x-www-form-urlencodedBut this will not work since I have embedded documennts, for example, I need to POST this: {title:”Awesome post!”, tags: [“blue”, “jeans”] }This is not possible with the built-in forms of either Chrome extension.When I select Raw Body and insert the conte
user2169261
.net wcf rest
I have suddenly started facing the below issue. My REST Service no more works. It was working sometime ago and I didn’t make any changes to config. As of sudden, it is behaving weird. I used WCF Test client to check the issue and strangely, the service method gets called 6 times and finally throws the below error.Error: Cannot obtain Metadata from http://localhost:49796/Test.svc/GetInformation?memberId=1 If this is a Windows (R) Communication Foundation service to which you have access, plea
theUtherSide
javascript json api rest mime-types
Making a call to a REST API by adding a <script> tag to the DOM. I need to set the type to application/json to avoid a JS error. A JSON object is returned by the API, and using type=text/javascript periodically gives a syntax error because the browser is expecting JavaScript but instead reads JSON. Depending on the browser, it will give an “Unexpected token :” error on the first colon, or “SyntaxError: missing ; before statement {“registry_company_name”:”This block does not perform the A
Ender Muab’Dib
android json parsing reflection
I’ve read dozens of post (here and other places) asking for parsing from/to JSON and most people code their exclusive parsers for each class. The usual answer is to use GSON or other libraries but since android supports JSON natively I don’t see the point of use third-party libraries.So I made my own generic JSONParser using Android JDK libraries exclusively. It works fine for any class whose fields are: primitive types, strings, one-dimensional arrays, or other classes. The problem now is to ha
templatetypedef
java reflection proxy classcastexception geotools
So I’m playing with geotools and I thought I’d proxy one of their data-access classes and trace how it was being used in their code.I coded up a dynamic proxy and wrapped a FeatureSource (interface) in it and off it went happily. Then I wanted to look at some of the transitive objects returned by the featureSource as well, since the main thing a FeatureSource does is return a FeatureCollection (FeatureSource is analogous to a sql DataSource and featurecollection to an sql statement).in my invoca
Stefano Ricciardi
c# reflection properties runtime
I am using reflection to populate the properties of an object. These properties have different types: String, Nullable(double) and Nullable(long) (don’t know how to escape the angle brackets here …). The values for these properties are coming from a dictionary of (string, object) pairs.So, for example my class has the following properties:string Description { get; set; } Nullable<long> Id { get; set; } Nullable<double> MaxPower { get; set; }(in reality there are about a dozen prop
ChssPly76
java reflection final
Let’s start with a simple test case:import java.lang.reflect.Field;public class Test {private final int primitiveInt = 42;private final Integer wrappedInt = 42;private final String stringValue = “42”;public int getPrimitiveInt() { return this.primitiveInt; }public int getWrappedInt() { return this.wrappedInt; }public String getStringValue() { return this.stringValue; }public void changeField(String name, Object value) throws IllegalAccessException, NoSuchFieldException {Field field = Test.
Nailuj
c# reflection attributes tdd assert
I have an example classpublic class MyClass{ActionResult Method1(){….} [Authorize]ActionResult Method2(){….}[Authorize] ActionResult Method3(int value){….}}Now what I want is to write a function returning true/false that can be executed like thisvar controller = new MyClass();Assert.IsFalse(MethodHasAuthorizeAttribute(controller.Method1)); Assert.IsTrue(MethodHasAuthorizeAttribute(controller.Method2)); Assert.IsTrue(MethodHasAuthorizeAttribute(controller.Method3));I got to the point whe
James Goodwin
java reflection
Hi What are the advantages and Disadvantages of Reflection in java?
Sergey Berezovskiy
c# .net reflection ado.net
hi,I need to get the ColumnsNames in ‘ResultColumns’ as shown in the image of the quickwatch above.I am not able to get anything inside the ‘query’ bt can access it through the quickwatch as shown.How can i access it.Please Help.Regards, Jaison
om-nom-nom
android scala reflection type-erasure scala-java-interop
I am trying to use the put method of the ContentValues class in the Android API from Scala, but I can’t figure out a way to make Scala narrow down the type of list elements. For example :val a: List[(String, Any)](…) val cv = new ContentValues for ((k,v) <- a) cv.put(k,v)…yields an error that roughly says it can’t resolve the “overloaded put method with alternatives put(String, String), put(String, Int),…”.My intuition is telling me I should probably use reflection, but I can’t figure o
Mihir
java android reflection notifications led
To implement things like canceling calls, clearing missed call notifications ,disabling notification LED and other such complex functionalities I have to rely heavily on Reflection. Will it effect my app in a long run?
Eric B.
java reflection field inner-classes
I’m running into a strange result here and am not sure if it is a bug in Java or it is expected behaviour. I have an inner class on which I’ve used reflection to get the declared fields (class.getDeclaredFields()). However, when I loop over the list of fields and check the individual types, the “this” field returns the outerclass and not the inner class.Is this expected behaviour? It seems quite odd to me.Ex:import java.lang.reflect.Field;public class OuterClass {public class InnerClass{publi
Michael Younani
c# xml windows-phone-7 silverlight-4.0 xdocument
It’s a Silverlight WindowsPhone Project and I’m trying to create a xml file in the isolatedstorage then I try to read from it, here is the code:using (var file = IsolatedStorageFile.GetUserStoreForApplication()){using (var stream = file.OpenFile(“MainLBItems.xml”, FileMode.Create)){XDocument MainLBItems = new XDocument(new XDeclaration(“1.0”, “utf-8”, “yes”),new XComment(“This is a comment”),new XElement(“Items”)); MainLBItems.Save(stream); }}The pro
Burf2000
silverlight windows-phone-7 silverlight-4.0 xna-4.0
I have built a simple game in WP7 and I am trying to add background music to it using MediaPlayer. The problem is it just bombs with {“An unexpected error has occurred.”} System.Exception {System.InvalidOperationException}Codetry{MediaPlayer.Stop();// Timer to run the XNA internals (MediaPlayer is from XNA)DispatcherTimer dt = new DispatcherTimer();dt.Interval = TimeSpan.FromMilliseconds(33);dt.Tick += delegate { try { FrameworkDispatcher.Update(); } catch { } };dt.Start();Uri pathToFile = ne
Valentin Kuzub
.net silverlight silverlight-4.0 focus tabstop
I got a control that looks like this , it has several text boxes[1 ][2 ][3 ][4 ]Now in my app those controls are forming a somekind of a matrix like[1 ][2 ][3 ][4 ] [1 ][2 ][3 ][4 ] [1 ][2 ][3 ][4 ]Now I wanted to set 1 3 and 4 IsTabStop = false so user can tab through 2nd textboxes only. After I have done that I found out that 1 3 4 now cannot be focused. And to my surprise in WPF this is not true, so its just another Silverlight unexpected limitation!http://msdn.microsoft.com/ru-ru/library/sys
Nanda
json rest silverlight-4.0
Suppose I have JSON data formatted as:(kind of tree data:){ “nodeData”: [“nodeObject”:{“nodeName”: “Node 1″,”nodeChildren”:[“nodeObject”:{“nodeName”: “Node 1-1″},”nodeObject”:{“nodeName”: “Node 1-2″},”nodeObject”:{“nodeName”: “Node 1-3”, “nodeChildren”:[“nodeObject”:{“nodeName”: “Node 1-3-1″ }]},”nodeObject”:{“nodeName”: “Node 1-4″},”nodeObject”:{“nodeName”: “Node 1-5″, }] },”nodeObject”: { “nodeName”: “Node 2″, },”nodeObject”: { “nodeName”: “Node 3”, }] }in order deserialize th
Myles J
wcf silverlight-4.0
One of our users received the following unexpected error yesterday whilst using our Silverlight app:[Async_ExceptionOccurred] Arguments: Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem.Any idea how I start to investigate this? The problem is intermittent and has so far occurred twice. We are not using a clientaccesspolicy.xml file as the services and web app are on the same server. I have looked at the IIS logs fo
TrueBlueAussie
silverlight silverlight-4.0 ria-services
Hey there, I am clueless in what is causing this but I get an error when my ria service if less than 2 items are been returned, everything works ok if I have 2 or more records been returned.My domain data source looks like this:<riaControls:DomainDataSource AutoLoad=”True”x:Name=”dsEmployee” LoadedData=”dsEmployee_LoadedData”QueryName=”GetEmployees”><riaControls:DomainDataSource.DomainContext><my:TestDomainContext /></riaControls:DomainDataSource.DomainContext></riaCon
Kit
c# silverlight silverlight-4.0 ria
I’m developing a Silverlight 4 RIA application. There is a DataGrid storing data and two buttons: add a new item and remove an item. After creating a new item for the second time the application freezes like this – I’ll explain the strange behaviour below.The scenario of creating a new item looks like this:After clicking, the child window appears. The reference to the domain data source used on the parrent page is being passed to the child window in the constructor. The user chooses a file. The
Charles
c# wcf silverlight-4.0
I am working on a silverlight application. While adding a server referrence, some times the server is returning an error message with out updating its services likeI dint understand why its returning like that, and when I tried to give the same address in a browser its returning the server xml file correctly, and I am able to run the server from another browser also. Can any one give me a suggesstion to overcome this type of exceptions. I also tried by removing queries from my link like “http://
Town
visual-studio-2010 xaml silverlight-4.0
This is an open and shut case which will hopefully save someone a headache in the future.I had the following line in Notepad (via OneNote) that I was pasting into a TextBlock to determine its visibility based on a property:Visibility=”{Binding IsPrinted, Converter={StaticResource VisibilityConverter}}”However, this generated the following error:Unexpected token Comma in Rule: MarkupExtension ::= ‘{‘ TYPENAME @(Arguments)? ‘}’, in ‘{Binding IsPrinted, Converter={StaticResource VisibilityConvert
AnthonyWJones
silverlight silverlight-4.0 font-size
Someone please teach me to fish here…I’m just learning Silverlight and have ran into a few situations where the font size actually used is drastically different than I would expect. There’s probably something conceptual that I’m missing.Case AIn one instance, I have defined a user control that presents a Label to show text. If one clicks on the label, the label (that is in a stack panel, in the user control) is replaced with a TextBox. When used at the top of a page (as in the example below
Vitaliy Kalinin
.net reflection.emit
I am trying to emit following:This is struct which will be included as property to a dynamically emited class:public struct GeoPoint {public double? lat { get; set; }public double? lon { get; set; } }I have to emit following class:public class GeoPointOwner {public GeoPoint GeoPoint{get; set;}public double? Getlat (){return GeoPoint.lat;} }I can’t figure out how properly emit method GeoPointOwner.GetlatHere is my code:var mbGet = typeBuilder.DefineMethod(“Getlat”, MethodAttributes.Public, typeo
Wim Coenen
c# reflection reflection.emit
I am trying to Emit what I thought would be a simple object array that would result in code similar to the below example object[] parameters = new object[] { a, b, };When I write the above code in C# using VS, I get the following IL. As expected this works. .locals init ( [0] object[] parameters, [1] object[] CS$0$0000)However, when I try and Emit IL directly, I only ever get a one index init array. Can someone help tell me where I’ve gone wrong here?Here is the Emit code I’m using:int arraySi
svick
c# dapper reflection.emit unboxing dynamicmethod
Overview (forgive me for being so detailed, but I’d rather it be too much than too little): I’m attempting to edit the Dapper source for our solution in such a way that when any DateTime or Nullable is read from the database, its DateTime.Kind property is always set to DateTimeKind.Utc.In our system, all DateTimes coming from the front end are guaranteed to be in UTC time, and the database (Sql Server Azure) is storing them as DateTime type in UTC (We are not using DateTimeOffsets, we are just
competent_tech
.net vb.net reflection reflection.emit
I’m designing a .NET-Type at runtime by using the Reflection.Emit-Namespace. Currently, I’m about to generate a method which invokes an already existing method in the generating class:Dim AssemblyBuilder As AssemblyBuilder = Nothing Dim ModuleBuilder As ModuleBuilder = Nothing Dim TypeBuilder As TypeBuilder = NothingDim MethodBuilder As MethodBuilder Dim ReturnType As Type = NothingAssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(New AssemblyName(“DynamicAssembly”), AssemblyBuilde
Eric Smith
Simon
c# cil reflection.emit
I have a class called EventConsumer which defines an event EventConsumed and a method OnEventConsumed as follows:public event EventHandler EventConsumed;public virtual void OnEventConsumed(object sender, EventArgs e) {if (EventConsumed != null)EventConsumed(this, e); }I need to add attributes to the at OnEventConsumed runtime, so I’m generating a subclass using System.Reflection.Emit. What I want is the MSIL equivalent of this:public override void OnEventConsumed(object sender, EventArgs e) {ba
svick
.net reflection reflection.emit propertyinfo
Why is the PropertyInfo methods for getting and setting a property so slow? If I build a delegate using Reflection.Emit, it is much faster.Are they doing something important, so that the time they take can be justified? That is… am I missing something by using Reflection.Emit to build delegates instead of usign the GetValue and SetValue of the PropertyInfo (aside of development speed)?PS: Please, give evidence, not only guessing!
Dan Schubel
c# generics reflection.emit
Using C#, I am noticing a significant difference in perfomance when populating a list with instances of a dynamically generated type versus a simple struct. The code below includes 4 different methods for populating a list with 100,000 objects.Each method performs differently:Button1: 15 millisecondsButton2: 31 millisecondsButton3 & 4: 300 millisecondsNote, the code for button 3 & 4 came from this topicCould anyone explain why the dynamically created object is slower?public struct DataRo
Wim Coenen
c# serialization reflection reflection.emit
Is there any way to save an entire class definition for a C# object to a file / data store?I use the [Serializable] tag and ISerializable interface to do this already, but both of these rely on the object definition being in the assembly at run time.What I’m looking for is a solution to the following scenario:1) User creates object MyClass in my software and saves itFor the purpose of this example, MyClass is a stand-alone object that doesn’t rely on any other class in the system:i.e. this could
Megacan
c# reflection reflection.emit
I am generating an Assembly on the fly using Reflection.Emit and then saving it. It contains one Type and a static Main() method in it..NET is kind enough to automatically reference a required assembly. However, in Main(), there is a call to a method from another assembly and it doesn’t get referenced in the standard way.When the assembly is executed, the runtime looks for this assembly and cannot find it, which is a problem.Reflector can detect this and shows this extra assembly under the “depe
Web site is in building