Web服务 - 请求类型System.Security.Permissions.SecurityPermission的许可失败类型、System、Web、Security

2023-09-05 00:04:56 作者:忆°往昔

我想主办GoDaddy的.NET Web服务。我不知道这是不是在GoDaddy的一个问题,如果有什么我可以做的。

I am trying to host a .Net web service on GoDaddy. I don't know if this is an issue on GoDaddy, or if there is anything I can do about it.

完整的错误信息是:

未处理的异常信息:System.Web.Services.Protocols.SoapException:   服务器无法处理请求。 --->申请许可   类型'System.Security.Permissions.SecurityPermission的,mscorlib程序,   版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089'   失败了。

Unhandled Exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Web服务只是有2种方法,一种是默认的HelloWorld的功能,并从我的MySQL数据库又返回一个值。在HelloWorld的功能工作正常。但是,当我从我的MySQL数据库调用,我得到上述错误。它可以在本地主机上运行时。

The web service just has 2 methods, one is the default "HelloWorld" function and another returns one value from my MySQL database. The "HelloWorld" function works fine. But when I call from my MySQL database, I get the above error. It works when ran in local host.

由于它是共享主机上GoDaddy的我不能运行完全信任的服务。我曾尝试加入<信任级别=中/> 到Web.config有希望让GoDaddy的运行该服务,但它给了同样的错误

As it is shared hosting on GoDaddy I cannot run the service with full trust. I have tried adding <trust level="Medium" /> to the Web.config to hopefully allow GoDaddy to run the service, but it gives the same error.

有什么我可以做从托管在GoDaddy的Web服务读入一个MySQL数据库值?

Is there anything I can do to read values in a MySQL database from a web service hosted on GoDaddy?

编辑:尝试在答案的建议由帕特里克·霍夫曼下方,仍然没有喜悦。确切相同的错误,即使它已被编译,以允许部分信任。任何其他的答案将是极大的AP preciated。

Tried the suggestions in the answer by Patrick Hofman below and still no joy. Exact same error, even though it has been compiled to allow partial trust. Any other answers would be greatly appreciated.

编辑2:尝试不同的dll文件从下面现在描述的越来越的SocketPermission 错误的项目。试图用ODBC代替,并获得 OdbcPermission 错误。我觉得这个故事的寓意是不要使用GoDaddy的。这一切都与他们中的信任和他们允许。要寻找到一个PHP的Web服务方法。不理想,但可能是唯一的出路。

EDIT 2: Tried various dlls from the projects described below and now getting SocketPermission errors. Tried to use ODBC instead and get OdbcPermission errors. I think the moral of the story is don't use GoDaddy. It's all to do with their medium trust and what they allow. Going to look into a php webservice method. Not ideal but might be the only way.

推荐答案

也许你需要设置Web应用程序所要求的权限模式。

Maybe you need to set the required permission mode of your web application.

此有关的安全模式一文可能是有用的。

此外,请参阅this文章对左右。

Also, see this article on SO.