Hosting a WCF Service in Vista - visual-studio

I put together a small WCF service in VS2008 and when I try to run the host using an HTTP protocol, it bombs because it doesn't have the proper rights to do so. On my "Host.Open()" line I get this exception: "HTTP could not register URL http://+:9001/. Your process does not have access rights to this namespace." I did not seem to have this problem using TCP. My o/s is Vista Home Premium.
This was happening when I would try to Debug it inside VS2008. After a lot of research, I determined I could get the host to run by building, going to the "bin" folder, and right-clicking on my executable, selecting "Run as Administrator". The same thing happened when I tried to use the WcfSvcHost.exe. I had to open the VS2008 Command Prompt window from my menu using "Run as Admin" before I could successfully get WcfSvcHost to run my service.
Is there a way to do this right instead of using this workaround? Am I going to have similar problems when I try to deploy this next week on a Windows 2003 Server?

This link might help you: http://msdn.microsoft.com/en-us/library/ms733768.aspx
Short version: pre-register the url/namespace from a privileged console
netsh http add urlacl url=http://+:9001/ user=DOMAIN\user

Make sure you are starting VS as administrator..

Locally, you can change your base address to something like this:
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/MyService/" />
</baseAddresses>
</host>
The main part being the addition of "Design _ Time _ Addresses". If you create a WCF Service Library project, it sets up the App.config for the project like this by default. Everything works fine this way, but if you remove "Design _ Time _ Addresses" and try to run it with "http://localhost:8731/MyService/", you will get the error that you are running into.

I was having a similar problem here:
WCF ServiceHost basicHttpBinding 503 error
The netsh command works for Vista, but for Windows 2003 server, there is an HttpCfg.exe utility that allows you to register a URL/namespace for an account. Not sure if the netsh is available in 2003.
I never actually got it to work on Vista, I'm still getting 503 errors when I try to access the services. If you run into the same problem/figure it out, I'd appreciate it if you post again! Thanks

Related

Error 193: '%1 is not a valid Win32 application on Windows Server 2003

I would like to get some help, I'm getting this error when trying to start a windows service and it's driving me crazy. The details are:
I've got a Windows Service developed on VB.NET (VS 2012), it's compiled for a x86 machine.
I used InstallUtil and the "SC CREATE" command to install the service on the customer's server (running under Windows Server 2003).
When I try to start the service, I get the following error message: "Could not start the service on Local Computer. Error 193: 0xc1"
I looked the Event Viewer for some clues, but I couldn't find any very useful info: in the "Application" tab there are no records logged by the service so I assume it's not even running a single line of code. In the "System" tab there are records logged by the Service Control Manager with the following error message: "%1 is not a valid Win32 application."
I did a long research on the web and the only solution provided is checking Windows Registry to find the ImagePath for the service and add some quotes at the beginning and end of the path. This is supposed to solve the problem but it's not working in my case. I have modified several times the ImagePath (I added and removed the quotes, tried with double a triple quotes) but I'm not getting any positive results.
Could someone help me with this? Thanks in advance...
I think that there is a combatibility problem with .net framework that you use and windows server 2003.Do you use .net 4.5?
Windows server 2003 can't run applications which target net framework 4.5.
http://www.microsoft.com/visualstudio/eng/products/compatibility
So you could change your target framework to 4.0.
My problem was due to having my service project configured as a Class Library and not Windows Application in the Application pane of the project properties.
Same original issue but Win Server 2019, also not resolved with quoting the registry ImagePath. However, was resolved by using a NTFS symbolic link for the folder parts of the path.
E.g. instead of the ImagePath registry entry for the Service being:
D:\My Folder\My File.thing
Create a Windows symlink at an elevated-permission Cmd prompt:
d:>mklink /D "myfold~1" "My Folder"
Then use the symlink in the registry ImagePath
D:\myfold~1\My File.thing

The Windows Process Activation Service failed to generate an application pool config file

I suddenly cannot start IIS anymore on my Windows 2008 R2 server. The depending "Windows Actication Service" does not start.
In the Event Viewer I can see the following message:
"The Windows Process Activation Service failed to generate an application pool config file"
I've checked all IIS config files for typo's, none can be found.
I've tried to remove the IIS role from the server, which results in an error.
I'm totally desperate here. I've looked on Google for several hours, but none of the suggestions I've found helped.
Something has messed up permissions and the user account under which WAS runs does not have permission to create its working files. Probably you installed a service pack or similar.
Rebuild the box and apply all service packs to Windows before you install WAS, and then let it update itself and then install your own stuff.
Rebuilding boxes is no fun and takes far too long. Learn to use virtualisation and undo disks.
If you have another working server, you can import IIS configuration from there via Shared Configuration. I was able to resolve this error by doing so.

Is it possible to access the Azure emulator from another computer on the same network?

