How to add a WCF server hosted in IIS to Silverlight - c#

I'm running IIS 7 with a WCF service. I'm pretty sure this service is working okay because, if I click 'browse', I get this screen:
So I go into Silverlight and I want to add this as a service reference to my application (not the web project). Now I'm not sure whether I want to give it the service address with the ?wsdl or withou the ?wsdl (it seems everyone I speak to has a different view on this).
So firstly, the attempt WITH the ?wsdl on the end:
Secondly, the attempt WITHOUT the ?wsdl on the end:
Note that there are two separate errors.
So it's entirely possible that there's a problem with my web.config, right? Well I don't know about that, although I will present that too, just in case someone can see any faults with it.
I've been struggling with this for days now. I can only imagine there must be a really simple solution, but I'm buggered if I can see what it is.
Well, I hope you can offer some useful suggestions. Thanks!

Related

ClickOnce and Windows Service deployment

So I have researched through MSDN and SO, but have not found the answer to a question asked quite this way: I have an app that will be turned off/on, and as part of the install/update, I want to have a Windows service get updated as needed also as part of the install to the primary app. The Windows service will provide data to the app, but if the app changes, the service may need to provide more/different data.
I looked at TopShelf as someone suggested on a different post, and seeing that makes me wonder if I can use TopShelf to deploy the service at the same time as the app itself - in other words, wrap the whole thing in ClickOnce, let TopShelf do the Windows Service part, and ClickOnce finish by doing the app part. Does that sound like a decent strategy?
Ok, so I found my answer: ClickOnce doesn't do what I want, because Microsoft said so (under "Next Steps"). But their suggestion is to include a class called ServiceController which can talk to your service from your application, and do any Service manipulation that you want. (TopShelf doesn't appear to be necessary.) I like this because it allows everything to be under one roof, and is elegant...It should solve permissions issues and other barriers to simplicity of installation - we want this to be as easy and seamless for our
customer as possible.

.Net Application Variables bleeding across applications

I have a couple of websites that have a shared code base as they are essentially the same website, except one is for the UK market and the other is for the US market. As well as sharing a code base, they also share a database with a very basic CMS so that each website can have some different content.
On the sites we have an admin page which can be used to set some HttpContext.Current.Application variables for each website, things that don't change all that often, but that we may want to change at a moments notice without having to update config files etc.
Now this has been working fine for a number of years now on a server 2003 box with IIS 6. Just yesterday we upgraded to a shiny new Server 2012 box with IIS 8 and we are now having issues with the Application objects.
To cut a long story short, now when an application variable is set on one website, it is being set across both sites, so the UK market sees the US application objects and vice versa, depending on which one was set last.
The application objects are pulled from a database based on a market code, and that is all working fine (the code hasn't changed in at least a couple of years now), and I have written some logging to confirm that the correct objects are being loaded for each website.
Each website has its own application pool, so I really can't see how this is happening. I have tested the sites on Server 2008 with IIS 7.5 and they behave fine there, similarly, I run a Windows 8 dev machine with IIS 8 with what I think is an identical setup to the new live servers (the app pools are configured the same and everything) and both sites do the correct thing there.
Has anyone ever heard of this sort of issue before, and does anyone have any suggestions for things I can look into to fix this? I thought it wasn't even possible to share Application objects across separate applications, are my assumptions wrong there?
Many thanks!
Mark
This sounds like a configuration problem, are you sure those site have different market codes? Looks like the queries returns wrong values for the application objects.
Ok, so it turns out, it was a configuration issue, not with the websites or even IIS. It in fact turned out that our sysadmin, when changing the DNS for the websites, accidentally changed the US website to the UK IP address, so both sites were the same application after all. I'm afraid it never even occurred to me to ping the sites to check the IP addresses, and we all now feel suitably silly for not spotting it sooner. I can only put it down to a ridiculously early start in the morning to do the change over, resulting in a bunch of over tired developers on a wild goose chase.
Still, if anyone else has a similar issue, perhaps this will help them.

WCF Service Calls Javascript Code On Start After Removing the Code from the .ASPX Page

I have a C# .NET WCF project that consists of a JavaScript page that calls a service. Upon start-up (in debug mode) it immediately calls the service, but I can not figure out why. To attempt to troubleshoot the issue I have performed the standard things, such as cleaning and rebuilding. I also have deleted the projects dll's under the Windows directory. To further emphasize the point, I deleted all of the Javascript in the .aspx file, but it still appears to retain it. I know this because the call stack is pulling the function call with the variables populated, even though they are not there.
What can cause this? How should I go about clearing out the code, since it's no longer there? I think it's a good place to start, as the other issue of calls at startup may be solved.
You should definitely use the REST protocol anyway. This ensures that other non-ASP.net websites can consume your service (interoperability).
Is there any particular reason why you're using WCF for this? It would be easier to use MVC 4.0 with the REST API. WCF is more suited to heavy lifting with Data contracts etc but it is not very interoperable.
In response to your question, what is the VS project configured to use as a start item?

.NET webpage/service/app communication

Alright guys, I'm in a little over my head on this one and am hoping someone can point me in the right direction, as I'm not really sure how to implement this.
I've got a piece of hardware that exposes a c#.net API. Great. Works wonderfully. I want to collect data from this hardware using the API (so, a small c# app that does what I need) and then display the results on a web page. Currently, I have the c# app grab data I care about and stick it in an RRD file, then I have the web page load the relevant data and display it to the user.
My question, then, is what do I do when I want to expose some of the API functionality to the user? How do I go about making the 2 projects talk using .NET?
Some clarification: The reason there are two parts is due to modularity. The attached hardware and API can change, but as far as any client request is concerned, nothing's different, everything's just a web request to them.
Very little experience in big .net projects, so if you've got a better idea, let me know.
The easiest way I can think of would be to use something like NServiceBus to post a message to the other component which communicates with the hardware. The hardware piece would pick up the message from the bus, process it and put the response back on the bus.
It's not a perfect solution, but I think it's definitely workable.
You should be able to find everything for it here.
Left it here for a few days to see if anyone else had any ideas. I ended up scrapping the whole idea and consolidating everything into the web app. Not my initial preference, but it works okay. Thanks to Terrance for the brainstorming session under my question.
Easy. Create a class library for the device handler. Add a public class which exposes a nice interface for the web app. Add a reference to the class library. Create your class and use it.

How to precompile WCF code and then host it on IIS?

How do you precompile WCF code so that the WCF code can't be seen by anyone who has access to the WCF code.
it's possible to this with ASP.NET code by using the "precompilation" feature. basically, what the precompilation feature does is enable the developper to deploy "binaries" to IIS instead of a folder containing source code.
can this be done with WCF too ?
I think you may be confused about something.
A WCF project is always "pre-compiled", unless you go out of your way to be unusual. The source files do not need to be deployed in order for the service to operate.
What leads you to believe that your source code needs to be deployed?
You're looking for an obfuscator.
I'm not sure why people are DVing your post as this is a legitimate question. However what you are actually looking for is source code protection not pre-compilation.
Source code protection can be many faceted to be effective however I routinely state it's generally worthless as you will spend alot of time and money for a very intangible benefit. If your product is based on a brand new algorithm that has true commercial value C# is definitely not the optimal language to develop that module in.
There are posts on here about this topic: https://stackoverflow.com/questions/402430/how-do-i-use-net-without-loss-of-control-over-intellectual-property being on of them. It's also possible this question will be closed as a duplicate.

Categories

Resources