Access denied when using svcutil - wcf

I am trying to consume a WCF service I wrote, but I can't get the svcutil.exe to generate a proxy.
Every path I try brings up access denied... What do I need to set to get permission?
Generating files...
Error: Cannot create output file: C:\ClientCode.cs
Access to the path 'C:\ClientCode.cs' is denied.

If using Windows 7 try 'Run as Administrator'.
As a bonus, you can eliminate this annoyance by opening 'User Account Control Settings' and change the setting to 'Never Notify'.

Related

Able to write file but not read from a network location

I have following network location
Dim myfolder As String = "\\10.0.0.90\myfolder\"
I am able to create a new file in this folder using following code:
File.Create (myfolder)
But when I try to read contents of this folder using code below I get error.
Code
Dim orderedFiles = New System.IO.DirectoryInfo(myfolder).GetFiles()
Error
The system detected a possible attempt to compromise security. Please
ensure that you can contact the server that authenticated you.
File writing is being done by ASP.Net page while reading is done from Windows Service. Could this be the issue?
Windows Service was running as "Local System". I right click on it, went into properties and changed the "Log on as" to some user account and now it can access network folder.

Accesing windows server 64 bits Registry info using citrix

trying to save file using Powerbuilder Datawindow Save As function
for path we are using
RegistryGet( "HKEY_CURRENT_USER\Software\Microsoft\windows\currentversion\explorer\shell folders", "Desktop", RegString!, ls_ret)
but when we login through citrix.
Not able to get this path.
When looged in as administrator getting this path but for other users we are not getting the path .
We also given full permission to particularly this registry but still not getting.
This does not seem to be Citrix specific, to simplify, add a user to Remote Desktop group and login directly via RDP (without Citrix), you should get the same behavior

Writing WCF messages to a text log in configurable directory

I have a WCF web service that is deployed at IIS.
Part of the web service is to validate the inputs using EntLib 4.1
For ex, the string values can be of specific length and so on.
In case of the validation being failed a fault exception is raised and the service is supposed to write the message in log file.
How do I go about creating the log file to a location that can be configured from a config file.
Basically how do we write messages from IIS (since the service is hosted at IIS, I am assuming that that will be the source!)
To write to the log file, make sure that the identity running your web application has write access to the log directory.
IIS7: You can find the identity in the IIS management console. Select the application pool that your web application is using. Click on Advanced Settings. In the properties window, look for the identity field. It may say Network Service. This is the account that needs write permission to your log output folder.
IIS6: Same as IIS7 except right click on the app pool and select properties. The properties window of IIS6 will have an Identity tab.
If you already have a log file in this directory, try deleting it and letting the framework create it.
Hope this helps.
Why not just write the warnings/error to the Event Log? It's easier to maintain than arbitrary log files and you can query them from other machines.
http://imar.spaanjaars.com/275/logging-errors-to-the-event-log-in-aspnet-applications
This website helped me with the same problem on IIS 7.5, where you have new Application Pool Identities: http://learn.iis.net/page.aspx/624/application-pool-identities/
Using the command line ICACLS test.txt /grant "IIS AppPool\<AppPoolName>":F on the log file or log folder worked for me.
Trying to set the permissions via the file/folder properties dialog failed, the AppPool identity was not accepted there.

Configuring WCF in IIS7 & Windows 7

I am having a problem when I try to browse WCF service (.svc file) which is hosted in IIS7 & Windows7. It throws following error.
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
I tried to run ServiceModelReg, but it say I should have admin rights in order to run this, although I am admin on this machine.
Does any one know how to resolve this issue.
FInally....
I am able to resolve this issue.
I ran following two command and it solved the problem.
aspnet_regiis -i & ServiceModelReg -i
Even though I am admin on the machine, I need to run this 2 commands by right click and select 'Run as Admin'.
Your issued is answered here. Trying to be short:
When you start the command prompt, can
you right-click on the icon to open it
and select "Run as Administrator"? I
don't know exactly what's the logic
behind that, but on Vista there are
two kinds of administrative users, one
"normal" administrator and one
"elevated" administrator. I'd guess
the tool needs the second kind.
and second
Also, Why do you need to run
Servicemodelreg.exe on VIsta?
Officially this is not supported on
Vista. Instead you can go to WIndows
features menu throught Add remove
programs and enabled Http Activation
under .Net framework 3.0 feature.
This will enable everything you might
want to do via Servicemodelreg.exe.
Edit
And also here.
If you go into IIS Manager and double click on Handler Mappings do you have *.svc paths listed?
If they are missing this link may help http://msdn.microsoft.com/en-us/library/ms752252(v=vs.90).aspx

FileUpload SaveAs UnauthorizedAccessException error (Dotnetnuke)

I am trying to save an image file in a custom module I am building for a DNN site.
However when I run the code I get an UnauthorizedAccessException.
if(upLoadAddImg.HasFile)
{
String imageLocation = ConfigurationManager.AppSettings["ImageFolderPath"];
//Upload file
upLoadAddImg.SaveAs(Server.MapPath(imageLocation));
}
I am running on localhost using the internal visual studio server. Tthe folderpath is all right and I have made sure Network Service has full permissions.
Am I missing something obvious or does DNN have some special permission setting I am missing?
If you are using the dev server in VS its identity is not Network Service by default. Most likely the directory you are saving to loccally is not allowed for the aspnet user - if you run this on a web site it should work at least code wise -------
To test it you can do one of two things make the portal directory open to everyone or set up a local site not run on the dev server ----