I am creating a windows service in VS2010, and in order to store a user's input during installation I've been told to write it to a file called app.config.
However i cannot find this app.config file? Does it create one in a windows service project? or just in a WCF windows service project?
In VS do the following:
Click on the service project
And add new item
Select Application Configuration File.
This will appear in your service project as app.config.
When you actually build the project you'll see it a Spotter.exe.config along side your Spotter.exe file.
Related
I actually just created an NServiceBus self-hosted endpoint and bootstrapped owin self-hosted web api 2 by adding the Microsoft.AspNet.WebApi.OwinSelfHost nuget package. It's all up and running fine and I can hit the controller endpoints that I added, but the package didn't add the normal items like the web.config.
I'd like to have the normal web.config available to where I can also add in different build configurations (the transform files like web.debug.config, web.release.config, etc).
How do I add this into my project?
I tried just adding the file, but ConfigurationManager doesn't read it.
web.config is used for asp.net web application on a hosted server. As you are using a self-hosted server then web.config is no applicable. You would need app.config which would resolve to the executable name with the .config file extension.
Add app.config to the project and ConfigurationManager should be able to read it.
UPDATE:
It was indicated that the same config transformation was also needed for app.config
The following VS tool fills in the gap left between web.config transformations.
Configuration Transform
Automatically transform app.config or any other config during build
process. Once the transformation is set, it will run on other build
machines without the extension.
The link includes step by step instructions on how to use it in applying configuration transformations.
What files do i need to put in iis directory when deploying wcf web service in iis adding as site?
For example:
Is it just dll from bin and service contract?
Does example.cs code files need to be copied in iis directory too?
It depends what you have in your service.
Usually, the bin folder, the configuration file and .svc file, if it exists.
But it's better let Visual Studio handle this. Right click over your service project and then "Publish". Visual Studio will copy everything you need to deploy to a folder.
I am wondering if its possible to create a separate web.config file for a custom service which references the PSI on SharePoint 2013.
So I have my "service.svc" within a folder in the PSI directory, but I would like to have a separate web.config just for this service. I want to try to consume that service in a more general approach, without going through "ProjectServer.svc" in my client.
So I thought it would be better if I can define the endpoints and the rest of the bindings in that separate web.config file.
Thanks
The solution was to create a separate folder in the mapped PSI folder of IIS. Then inside you can easily install your service when deploying with a separate web.config file.
I restructured a WCF project to separate the service.cs and contracts to separate projects. In the main WCF project I place only a service.svc file that references (dll, not service reference) the service class. I also updated app.config to reflect the change.
Once I do this, the wcf test client no longer loads the service. It gives no errors. I can publish to my local IIS and it still works just fine.
Do I need to add something to the wcftestclient.exe command line options?
Is the dll of the project that has the contracts in there also? Make sure to copy everything from the bin/debug (or bin/release) into IIS virtual directory.
I have a wcf service application that has some application startup code in the app_code folder of the project. When i publish this project to my website, it deploys it with source code and app_code folder.
Is there a way to precompile the wcf app ( like an asp.net app), that includes all the dependencies and compiled code ?
i checked the web deployment package files, and even that has the source code of app_code folder.
problem here really is that since the template for wcf does not expect app_code folder and .cs files in it, they get added as content, changing them to compile would include them in the web dll
Your best bet would be to:
put all your WCF service-related code into a separate class library assembly
deploy that assembly to the .\bin directory
only put your MyService.svc file (without any code-behind) to your virtual directory
With this setup, the WCF service is still being hosted by IIS, but you don't need to do any special tricks and hacks to get it to work properly.