I'm running Windows 7 (x64) with VS 2010 SP1 and the Windows Azure SDK 1.5. I'd like to be able to debug a web application on an iPhone connected to the same network to shorten debug cycles.
IIS is running on this machine and can see that a temporary site is being created when I debug the Azure project. Is there a way to add an additional binding to the IIS site so that I can connect from the the iPhone when the debug is started? I can manually add a binding once the debugger starts up but this is lost when I stop debugging.
This is a very old thread, but I came across it trying to do the same thing- after more searching I found this: and it worked great for me (Using Passport to pass the traffic)
http://blog.sacaluta.com/2012/03/windows-azure-dev-fabric-access-it.html
you can use port forwarding to do that.
netsh interface portproxy add v4tov4 listenport=800 connectaddress=127.255.0.0 connectport=82 protocol=tcp
More info here: http://fabriccontroller.net/blog/posts/remotely-accessing-the-windows-azure-compute-emulator/
I have managed to find a solution that kind of works.
I went to IIS manager and created a new website that points to the folder were I'm developing, on the port 8000.
Now I can access it through http://ip-of-server:8000, and also debug the application.
Hope it works for you also.
I have discovery this solution http://blog.piyushthacker.com/?p=24
Works fine for me :)
In newer version (1.3 and higher) you may need to change file IISConfigurator.exe.config file like in this solution http://blog.syntaxc4.net/post/2011/01/06/changing-the-windows-azure-compute-emulator-ip-address.aspx
I use Fiddler to create a proxy server (tick options Act as system proxy on startup, Monitor all connections and Allow remote computers to connect), configure the remote browser to use the proxy server, and access my Azure website via http://ipv4.fiddler:81/ Technique from here.
There is a solution for this,
Look at This SO Answer,
which is based on this post

SignTool unexepected internal error

I am running SignTool with the following command:
signtool sign /f keyfile.pfx /p mypassword pathToMsiFile.msi
and i get the following error:
SignTool Error: An unexpected internal error has occurred. Error
information: "Error: Store::ImportCertObject() failed."
(-2146893792/0x80090020)
It worked just until a day ago, and i have no idea what might have changed...
Any ideas would be great, thanks!
I managed to fix it.
Apperantly the user was corrupted.
after fixing the user using this KB from microsoft everything became right again.
I had the same issue but only when I'm trying to sign it under IIS/PHP script. When I run PHP from the console it's OK. And here there were no issue with account. Only one thing helped me - changing Anonymous Authentication Credentials for Site/application from Specific USER to Application pool identity.
I managed to fix it. Apperantly the user was corrupted.
after fixing the user using this KB from microsoft everything became right again.
None of the suggested answers worked for me using Windows 2008 R2 and IIS 7.5. What did work was to change a setting for the application pool. Here is what works on IIS 7.5.
Select your application pool and click Advanced Settings
Under Process Model, change Identity to LocalSystem
This is the only thing that worked for me, hopefully it will help others down the road.
I'm not sure if setting your Application Pool to run as the LocalSystem is a good idea from the security standpoint. One way to fix this error is to enable Load User Profile in Advanced settings for the Application Pool. Don't ask how long it took me to find it out...
Here's more details.
I was also experiencing this error within a web application which was using an IIS web application pool with domain credentials, but the "Load User Profile" was set to false. Once I set it to true, signtool.exe worked without issues.

"No printers are installed." problem when using excel 2003 interop sheet.PageSetup through a WCF service

We have a WCF service that generates an Excel file off of a template and feeds it back to the client in a byte array. For some reason, we are getting an error when we try to do this:
sheet.PageSetup.CenterHeader = sheet.PageSetup.CenterHeader.Replace("[customerName]", customerName).Replace("[dateTime]", date.ToShortDateString());
When it hits this line, we get this error message:
No printers are installed. To install a printer:
In Microsoft Windows 2000, click Start, point to Settings, and then click Printers. Double-click Add Printer.
In Microsoft Windows XP, click Start, and then click Printers and Faxes. Under Printer Tasks, click Add a printer.
Follow the instructions in the wizard.
The service runs under the LocalSystem account. When we first deployed this service, it was to an x64 machine and had the same issue. Our dev environment is x86 so we moved the service to another server that was x86 and it worked fine for a while. It recently stopped working and is now giving us this error message again. I am pretty sure it was becuase of a mass windows update that was done on the app server recently.
Funny thing is, I tried changing the service to "allow interaction with the desktop" and it didn't work, but when our sysadmin did that same thing, it worked for one file generation but is not working now.
There are printers installed on the machine, both on domain accounts and local accounts. I've also tried running the service under a different account, but then I wasn't able to connect to the service due to some SSPI error. We tried using the Network Service account but then the app couldn't see the service at all. We've restarted the service after each change also to no avail.
What I do know about the "PageSetup" part of the sheet object is that it needs to have a printer installed to access it at all, even if you aren't printing. I was unable to figure out a way to trick the machine into thinking the LocalSystem account has a printer installed.
We figured out the problem, I had my config file still pointed at the x64 server :(
As to why it won't work on x64 (to my knowledge) - since office 2003 is x86, it needs an x86 print spooler in order to work correctly. I don't know of any way to get an x86 print spooler on an x64 OS so we just stuck it on the x86 server.

Resources