Accessing Web Service from Windows forms app, Permission Exceptions

R

Rodney

I have a web service that I'm using for several applications to
retrieve data from an oracle database. I have ASP.net pages and some CE
apps all accessing the web service fine. The web service is located on
a server that i have full control over.

When I'm adding new webmethods to the service I'd like to debug them
through a simple testing app I've made on my machine. Its just a simple
windows form with a control to the web service running on the server.
When i try and run the method I get a this error message:

"Request for the permission of type 'System.Net.WebPermission, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed."

in my CE applications I use a NetworkCredential with a user I created
on the server strictly for this service, and it works perfectly. The
same process does not work for my windows form app.

I have been copying the web methods code into app and debuging it that
way, but at some point down the road I will be creating some windows
applications that will need to access this or other web services and
I'd like to get this to work.

Thanks
Rodney
 
J

John Saunders

Rodney said:
I have a web service that I'm using for several applications to
retrieve data from an oracle database. I have ASP.net pages and some CE
apps all accessing the web service fine. The web service is located on
a server that i have full control over.

When I'm adding new webmethods to the service I'd like to debug them
through a simple testing app I've made on my machine. Its just a simple
windows form with a control to the web service running on the server.
When i try and run the method I get a this error message:

"Request for the permission of type 'System.Net.WebPermission, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed."

in my CE applications I use a NetworkCredential with a user I created
on the server strictly for this service, and it works perfectly. The
same process does not work for my windows form app.

I have been copying the web methods code into app and debuging it that
way, but at some point down the road I will be creating some windows
applications that will need to access this or other web services and
I'd like to get this to work.

This exception is thrown by Code Access Security. I suspect that your
Windows Forms application, or some assembly it's using, is only partially
trusted, and isn't permitted to access the Internet. This has nothing to do
with file permissions.

John
 
R

Rodney

You were correct John. My projects folder is on a network share so that
it'll be backed up. Now that I added a full trust to my machine
security setting it is working correctly.

thanks,
Rodney
 
W

wizia

I tried and i could eliminate this error
--------------------------------------------
This error occurred when trying to run code that accessed the
System.DirectoryServices namespace.

To work around this, just open up your .NET 2.0 security:

Start --> settings-->Control panel -->administration tools

Start the .NET Framework 2.0 Configuration tool (from Administrative Tools).
Expand Runtime Security Policy.
Expand User - Code Groups and right-click on All_Code and select Properties.
On the Membership Condition tab make sure All Code is selected in the
dropdownlist.
On the Permission Set tab make sure FullTrust is selected in the
dropdownlist.
Click OK
Under Runtime Security Policy, expand Machine - Code Groups and right-click
on All_Code and select Properties.
Perform steps 4 - 6.


--Vijay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top