Shared Class Across A Web Service Boundary?

Aug 15, 2011

I have a class in a shared library, that I have added references to on both the webservice and the client project. One of the functions in the webservice returns a list of this class.

when I try to cast the return value into a List of the class on the client side, I keep getting an error telling me that a 1-dimensional array of type '<webservice.class>' cannot be converted to type '<sharedlib.clas>'.

The reason that I put the class into the shared library, was because I wanted the webservice to return strongly typed data, but I also have a couple of methods in the class. I dont care about them on the server side, but they are needed on the client side. I figured that this would be the "better" method, since in a shared library it is only declared once for both projects.

View 3 Replies


ADVERTISEMENT

Use Derived Class Shared Variables In Shared Methods Of Base Class?

Jun 4, 2010

I am trying to add shared members in derived classes and use that values in base classes...

I have base

class DBLayer
public shared function GetDetail(byval UIN as integer)
dim StrSql = string.format("select * from {0} where uin = {1}", tablename, uin)
end function
end class

[Code]..

currently there is error using the tablename variable of derived class in base class but i want to use it i dun know other techniques if other solutions are better then u can post it or u can say how can i make it work? confused...

View 2 Replies

.net - .NET XML Web Service, Consuming Class Not Able To Access Web Service Class?

Mar 21, 2012

I am creating a simple XML web service and have run into something I can't quite explain.My web service class has the following structure :

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel

[code]....

Invoking my method using the built in VS web service test harness works fine. I created another project, in another solution, to test consuming the web service. I added a web reference to my project and set it so I could reference my web service by using "localWS". Then in the page load event of my consuming class I tried to instantiate an object of my web service:

Dim srv As New localWS.MyWS

But there was no "MyWS" type found. There is however a localWS.MyWSSoapClient class. When I use it I can invoke my web methods. My question is, why can't I create a straight up version of MyWS class? In the tutorials I'v read, and in the book I have, example consuming classes for .NET XML web services can instantiate objects of the web service class they are consuming. As a further test I added a new web form to my web service project and from there I was able to instantiate a MyWS class.

View 1 Replies

Create A "shared" Variable That Is Shared With All Instances Of A Class?

Jan 14, 2011

I seem to be drawing a blank. I'd like to create a "shared" variable that is shared with all instances of a class but not classes that inherit from it. For example.Class A: Shared list As New List(Of String): list.Add("A")

Class B Inherits A: list.Add("B")Class C Inherits B: list.Add("C")The end result I'd like is that any instance of A has just A in the list. Any instance of B has A and B in the list. Any instance of C has A, B, and C in the list. I can accomplish it by creating Instance variables, but I have to construct the list for each instance of a class. I'd like to construct it once for a specific point in the Hierarchy and then share it accross other instances of that class.

View 12 Replies

Can't Inherit Shared Properties From A Base Class In A Child Class?

Dec 29, 2010

This is another one of my "I think it's not possible but I need confirmation" questions.I have a base class for a bunch of child classes. Right now, this base class has a few common properties the children use, like Name. The base is an abstract class (MustInherit)Technically, this means that everytime a child class is instantiated, it lugs around, in memory, its own copy of Name. The thing is, Name is going to be a fixed value for all instances of a given child. I.e., Child1.Name will return "child_object1", and Child2.Name will return "child_object2".

View 1 Replies

Windows Service: Multiple Instances Of The Same Service Class?

May 3, 2011

When you create a Windows Service, you create a list of the services you want to start. The default is this:

ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service}

Can you have multiple instances of the same Service class (that bind to different addresses or ports), like this?

ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service("Option1"), New Service("Option2")}

Or will that cause problems? Should we use two different classes instead?

View 1 Replies

Web Service - How To Write Text String Directly To Network Shared Printer

Jan 16, 2012

I have a web service that is currently calling the DOS command copy to put a text file to a specified network share.

This is the code:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data
Imports System.IO
Imports System.Xml
[Code] .....

It appears doing this might be causing some problems and our front-end programmer suggested I see if I can output the stream "output" directly to the network shared printer specified by the SOAP request. Is this possible? This is VS 2010

View 8 Replies

Inside The Service Class, Declare A Class Variable Named Started?

May 8, 2012

Create a class named Service. Inside the Service class, declare a class variable named Started. The datatype of this variable is Boolean.Public Class Service Dim started as Boolean End Class Create a class named Server. Inside the Server class, declare a dynamic array that can contain elements of the type Service.(Note: For convenience, both the array and the variable Started can be accessible from a client program that creates an instance of Server and Service respectively)

