How does configuring a service reference affect my project? - visual-studio

I have a C# Visual Studio console application with a service reference. The company providing the service offers two API's one for test and one for live. They are supposed to be essentially the same service but with different URL's to different servers.
When I right click the service reference and choose Configure Service Reference, I am able to enter the the URL for the live service; and my project compiles properly.
I am new to this and am not really sure if I should be reconfiguring the service or if I should be deleting it and re-adding it in? I don't know if there are .config files I should be changing or cleaning manually.
So I guess my question is - are there pitfalls or better practices for this process that I should be aware of?
Any advice greatly appreciated. Thank you.

I have worked with Service References myself and so far never had any problem with just updating the service reference. If you like/need to change the configuration, it is possible by editing the .config file that gets generated

Related

User Settings Not Working When Deployed By Setup Project (C# VS2013) *FIXED

I have made a few setup projects in my time, but this is a first for using User Settings. I may be using the wrong "words" when searching since I cannot be the only person with this issue.
The user settings I am talking about, are the settings you define in the Project Properties -> Settings. They work like a charm inside VS, but when I make the installer (using the free setup project extension, not the WiseInstaller LE that is included) and run the EXE, nothing takes.
I tried including the settings.settings file, and the App.Config file but that idea did not work.
What am I doing wrong? If I need to convert these to registry entries, then I need to do a lot of recoding. These are scoped to User, not Application.
Thanks,
Dave
I figured it out, it had nothing to do with the setup project, but rather my code flow. The settings form first tried to connect to the DB, since the connection information is entered on that form, it threw a cannot find error, so thinking that is what it should do, I hit continue. Well I was a bit wrong.
That error kind of made the form stop working since the information comes after the DB connection. I added a trap, and changed the code flow and all is good again.
Thanks
Dave

What project types in Visual Studio 2013 would you use to create this structure

I am working on a new project and instead of creating a single project with the UI and Web Services in the same project I want to separate them into two projects. Like the image.
What project types in Visual Studio 2013 would you use to do this. I know that I can do everything by hand but...
I have tried the WebAPI project type but it assumes everything in 1 project.
I know someone else has wrestled this issue so I would appreciate your input.
Any advice would be appreciated.
I think you might be confusing "projects" with "solutions". It sounds like you should just start with a Blank Solution and develop out the different projects. There's no reason why all of these couldn't live within the same solution.
I think that Mr. Beam missed the point of the question in that Mr. Washington is asking about the project types to create shared services that are called by and UI type project.
I think just creating an empty project with the WebAPI inclusion would be what you want. You could then to REST calls to your service layer project with no other overhead.
JD

Sharing AppSettings and ConnectionStrings between a console and a web app

I have a multi-tiered ASP.Net MVC 3 application in which different layers need to share some settings, and I am wondering how to best achieve this.
For now, all my AppSettings are in the Web.config file, but I just added a new project to my solution to create a console application that will be called every night buy the Windows Task Scheduler to perform routine maintenance tasks. This console application will be using the same database, repository layer, service layer, etc. as the web application, and both applications should share the same settings for the most part. I would like to avoid duplicating the settings in two files (app.config and web.config).
Also, I want these settings to be available to the service layer, which is in a separate project in the same solution.
I have read the following post, but I don't fully understand the solution, and I am not sure it is the best way to do this.
Sharing Config settings between Web App and Console App
I also read the article linked to by that post, and I don't find the solution very elegant.
I am using VS 2010 and EF 4.3.1.
If you're simply interested in accessing the AppSettings of your web.config file from a console app, that's simple enough. The only real annoyance is that since your console app won't be running in a web context, you will have to know in advance what your site is called in IIS. This being your own application shouldn't be a challenge.
Just use System.Web.Configuration.WebConfigurationManager to open and access the web.config of the specified site.
The idea is that you could put the settings into a common .config shared between all your projects as a link instead of putting it in all projects. The solution is outlined in this answer. Also checkout the configSource property on MSDN if you are not aware about the possibility of externalizing configuration elements into a separate file.

Multiple Instances of ClickOnce app

Some background to my problem...
We are currently using ClickOnce to deploy part of our solution which was working a treat until we encountered a scenario where we are now required to have multiple instances of our application installed on the same PC. We are able to achieve this internally and have this working perfectly as we know what instances we have so our build process will update AssemblyName to include the instance name before publishing the installer, this means we are able to have multiple instances on our PCs internally (ie, test, live and demo etc).
Our external deployment process is slightly different, we take one of the ClickOnce installers created in our build (along with all our other components that make up our application) and as the ClickOnce installer is deployed on a server we update the app.config along with the manifest files and resign so they now have client specific details. If a client chooses to have multiple instances of our product installed the ClickOnce will now fail when a second instance is installed on a desktop PC as all instances share the same assemble name.
So finally to the question, does anyone know of a way to update the manifest etc after the clickonce package has been created to allow multiple instances to be installed? We could go down the route of building many clickOnce installers but I dont think this will really work for us, is there perhaps an alternative to ClickOnce which provides a similar upgrade experience for non-admin users?
Hopefully someone will be able to share their experiences and help me resolve this.
Thanks in advance
Doug
I don't know of another technology that allows such a simple auto update process. So sticking with ClickOnce... I think this link might be useful. It explains what you need to do to have the same app installed twice. Essentially changing the assembly name and product name should do it.
Hope that helps.
Greg

Windows Azure - The current service model is out of sync

When I run a Windows Azure web role on my local developer fabric, I get the following error:
The current service model is out of sync. Make sure both the service configuration and definition files are valid.
One of my colleagues hit this issue and after a bit of playing about, the problem was that the two service configuration files (cloud and local) had a different number of Settings.
When he updated the configuration files so that they were in sync it all worked.
A tip would be to use the GUI in Visual Studio to add new settings to both at the same time. The GUI can be accessed by right clicking the web role and selection properties. This should open up a window. Click the Settings tab on the left.
For me, this was caused by my azure project having been copied from one PC to another (going from Win 7 to Win 8.1 in the process). I am using VS 2013 Community edition on both, but I had upgraded from Azure 2.4 on Win7 to Azure 2.5 on the Win 8.1 machine.
If you unload the azure project and edit the csproj file, you just need to make a small edit (e.g. adding a comment) and save it, so it re-writes itself. This fixed it in my case (where I'd spent ages checking for errors in the CSDEF and CSCFG files). Once I re-saved the csproj file, it worked fine.
This happened to me because one of my cloud configuration files (.cscfg) was missing some key-value pairs that were defined in ServiceDefinition.csdef.
Going over the files manually was a pain. There's an easy way to discover the descrepancies:
In the Solution Explorer, right-click one of the Roles that make up
your Cloud Service and click 'Properties' in the context menu.
The Role properties window will open up grey with an error message saying:
"Invalid Service Definition or service configuration. Please see the
Error List for more details".
Open the Error List window and in some cases you
should be able to see a list of the specific discrepancies, complete with file
and property names.
I followed all the answers here and it still didn't work
eventually I restarted Visual Studio and it worked.
I believe the solution was the combination of one or more of the answers here + restarting VS.
What worked for me was to:
Make sure the Cloud Services .cscfg and .Local.cscfg files were identical (unless you need your Local.cscfg to have some differences for debugging purposes),
Make sure the .csdef file had definitions that matched the .cscfg files, and then
Close the project and delete its Cloud Services .ccproj.user file.
After reloading the project, all was well.
The error can occour when there is no actual fault in the service configurations.
If it occours and everything seems to be correct, instead of restarting visual studio, simply unload the azurecloud project (rightclick: unload proecjt
Please cross check your ServiceConfiguration.Cloud.cscfg and ServiceConfiguration.Local.cscfg files. My problem was, I added a configuration to Local.cscfg but forgot to add the same to Cloud.cscfg
Had this issue - no errors though. I have found that for some bizarre reason the if the setting:
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
was commented out, then the workerrole would not launch.
For me, the issue turned out to be an inconsistency between the vmName value I had assigned to one of my roles in my various environments. I have a *.cscfg files for my development, test, and production environments. Each of these had a role definition that was supposed to be along the lines of
<Role name="HardWorker" vmName="SomeName">...</Role>
but one had an entry like
<Role name="HardWorker" vmName="SomeOtherName">...</Role>
and that, apparently, was enough to trigger the error.
My problem was incorrect certificate definition in csdef file.
For me the problem was that the Wifi I was using blocked the PORT Azure is using, changing Wifi solved that problem.

Resources