• 0

[C#] Interacting with an online server


Question

Hi,

Im currently in the middle of developing a desktop application and need some advice on some issues.

Logging in - I currently use the MySQL library to send login information to the server in order to validate the user.

Is this good practice? Is it commonly used for desktop applications wishing to have a web presence?

I also have a plug-in infrastructure built into the application. Drop in a .dll file into the application folder and it will be available on startup.

I am thinking of developing a store module that allows the user to select a plug-in and install it in the correct directory.

How is something like that done using C#.

proping for a list of plug-ins and downloading the right files onto the computer.

Thanks,

Any help would be much appreciated :)

Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

Anyone...?

Its mainly the second question i'm concerned about really...

I also have a plug-in infrastructure built into the application. Drop in a .dll file into the application folder and it will be available on startup.

I am thinking of developing a store module that allows the user to select a plug-in and install it in the correct directory.

How is something like that done using C#.

proping for a list of plug-ins and downloading the right files onto the computer.

Link to comment
Share on other sites

  • 0
Logging in - I currently use the MySQL library to send login information to the server in order to validate the user.

Is this good practice? Is it commonly used for desktop applications wishing to have a web presence?

You may find this to be the practice for internal applications, but rarely will you find this in a public application. Companies do not want their database servers to be open to the public.

Most desktop applications will access web services, and/or web pages to execute actions.

I also have a plug-in infrastructure built into the application. Drop in a .dll file into the application folder and it will be available on startup.

I am thinking of developing a store module that allows the user to select a plug-in and install it in the correct directory.

How is something like that done using C#.

proping for a list of plug-ins and downloading the right files onto the computer.

It would be pretty simple. Create a web service (or a page) that returns a list of available plug-ins. The list would contain plug-in details such as name, description, version, and filename/location. You can then use that information in a grid or something similar in your application. Once a user double-clicks on a selection, you can use that file location piece to download the file and store it in any directory you want. http://www.google.com/search?q=C%23+downlo...lient=firefox-a

Link to comment
Share on other sites

  • 0
You may find this to be the practice for internal applications, but rarely will you find this in a public application. Companies do not want their database servers to be open to the public.

Most desktop applications will access web services, and/or web pages to execute actions.

This application checks a database every 30 seconds for new messages and updates an icon on the screen if a new one shows up.

Would it be safer to use SQL server for this purpose?

It would be pretty simple. Create a web service (or a page) that returns a list of available plug-ins. The list would contain plug-in details such as name, description, version, and filename/location. You can then use that information in a grid or something similar in your application. Once a user double-clicks on a selection, you can use that file location piece to download the file and store it in any directory you want. C%23+download+file&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US%3a%6ffficial&client=firefox-a

Thanks mate, that seems a lot easier than i imagined :)

Link to comment
Share on other sites

  • 0

Have you considered setting it up as a SOAP web-service system? That will help isolate the data from the UI layer and you can call SOAP functions from the desktop applications as if they were any other class functions.

Link to comment
Share on other sites

  • 0

If you are using .net 3/ 3.5 you can also from the same webservice use JSON instead of SOAP which will probably be better if you are polling every 30 seconds as the transfer size will be much less.

Link to comment
Share on other sites

  • 0

I'm not a fan of SOAP myself. There is a market for it. In most cases, though, people can get by with a lot less.

Link to comment
Share on other sites

  • 0
It would be pretty simple. Create a web service (or a page) that returns a list of available plug-ins. The list would contain plug-in details such as name, description, version, and filename/location. You can then use that information in a grid or something similar in your application. Once a user double-clicks on a selection, you can use that file location piece to download the file and store it in any directory you want. C%23+download+file&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US%3a%6ffficial&client=firefox-a

I have been looking into web services for the last few hours and i'm slowly finding out how it works. :)

I am now able to make a service, connect to the service from the desktop application and call web methods.

Going good so far...

However i seem to be having problems returning custom objects from the web service. I can return custom objects but cant seem to access any public methods inside this object. The only things i can seem to access from these custom objects is public variables.

I cant seem to find the solution online, any idea what im doing wrong?

Link to comment
Share on other sites

  • 0

Ok, another question then.

At the moment my webservice has a constructor in which i open a mysql connection but...

Is it better to keep this connection open for the life of the webservice or should I open and close the mysql connection in every WebMethod?

If i was to keep the connection open, should I close the connection in the deconstructor?

Is the webservice disposed when i call the .Close() method on my webservice object?

~Service()
{
// close connection here
}

Link to comment
Share on other sites

  • 0
I have been looking into web services for the last few hours and i'm slowly finding out how it works. :)

I am now able to make a service, connect to the service from the desktop application and call web methods.

Going good so far...

However i seem to be having problems returning custom objects from the web service. I can return custom objects but cant seem to access any public methods inside this object. The only things i can seem to access from these custom objects is public variables.

I cant seem to find the solution online, any idea what im doing wrong?

That's by design. Think of the objects returned as data containers. Processing of business logic (the methods) wouldn't really make sense for the local proxy classes as business logic should be handled on the server.

Ok, another question then.

At the moment my webservice has a constructor in which i open a mysql connection but...

Is it better to keep this connection open for the life of the webservice or should I open and close the mysql connection in every WebMethod?

If i was to keep the connection open, should I close the connection in the deconstructor?

Is the webservice disposed when i call the .Close() method on my webservice object?

~Service()
{
// close connection here
}

You should close/release the connection as soon as possible. Page and webservice instances have a lifetime of a single request. Every time you request a page and/or webservice it gets created and then destroyed.

Edited by sbauer
Link to comment
Share on other sites

  • 0
That's by design. Think of the objects returned as data containers. Processing of business logic (the methods) wouldn't really make sense for the local proxy classes as business logic should be handled on the server.

Yea, your right. Just seemed a bit weird at first. I thought the object would be serialized and de-serialized like when you are saving an objects state to disk. It was just a matter of setting up access-modifiers to access the private variables.

You should close/release the connection as soon as possible. Page and webservice instances have a lifetime of a single request. Every time you request a page and/or webservice it gets created and then destroyed.

I dont understand what you mean by this statement. At the moment I create the webservice object when the desktop application starts and close the webservice just before the desktop application closes... I have changed my web methods, following your advice above, opening and closing the mysql connection within the method rather than keeping it open for the lifetime of the webservice object.

You say that webservices have a lifecycle of one request, but i can seem to open the web service, call numerous web methods and close the web service. Does a request in this case mean a web method call?

Thanks for all the help anyway, really getting the project moving along :rofl:

Link to comment
Share on other sites

  • 0
I dont understand what you mean by this statement. At the moment I create the webservice object when the desktop application starts and close the webservice just before the desktop application closes... I have changed my web methods, following your advice above, opening and closing the mysql connection within the method rather than keeping it open for the lifetime of the webservice object.

You say that webservices have a lifecycle of one request, but i can seem to open the web service, call numerous web methods and close the web service. Does a request in this case mean a web method call?

Thanks for all the help anyway, really getting the project moving along :rofl:

Sorry, I meant the actual web service code itself (asmx page on the server) has a single request life cycle. The code that calls the web service (on the client) has a developer-defined life cycle. When you said web service, I assumed you were talking about the asmx code.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.