Create a constructor for the Service class. When the constructor is executed, it will set the value of the class variable Started to True. Create two new classes: WebServer and DatabaseEngine. Both of these classes inherit from the class Service. Inside the Service class, declare a Sub procedure (method) named Terminate. This method should display the following text Service stopping in a message box when executed.This method can be overridden in classes that inherit from Service class.

Inside both the WebServer and DatabaseEngine class, override the method Terminate inherited from their base class Service. Both methods should first call the base class Terminate method. The messages Web server stopping and Database engine stopping should also be displayed in a message box when the Terminate method for the WebServer and DatabaseEngine are called respectively. These messages should only be displayed if the Started variable inherited from their base class is not equal to False.

Inside the Server class, declare a method named Shutdown. This method does not return any value. When executed, it will call the Terminate method for each of the Service instances (if any) in the arrServices
array. You should call the Terminate method within a For Each loop that loops through the elements of the arrServices array.

In the Sub Main method, create an instance of the class Server. Set the size of the arrServices array in
your Server instance to contain 2 elements. Create first a WebServer instance and then a DatabaseEngine
instance into this array. Call the Shutdown method from your Server instance.

View 7 Replies

Partial Entity Class With Shared Extension Not Associated With 'other' Partial Class In Client Using RIA Services?

Apr 21, 2011

I have extended an Entity Framework 4 entity class with a calculated property in a partial class. This member is not available on the client to which the entities are exposed via WCF RIA Services.when using C# appears to be changing the extension of the partial class file from .cs to .shared.cs. I tried this with my VB.Net solution (.vb to .shared.vb) and got a long list of errors. I believe what happened is that the partial class lost its association with the entity on the client - it inherited from object rather than EntityObject.

My best guess is that this is related to the way that VB.Net handles namespaces.Each project has a 'Root Namespace' which is prepended to anything that is defined within a code file. C# has a 'Default Namespace'which is the namespace into which new types are placed by default - via a namespace statement within the file.The partial class is probably having the client namespace prepended to it which puts it into a different namespace than the entity with which it is associated on the server.Is there any means of extending an entity in such a way that those extensions are available on the client via WCF RIA Services and VB.Net?

View 1 Replies

Adding A Windows Service Class To A Class Library

Feb 14, 2012

I have a class library in VB.NET that does a NET-envelope for an USB device driver.There is only one function of that driver that I could not envelope in a traditional class, but I had to put it in a Windows Service as described here:Sharing a class property (field) between applications.The Windows Service works fine, but I have now two projects for my NET-envelope: the one with the class library, the second with the windows service and I do not like the idea to maintain two distinct projects for the same driver.Is it a good practice (or even if possible) to add a windows service class to a normal class library (without creating its own project as described in the vb tutorial)?I know, in any case I should create a separate setup only for the windows service, but in this way I could have together all the classes that envelope my usb device driver in only one project.

View 1 Replies

Access Shared Variables Of A Class?

Jul 23, 2009

I am making a small application in which i have added a class module and a window forms in vb.net. i want to acess the shared variables and mathods of class without making any object.

View 8 Replies

Best Way To Initialize Shared Members In A Class

Aug 23, 2011

I was looking on the interweb to see if there were any good examples on how to initialize shared members within a class while still initializing instance variables.[code]How do I initialize both instance and shared members without re-initializing the shared members every time an object is created from a class?

View 1 Replies

C# - Reset A Static/shared Class?

May 4, 2009

I've got a shared class (static in C#) which mostly carries some settings data that any class in the application can read and sometimes write. Also there are some static properties which holds some internal states.

Now I want to revert this class to initial stage of it. With all default variables etc. Assume that the user want to reset the current state and start over without restarting the application.

In a singleton model I'd simply renew it with something like this :

Public Sub Reset()
_Instance = New MyClass()
End Sub

However this is not possible in a Shared class. Or should I switch back to Singleton?

View 3 Replies

Class Module Which Is Shared Between The 2 Projects?

Mar 29, 2010

I have no idea what is going on here but it is strange to say the least.I created a new solution in VS2008Pro under windows 7 This solution has 2 projects one for the pc and one for a CE based device.There is one class module which is shared between the 2 projects.In VS2005 under xp this same basic project worked fine but here I am seeing error messages that appear out of no where.

