473,657 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Share Class between Windows app and ASP.NET website

All,

I created a class in a windows application and I'd like to be able to
pass an instance of that class as a method parameter to a web service.
The class contains 100 variables. I tried adding a new class to the
web service (using VS Web Developer Express) and recreated the
variables to match what was in the windows application class but when
I try to pass an object as a parameter I'm getting a 'Cannot
implicitly convert from winform.type to webservice.type '.

Is there an *easy* way to share a class between my win form app and
the web service so I can pass objects back and forth?

Thanks in advance.
Jan 8 '08 #1
4 2660
Well, normally the proxy will create an entirely unrelated, meta-data
based type. With WCF there are a few tricks you can pull to share the
type more directly (i.e. without using svcutil.exe, which would do the
same thing as wsdl.exe) - but otherwise I think you have to stick to
treating the metadata version as just that: raw data.

You could perhaps write a utility method to convert between the two?
By copying the properties (either by hand, or by using some tricks
like reflection to do it more gracefully) or possibly (less nice) by
serialization / deserialization . Actually, you might even be able to
add cast operators to your main class (casting to the proxy class)
[not sure if this is a great idea]

Marc
Jan 8 '08 #2
Hi,

If you put that class in a shared dll then both projects can have a
reference to it. Inaddition if the class support a Constructor or a method
that receive all the variables then either program can create an instance
that is the same in both programs. The only thing to note though is that you
will have two instances that will be the same at that point but that can be
modified independently afterwards.

Also take a look at Serialization, it could also solve your problem.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Looch" <lu**********@y ahoo.comwrote in message
news:33******** *************** ***********@v29 g2000hsf.google groups.com...
All,

I created a class in a windows application and I'd like to be able to
pass an instance of that class as a method parameter to a web service.
The class contains 100 variables. I tried adding a new class to the
web service (using VS Web Developer Express) and recreated the
variables to match what was in the windows application class but when
I try to pass an object as a parameter I'm getting a 'Cannot
implicitly convert from winform.type to webservice.type '.

Is there an *easy* way to share a class between my win form app and
the web service so I can pass objects back and forth?

Thanks in advance.

Jan 8 '08 #3
Dear all,

I have a similar problem in a Visual Studio solution with two projects:

Project 1: "Normal" class library which contains public business objects. The DLL created by this project may be called directly by the user (as a DLL assembly).

Project 2: A WCF server containing services where I want to use the *SAME* business objects as parameters in public "ServiceContrac t" functions. (This is important as I do not want to write 2 versions of each business object).

But this seems somewhat impossible, as
1) It seems impossible to add the "DataContra ct"/"DateMember " attributes to objects in BusinessServer. dll, and also
2) It seems impossible to define the business objects in the WCF-server project and have them accessible/exposable by Project 1.

So, HOW TO REUSE BUSINESS OBJECTS BOTH AS "NORMAL" BUSINESS OBJECTS IN THE DLL, *AND* AS "DataContra ct" OBJECTS IN WCF SERVICE?

This type of code reuse seems to me to be very important.

Best regards,
Bjørn Sigurd Johansen
Norway
Jul 27 '08 #4

You'll want to check out this blog entry:
http://sholliday.space s.live.com/Blog/cns!A68482B9628 A842A!158.entry

...

You have to remember that with WCF, you have the ability to expose DotNet
code to non-DotNet clients.
Thus the "client side proxy".

In a DotNet to DotNet world, you don't necessarily want that. You want
things on both sides about the same....
and WCF is a service.

The blog entry should help.


<Bjorn Sigurd Johansenwrote in message
news:20******** *************** *********@spide rsolutions.no.. .
Dear all,

I have a similar problem in a Visual Studio solution with two projects:

Project 1: "Normal" class library which contains public business objects.
The DLL created by this project may be called directly by the user (as a
DLL assembly).

Project 2: A WCF server containing services where I want to use the
*SAME* business objects as parameters in public "ServiceContrac t"
functions. (This is important as I do not want to write 2 versions of
each business object).

But this seems somewhat impossible, as
1) It seems impossible to add the "DataContra ct"/"DateMember " attributes
to objects in BusinessServer. dll, and also
2) It seems impossible to define the business objects in the WCF-server
project and have them accessible/exposable by Project 1.

So, HOW TO REUSE BUSINESS OBJECTS BOTH AS "NORMAL" BUSINESS OBJECTS IN THE
DLL, *AND* AS "DataContra ct" OBJECTS IN WCF SERVICE?

This type of code reuse seems to me to be very important.

Best regards,
Bjørn Sigurd Johansen
Norway

Jul 28 '08 #5

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

Similar topics

5
8813
by: JohnFol | last post by:
I am using the Win23 API WNetCancelConnection2 and can sucessfully make a connection to a share within my class. The class is called from a Windows Form based test harness. When I instantiate exactly the samce class from a Windows Wervice, I get "A specified logon session does not exist. It may already have been terminated" .. The error number is 1312. I know the code to be good, so I suspect something around security / windows...
6
1615
by: Tony Fonager | last post by:
I am currently developing a statistics system in ASP.NET, and need to share information about the customers websites, in this application. (I have simplified my code, to make my project easier to explain.) The simple version of the system is like this : A customer inserts HTML code on his webpage, which contacts my statistics server each time the customers website recieves a hit - like a classic "register website traffic" system. ...
8
4544
by: Tony Fonager | last post by:
I am currently developing a statistics system in ASP.NET, and need to share information about the customers websites, in this application. (I have simplified my code, to make my project easier to explain.) The simple version of the system is like this : A customer inserts HTML code on his webpage, which contacts my statistics server each time the customers website recieves a hit - like a classic "register website traffic" system. ...
0
1043
by: Michiel | last post by:
Here's the situation: Windows XP SP2 with VS .Net 2003 Web project located on: Windows Server 2003 IIS 6 & Remote Debugging Website with document root pointing to UNC share on: Windows Server 2003 File Server
3
5045
by: musosdev | last post by:
Hi guys Okay, I've setup my projects to open and compile fine in VS2005 using FPSE and remote web, but it's *really* slow. So I thought I'd have a go at doing it the normal way, by loading from the network share. It loads in VS2005 fine, and I can edit and save code changes etc, but when I try and Build the solution, I get the following error... An error occured loading a configuration file: Failed to start monitoring
3
3134
by: Bob Peek | last post by:
I would like to share code between several web sites that exist as virtual directories under a single site. It appears that I have to create an app_code directory under each virtual root in order to share classes accross the code in the different virtual directories. This seems to defeat the purpose of shared code. Is there any way to specify to IIS where the app_code directory is for a virtual site?
15
5802
by: Neo | last post by:
Hello All, I found that ASP.net website only accepts code withing site directory. This creates big hurdle in shairng code. How to share code between two websites, like the way share between two non-website code? -Pravin
6
2962
by: tendim | last post by:
G'day group. Currently our organization us using VB6 based applications, and I am trying to push forward and migrate some of the smaller things to VB.NET, eventually migrating all applications from VB6 and other legacy languages/systems (Pure VBScript, DataEase, etc.) over to .NET. Currently, *all* user data is stored on network shares. When a user logs in to a workstation, their home drive is mounted from one share, all of their...
0
1404
by: GregInHouston2 | last post by:
I am attempting to access the files on a share on a server in my network so I can list the files there on an intranet web page. At this point, the share permissions and the NTFS permissions are set so open that it scares me but my GetFiles() call still generates an "access denied" exception. I have even given "Everyone" read access to the share and read, read&execute, and list folder contents permision on NTFS. The Directory Security...
0
8303
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8602
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7316
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.