Return An Object As The Return Value Through A RealProxy Transparent Proxy?
Oct 7, 2010
I'm working up a system where I plan on using RealProxy objects to enable intercepting method calls against a set of objects, handling the call, and then returning appropriate results. This works just find for simple return types like strings or ints, but I can't seem to return objects from the RealProxy.Invoke method. Everything works. I get no errors, but the returned value is always NOTHING, instead of an object.
I've worked up the smallest sample code I could, and have included it below. Essentially, just call RPtest and single step through. The code creates a simple object, RPTestA, with a string field and an object valued field It then retrieves the string
Each one of this functions returns a List of entities. If I call this functions individually they return their values ok. But what I want is to make only one call to the service and no several! I want to be able to receive it in another application like this:
I'm connecting my program to some external code. I'm setting it up so that the external code can instance objects and I've come across a problem. I've created this function here:
[Code]...
I'm trying to create a System.Diagnostics.Process object. For what ever reason though, it always return Nothing instead of the object. Does anybody know what I'm doing wrong? I'm doing this in VB.net so all .net responses are accepted :)
I have an interface that describes an specialized list in my application...
[Code]....
Is there a way to make an interface serializable, or am I going to have to convert each of my objects into a concrete class implementing the interface, and then return that class?
I have a class i've called "buttons", which passes in 1 variable, the button text, and then returns a new button with that text. however, i do not know how to get the class, when called to return a button.
similar to how 'toString' works, except it would return a button object instead of a string. (im not sure how toString works in vb.net. in java it is automatically called when you call the new class, so newclass and newclass.toString(); return the same) [code]...
I'm trying to return an object from a function. E.g. Ive got a function populateDog that returns Dog. So in my aspx class I want to be able to be able to pass in Lassie as the name of the dog(I have a dog class) and have the function return the object with the data it populated. [Code] The idea was to have a database and I would eventually pass in an ID to query results and return it.
I 'm new to programming and to vb. So my question could be from misconception about what can i do. How can i pass a string to a "procedure" and get in return a object whith the same name as the string?
I'm needing to go through all the controls on a page, looking for a specific one. We've got a bunch of user controls, a masterpage, content panel, &c.
The basic idea is simple, but once I find the control I want, say five 'layers' in, the control is returned only one level.
I know I can do something cheesy like having a private variable and assigning the control to that down in the rabbit hole, but I figure there must be a more official method of doing this.[code]...
I have the following linq query which returns a Report Object; yet I need to explicitly set the value of one of its proprties from another column. [code]...
I'm writing a solution where the data entities are passed to clients using datasets through a WCF service, with nHibernate as ORM. My predecessor has written some translator classes, converting datasets to entities and vice versa. In most cases he's declared the return object as a parameter for the object.
For example:
Public Shared Function CreateEntity(ByVal ds As DataSetObject, ByVal entity As EntityObject) As EntityObject Dim row As ds.EntityObjectRow = ds.EntityObject(0) entity.Id = row.Id
[code]....
He's not with the company anymore, so I can't ask him why he's done it this way. Hence my question here. Is there some performance gain, or traceablity thing with nHibernate by using the first implementation rather than the latter?
I'm making a Visual Basic GUI application to display whether a number of my ports are open for people to know whether things like my website and my Minecraft server are open.My problem is I have absolutely no idea how to do this in Visual Basic.Basically, I'm asking for something which sends a signal to an IP with a specific port, if it is open then return true, if it's closed, return false. Similar to: http:[url]....
I am using TPT modeling and writing the EDMX by hand as our data model is much more complex than the designer can support. My model includes a ProjectObject which has a dependent object name Project. When I query ProjectObject.OfType(Project) using Linq to SQL, I receive back data in all the fields that are inherited from ProjectObject, but no data in the fields that only in Project. I have ran a SQL Server Trace and captured the actual SQL and ran it using SSMS and it returns data there, so I am relatively certain the data is being passed back, but it seems to be getting lost somewhere in EF. Everything appears to be ok in my model, but . . .
I'm creating my Data Access Layer and I want to return my object but not all the fields so this is the code i'm using
CODE:
I then call this method in the Business Logic Layer
CODE:
lastly I try to call in in my user interface and bind it to a DataGridView
CODE:
But I keep getting this error: Unable to cast object of type 'System.Data.Linq.DataQuery`1[VB$AnonymousType_0`3[System.String,System.String,System.String]]' to type 'System.Collections.Generic.IEnumerable`1[PP_DAL.DCProposal]'.
Ok, just needing a 2nd set of eyes looking at this to make sure the error isn't something else other than my LINQ code here. Here's the function class itself:
Public Function GetJacketByPolicyID(ByVal jacketID As Int32) As tblPolicy Dim db As New DEVDataContext() Dim j As tblPolicy = db.tblPolicies.Single(Function(p) p.policyNumber = jacketID) Return j End Function
and here is the code which calls this class function in the web control form itself:
Dim p As tblPolicy Dim j As New Jackets() p = j.GetJacketByPolicyID(3000050)
For some reason it's flagging the 2nd line in the GetJacketByPolicyID function saying the specified cast is not valid. So I'm guessing it's something I'm doing wrong. I'm sure the tblPolicy/tblPolicies class works right since I can create a new instance of a tblPolicy and set a few variables by hand and return it, so that's not it. I've also checked the datarow I'm fetching and there's no null values in the record, so that shouldn't be it either.
So I've run into a case where I have a class that can store either a string or a numeric value, and I want a single property to return one or the other (it would be a failure for both to be set). I'm using a custom generic class to deal with the numerics (so I can use signed, unsigned, and nullables), and will be storing the string in a separate variable.
In theory, if overloading could be done based on the return type, I could do this quite easily. But .NET currently disallows this. So I am wondering if there is some other really-far-out-there trick (outside of MSIL generation via Reflection.Emit) that could accomplish the same thing.
I'm open to ideas via delegates, pointer dereferencing, generics, mystical rites, etc. Also interested in any thoughts or pros/cons of such possibilities as a learning tool. If using a standard Object is the only way to achieve what I want, then that's fine with me. But It's difficult to find the correct set of keywords to hunt down this kind of capability on Google, so I thought I'd ask here before I moved on to doing something else on the project.
After reading all the examples for list of T exists and Find and find first, none show how to handle multi-property objects. Below is bare bones example maybe someone could flesh out to show how this should be done.
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim DatePriceList As New List(Of DateAndPrice) DatePriceList.Add(New DateAndPrice(Date.Parse("1/1/2000"), 10.12)) DatePriceList.Add(New DateAndPrice(Date.Parse("1/2/2000"), 11.12))
I would like the following function to return Nothing if the element with the specified key is not in the collection. Instead, it returns an error - something to the effect of "no element found"
Public Class MyCollection Inherits System.Collections.ObjectModel.Collection(Of MyType) Public Function FindByActivityKey(ByVal searchValue As Integer) As MyType
I can easily read the value of the updated_time with:
post.updated_time
However this returns the count of items in the collection, not the value of the "count" property in the json object.
post.comments.count
Is it possible to get the value of post.comments.count without it using the "count" keyword?
I should note that the JSON is much larger than this. If there are actually comments there is another collection of the actual comments so something like post.count(0) would not work in that case.
In order to return a value from a VB.NET function one can assign a value to the "Functions Name" or use "return value." I sometimes see these inter-mixed in the same function. Personally, I prefer the return. My question is, what is the internal difference, if any, between the two?
Dim mappath As MatchCollection = r.Matches(randomstring) when changed to derp doesn't work. Derp does work when you put it in a message box too. I tried .tostring. I don't know what to do D:) I tried tostring, I tried converting with cstr but it say's it cannot return a value, what do?