Example the CE portion flags 3 lines initially 1 related to a file i.o function and 2 others related to socket methods. All three of these were supported in VS2005 using framework 2.0 which is the same framework I am using here. This is just the tip of the ice berg however.If I attempt to run the code it runs fine for the pc client and of course not for the CE device. If I make any kind of change, add a line, comment a line or just add a comment I get lots more errors with odd messages that are not even valid.

In one case after I saved it jumped from 3 errors to 30, in another case to 50 and yet another to 144 errors yet the only errors that were present were the original 3 that were flagged.The ide threw errors like Try Catch must end with matching End Try.Get no longer supported ' apparently referring to the binary file get but here it is used as the get portion of the property.Get must end with matching end get.It also started complaining about functions and data types.For example saying "an is not declared" pointing to the word Boolean Or telling me my functions are not declared point to only 1/2 of the function name.

I do not see any errors in the code and it reports no errors in VS2005 under XP.As a test I tryed adding a new property to the project after it was telling me there were 144 errors. I allowed the ide to do most of the work and when I hit enter the errors went back to 3. Then I saved the project and the errors went to 105 pointing first at the new property just created.

View 5 Replies

Derived Class Shared Methods?

Nov 3, 2010

I have a function that 2 derived classes use, but the third doesn't, would it make sense to just leave it in the base class, even though one of the 3 derived classes doesn't use it?The only way I could think of disallowing the third class is to basically create an intermediate class that is derived of the base, then the 2 that use the common function are derived off the second class.

Is it possible to prevent the 3rd class from using the function, while letting the two that are supposed to use it, use it?Does that just seem to go overboard, I mean as long as I don't "try" to call the function from the 3rd class, it shouldn't be a problem, I just was interested if there was a way to prevent it all together without a lot of hassle.

View 2 Replies

Library Of Functions In A Shared Class?

Feb 11, 2009

I have large group of functions that I would like to store in basically a library and simply call the functions from the controls on my forms. Back in VB 6 I would have done this with a module, but now I have been told that a Public Class is the correct way in .NET. How should I go about doing this?

View 2 Replies

Shared Class With Generic Methods?

Jan 28, 2010

I have created a Interface and a couple classes that implement this Interface. I am in the process of developing a Shared Class that utilizes the functions that each of the individual classes have, due to the interface implementation.What i need to know is how do i develop this Shared Class so that way each of the methods within it are restricted to a single data type. This single data type needs to be restricted to any class that has implemented the Interface.

Some examples:

Public Interface IVector(Of T)
Sub Add(ByVal v2 as T)

[code]....

As you can see it would allow me to develop one form, since i have standardized the required Subs/Functions for any class the implements the IVector interface. As i am still in developement, i was wondering if my current understanding of the method generics is correct in its current form or what i would have to do to make the Generic Shared Class work in the fashion that i am looking for in the example implementation.

View 6 Replies

Use Shared Property With Class Inheritance?

Jan 12, 2011

I have a base class which defines a shared readonly property like this[code]...

View 5 Replies

VS 2008 - Getting Final Value From Shared Class

Dec 4, 2009

I am having trouble trying to get my shared class final value

Class name : Encryption
Public Shared Sub PassEn(ByVal PassTxt As String)
Dim strText As String = PassTxt
Dim salt As String = "61651616516161651615"
Dim bytHashedData As Byte()
[Code] .....

I am trying to call this from the call and get the return hash but when I try to make a global variable it doesn't allow it. How would I call this and get "HashValue" on to a textbox on my form.

View 4 Replies

Writing Shared Subroutines In A Class?

Dec 8, 2009

AdamSpeight2008, on 19 Jul, 2008 - 10:50 AM, said:Labels You have a label on a form and If you're using Label1.Caption = "Text for label" it's VB6 If you're using Label1.Text= "Text for label" it's VB.Net Buttons You have a button on a form. To set the text on the button.You're using Button.Caption= "Text on button" it's VB6 You're using Button.Text="Text on button" it's VB.Net

View 2 Replies

.net - Enforcing Using The Class Name Whenever A Shared Member Is Accessed?

Jan 20, 2010

We have a coding standard that says all shared (static) fields and methods must be called with the class name. E.g. NameOfClass.whatever Is there a tool that we can use to check this is in fact the case? (Likewise for modules) I should have make it clearer we are using VB.NET.

