473,224 Members | 1,657 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

How to alias 2 classes in c#

WT
Hello,

Here is my pb: I have a group of classes in 2 namespaces which are exactly
simlilar.
Theses classes are generated by Visual Studio when inserting a Web
Reference, having 2 versions of a web service with a total compatibility in
data structures, I need to write a program able to deal indiferently with
any version of the web service.
Writing a compatibility layer is very long and need lot of unecesary
create/delete to transfert from one object to its correspondant object and
call the web service api without having compiler refusing.

It could be very usefull to have something abale to say 'class1 is an alias'
of class2 and to be able to cast directly object of class1 to class2 and
vis-versa. All methods and properties of the class having same names and
type.

Any idea ?

Thanks, CS.

Jun 27 '08 #1
4 1487
Well, if you use wsdl.exe at the command-line, you can use /sharetypes
to do this, specifying multiple urls (or other sources) to inspect.

That do?

Marc
Jun 27 '08 #2
Hi CS,

For ASP.NET webservice's client proxy, if you use "Add WebReference" to
create the proxy, it will always create a new copy of the custom types(even
if you have add multiple reference to services that use the same custom
types).

As Marc suggested, you can use wsdl.exe commandline utility to generate
the proxy, this tool has "SharedType" option that will indicate the proxy
generation to share types.

#Web Services Description Language Tool (Wsdl.exe)
http://msdn.microsoft.com/en-us/libr...b6(VS.80).aspx

#Framework 2.0 - WebServices Shared Types
http://weblogs.asp.net/israelio/arch...04/346337.aspx

#Proxy Type Sharing
http://asp.dotnetheaven.com/webservi...peSharing.aspx

So far for webservice, the type sharing support is still limited. In WCF ,
type sharing between multiple clients or even existing class library
asemblies are much more enhanced.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "WT" <WT@newsgroups.nospam>
Subject: How to alias 2 classes in c#
Date: Thu, 5 Jun 2008 15:29:31 +0200
>Hello,

Here is my pb: I have a group of classes in 2 namespaces which are exactly
simlilar.
Theses classes are generated by Visual Studio when inserting a Web
Reference, having 2 versions of a web service with a total compatibility
in
>data structures, I need to write a program able to deal indiferently with
any version of the web service.
Writing a compatibility layer is very long and need lot of unecesary
create/delete to transfert from one object to its correspondant object and
call the web service api without having compiler refusing.

It could be very usefull to have something abale to say 'class1 is an
alias'
>of class2 and to be able to cast directly object of class1 to class2 and
vis-versa. All methods and properties of the class having same names and
type.

Any idea ?

Thanks, CS.

Jun 27 '08 #3
WT
Thanks to Marc and you Steven, I will do a try.
Something like
using class2 = class1 would have also been usefull.

CS
"Steven Cheng [MSFT]" <st*****@online.microsoft.coma écrit dans le message
de news:4T**************@TK2MSFTNGHUB02.phx.gbl...
Hi CS,

For ASP.NET webservice's client proxy, if you use "Add WebReference" to
create the proxy, it will always create a new copy of the custom
types(even
if you have add multiple reference to services that use the same custom
types).

As Marc suggested, you can use wsdl.exe commandline utility to generate
the proxy, this tool has "SharedType" option that will indicate the proxy
generation to share types.

#Web Services Description Language Tool (Wsdl.exe)
http://msdn.microsoft.com/en-us/libr...b6(VS.80).aspx

#Framework 2.0 - WebServices Shared Types
http://weblogs.asp.net/israelio/arch...04/346337.aspx

#Proxy Type Sharing
http://asp.dotnetheaven.com/webservi...peSharing.aspx

So far for webservice, the type sharing support is still limited. In WCF ,
type sharing between multiple clients or even existing class library
asemblies are much more enhanced.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
>>From: "WT" <WT@newsgroups.nospam>
Subject: How to alias 2 classes in c#
Date: Thu, 5 Jun 2008 15:29:31 +0200
>>Hello,

Here is my pb: I have a group of classes in 2 namespaces which are exactly
simlilar.
Theses classes are generated by Visual Studio when inserting a Web
Reference, having 2 versions of a web service with a total compatibility
in
>>data structures, I need to write a program able to deal indiferently with
any version of the web service.
Writing a compatibility layer is very long and need lot of unecesary
create/delete to transfert from one object to its correspondant object and
call the web service api without having compiler refusing.

It could be very usefull to have something abale to say 'class1 is an
alias'
>>of class2 and to be able to cast directly object of class1 to class2 and
vis-versa. All methods and properties of the class having same names and
type.

Any idea ?

Thanks, CS.

Jun 27 '08 #4
Sure. If you encounter any other problem later, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
--------------------
>From: "WT" <WT@newsgroups.nospam>
References: <6F**********************************@microsoft.co m>
<4T**************@TK2MSFTNGHUB02.phx.gbl>
>In-Reply-To: <4T**************@TK2MSFTNGHUB02.phx.gbl>
Subject: Re: How to alias 2 classes in c#
Date: Fri, 6 Jun 2008 06:51:51 +0200
>
Thanks to Marc and you Steven, I will do a try.
Something like
using class2 = class1 would have also been usefull.

CS

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John | last post by:
Hi all, I am doing the change from having worked in Oracle for a long time to MS SQL server and am frustrated with a couple of simple SQL stmt's. Or at least they have always been easy. The...
10
by: Kimmo Laine | last post by:
Hi, i try to define alias and then use it in another file like this: // ---------- // file: a.cs using System; using MyAlias = MyNamespace.MyClass;
7
by: Lance | last post by:
Is there any way to create an import alias that applies to the entire project? For example, lets say that I want "VB" to represent Microsoft.VisualBasic throughout my entire project. Is there...
2
by: KK | last post by:
Hi, How can I create alias for a class object? Please go thru this program to understand the motivation. Class Name; Class Country{ Name list; /*My intension is to have: list - usa list - uk
6
by: Maxim | last post by:
Hello, everybody! I'd like to make global type alias. If I used c++ I would write the following code to create a global type alias: typedef SomeType MyAlias; I've found that using keyword...
56
by: Peter Olcott | last post by:
I am trying to refer to the same std::vector in a class by two different names, I tried a union, and I tried a reference, I can't seem to get the syntax right. Can anyone please help? Thanks
59
by: peter.tornqvist | last post by:
Maybe I'm stupid or maybe I am missing the obvious, but I can't find a way to define a type alias in C# for primitive types (class and interfaces I can inherit from, no problem). I.e I want to...
9
by: lnatz | last post by:
Hi, I am writing a shell for a class and I have to write some builtins such as alias and cd. I am having some trouble with alias. I anyone could give me some ideas about how to do it I would...
1
by: dwasler | last post by:
Try every thing I know to remove this alias I know there been other posting I read each one none seem to work. Thank You DLWasler dwasler@yahoo.com OS Window db2 V 8.2.X
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.