[Code]...

View 5 Replies

Access Of A Shared Member [...] In Custom Class?

Jun 9, 2012

I have a custom class called "Time" with the following function, for determining if one Time equals another Time.

Public Shared Shadows Function Equals(ByVal Time1 As Time, ByVal Time2 As Time) As Boolean
Dim x(2) As Integer
x(0) = CInt(Time1.Hour)
x(1) = CInt(Time1.Minute)

[code].....

Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.I know it shouldn't do any harm, just let the compiler skip evaluation, but is it a way of getting rid of this warning?

View 6 Replies

Accessing A Public Shared Variable From A Different Class?

Jan 10, 2012

I currently have two forms, and I need to share the value of a variable in one of them.

I declared the variable to be 'Public Shared', and assigned a value to it. However,

when I inspect the value it appears as 'Nothing'. Here is the snippet:

Public Class A
Public Shared sVar As String = Nothing
Private Sub A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

[Code]....

View 4 Replies

Call A Shared Method In A Loaded Dll Using Class Name?

May 8, 2012

[code]...

Dim ass as Assembly = Assembly.LoadFile("sample.dll")

Now, I want to call the shared method using the class name.

View 1 Replies

Calling Shared Methods From .NET Class Library In VB6

Jan 25, 2010

I have the following class in a .NET class library:

Code:
Public Class JasonTest
Sub New()
End Sub

[Code]....

The .AddNumbers call works fine, but the AddStrings call yields the error 'Object doesn't support this property or method'.

Is there any way to call a shared method from .NET in VB6? I was unable to find any documentation on this.

View 5 Replies

Replace A Module With A Class And Shared Member?

Mar 17, 2010

I want to replace the Public Declarations that I currently store in a Module with a Class.Currently in my Module I have a declaration like this:

Public SetPath As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments

How do I get the same functionality from a Class?

Public Class Audits
Private _SetPath As String
Public Property SetPath() As String

[code]....

I know I can reference the SetPath in code by doing a Dim aud as New Audit so my question is this. Where is the correct place to put the

= My.Computer.FileSystem.SpecialDirectories.MyDocuments

And is this an good example of a member that should be shared? If so does both the Private and the Public need to be shared. I just started using Refactor Pro and it almost always is recommending that I make all members shared. Is there ever a good reason not to do so?

View 6 Replies

Shared Class Field In Visual Basic

Jul 26, 2011

I have a class, MyClass, declared as public, with a Shared method test():

[Code]...

If I comment out Response.Write MyClass.test(), everything works fine and I can use the Class - however, trying to access the Shared method, I get the following error: Local variable 'myClass' cannot be referred to before it is declared Any pointers as to what I am doing wrong?

View 1 Replies

VS 2008 - (Shared Class) Select Case

Dec 5, 2009

Im trying to get pass len from a shared class but when i call it. I used a case to select how long the pass len is but it doesnt select any case.

class name : PassLenCL

Public Shared Function PassLen(ByVal PassTxt As String)

Dim TextLen As Integer = PassTxt.Length

[CODE]...

View 3 Replies

.net - Fetch A Shared Member From A Class When It Is A Generic Type?

Nov 4, 2011

I have a bunch of classes that all contain a Shared ReadOnly Dictionary. If I want to access that Dictionary when the class is a generic type (such as when I have a wrapper function that takes T as an interface that all of these classes implement), what's the way to do it?

I want to do something like GetType(T).GetMember("Dict"), but that will return a MemberInfo type, and that cannot be cast to a Dictionary of my defined type(s). For calling functions this way, one can use a delegate + CreateDelegate + GetMethod. But there doesn't seem to be an equivalent Create*for GetMember stuff. Or am I missing something?

If I plug the GetMember call into the immediate window, and then use a subscript as if it is an array, then the debug output says I am getting a Dictionary back. But if I use that same approach in the actual function that I am trying to write, then I get an error about System.Reflection.MemberInfo cannot be converted to Dictionary(X, Y)

View 2 Replies

Class Referencing - Form4.vb Doesnt See The Shared Class1

Aug 12, 2011

I have class file class1.vb with 3 classes class1 , class2, class3. a class file class10.vb with class10 class11 class13

I declared class 1 public and declared a public shared new instance of class11 in class1 at the top

All classes in class1.vb can use this shared instance, but a form4.vb doesnt see the shared class1.(new instance of class11)

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved