.net 2.0 partial trust problems - mysql

Post here for help with installing or upgrading mojoPortal pre-compiled release packages. When posting in this forum, please provide all relevant details. You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

Post here for help with installation of mojoPortal pre-compiled release packages

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.

You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

This thread is closed to new posts. You must sign in to post in the forums.
4/12/2006 7:26:54 AM
Gravatar
Total Posts 4

Re: .net 2.0 partial trust problems - mysql

Hi all!

Great portal, can't wait to give it a spin, I've done lots of reading up on it!

I'm having particular issues with my hosting provider, the system is quite rightly locked down on medium(partial) trust, because its a shared server, unfortunately lots of things aren't working asp.net forums, some components and mojoPortal! here is my error, is there a way round this or any configuration tips for medium trust anyone knows??

I await someones wise feedback!

Paul Wroe (UK)

Unable to connect to any of the specified MySQL hosts

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[MySqlException: Unable to connect to any of the specified MySQL hosts]
MySql.Data.MySqlClient.NativeDriver.Open() +1201
MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() +147
MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() +434
MySql.Data.MySqlClient.MySqlPool.GetConnection() +56
MySql.Data.MySqlClient.MySqlPoolManager.GetConnection(MySqlConnectionString settings) +210
MySql.Data.MySqlClient.MySqlConnection.Open() +143
MySql.Data.MySqlClient.MySqlHelper.ExecuteReader(String connectionString, String commandText, MySqlParameter[] commandParameters) +51
mojoPortal.Data.dbPortal.FriendlyUrl_GetByUrl(String HostName, String FriendlyUrl) +238
mojoPortal.Business.FriendlyUrl.GetFriendlyUrl(String hostName, String friendlyUrl) +15
mojoPortal.Business.FriendlyUrl..ctor(String hostName, String friendlyUrl) +9
mojoPortal.Web.SiteUtils.RewriteUrl(HttpApplication app) +174
mojoPortal.Web.UrlRewriter.UrlRewriter_BeginRequest(Object sender, EventArgs e) +130
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

4/12/2006 7:34:07 AM
Gravatar
Total Posts 18439

Re: .net 2.0 partial trust problems - mysql

This is a common MySQL error that can be caused by a number of things, the most common of which is if MySQL is not configured to allow tcp/ip connections.

Google will find you other possible causes as well as documentation of this issue in the help pages on the MySQL site.

Thats about all the wisdom I have since I know nothing about the configuration on your hosted server.

Cheers,

Joe

ps: When pasting anything copied from an html page into these forums, please use the paste as Text toolbar item to paste it. Its the one with the clipboard and the T
4/12/2006 7:38:40 AM
Gravatar
Total Posts 18439

Re: .net 2.0 partial trust problems - mysql

This issue has also been posted in these forums before and the user was able to resolve it with my previous help:

See here http://dev.mysql.com/doc/mysql/en/can-not-connect-to-server.html
make sure your /etc/mysql/my.conf file does not have the "skip-networking" feature enabled. This is the default in some installations and disables tcp/ip connections.

Of course this is just the most common cause of the problem so I'm not sure it will solve it for you.

Cheers,

Joe
4/12/2006 7:43:02 AM
Gravatar
Total Posts 4

Re: .net 2.0 partial trust problems - mysql

ok we're getting there with this one, the error has changed now to this!

Unable to read the security policy file for trust level 'Medium'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Unable to read the security policy file for trust level 'Medium'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): Unable to read the security policy file for trust level 'Medium'.]
System.Web.HttpRuntime.SetTrustLevel(TrustSection trustSection, SecurityPolicySection securityPolicySection) +467
System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags) +239

[HttpException (0x80004005): Unable to read the security policy file for trust level 'Medium'.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +3426855
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +149


4/12/2006 7:50:04 AM
Gravatar
Total Posts 4

Re: .net 2.0 partial trust problems - mysql

And its changed again...there must be a way to run this using medium trust?

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +59
System.Web.HttpContext.System.IServiceProvider.GetService(Type service) +54
Brettle.Web.NeatUpload.UploadHttpModule.GetCurrentWorkerRequest() +27
Brettle.Web.NeatUpload.UploadHttpModule.Application_BeginRequest(Object sender, EventArgs e) +101
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64


4/12/2006 7:50:31 AM
Gravatar
Total Posts 18439

Re: .net 2.0 partial trust problems - mysql

I haven't done anything with partial trust configuration myself, but these 2 articles may help.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/HTCode_Acc.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/THCMCh09.asp


I think you need to create the policy file for medium trust as discussed in the second article and then add a tag in web.config specifying medium trust and the path to the policy file


Cheers,

Joe
4/12/2006 7:59:49 AM
Gravatar
Total Posts 148

Re: .net 2.0 partial trust problems - mysql

Try removing the NeatUpload UploadHttpModule from the <httpModules> section your Web.config.  NeatUpload definitely won't work in that environment.  I don't know whether the rest of mojoPortal will or not.

--Dean
4/12/2006 8:03:34 AM
Gravatar
Total Posts 18439

Re: .net 2.0 partial trust problems - mysql

Hey Dean,

Glad you chimed in I was wondering about that. I'm thinking for NeatUpload to work in this situation it would require being signed with a strong name key and installed in the GAC so that it had full trust. Do you think that would work?

I'm not sure about the rest of mojoportal either, when he removes NeatUpload from the pipeline it may just move the error to the UrlReWriter module or some other permission error.

Joe
4/12/2006 8:04:35 AM
Gravatar
Total Posts 4

Re: .net 2.0 partial trust problems - mysql

Thanks, Yeah I just tried that and its the same error,

What does mojoPortal and NeatUpload need full trust (or full access) to the machine level?

4/12/2006 8:16:55 AM
Gravatar
Total Posts 18439

Re: .net 2.0 partial trust problems - mysql

The above linked articles indicate what is allowed at each trust level:

Full Unrestricted permissions. Applications can access any resource that is subject to operating system security. All privileged operations are supported.
High Not able to call unmanaged code

Not able to call serviced components

Not able to write to the event log

Not able to access Microsoft Message Queuing queues

Not able to access OLE DB data sources

Note In ASP.NET 2.0, you can access OLE DB, Oracle, and ODBC data sources by customizing the policy and granting the appropriate permission; for example, OleDbPermission, OraclePermission, or OdbcPermission.

Medium In addition to the above, file access is restricted to the current application directory and registry access is not permitted.

No reflection permissions whatsoever. No sockets permission. Can send e-mail by using SMTP servers.

Note In ASP.NET 2.0, you can use the SQL Server data provider from medium-trust applications. You can also access OLE DB, Oracle, and ODBC data sources by customizing the trust-level policy and granting the appropriate permission; for example, OleDbPermission, OraclePermission, or OdbcPermission.

Low In addition to the above, the application is not able to connect to SQL Server and code cannot call CodeAccessPermission.Assert (no assertion security permission).

Read-only access for file I/O within the application's virtual directory structure.
Minimal Only the execute permission is available.

At medium trust you can't use System.Reflection at all. Since mojoPortal does use some reflection I think you will not be able to get it to run in medium trust

NeatUpload hooks into the HttpRequest to handle large file uploads and apparently that is also restricted in medium trust.

It might work at high trust since we don't use any unmanaged code.
4/12/2006 9:44:46 AM
Gravatar
Total Posts 148

Re: .net 2.0 partial trust problems - mysql

Joe,

Installing NeatUpload in the GAC might allow it to work, but I don't have a good way to test that since Mono's CAS support isn't complete and I don't have GAC access on any Windows machine with IIS.  If you have a chance to give it a try at some point, I'd love to know whether it works.  It's not a high-priority though since this situation seems pretty rare.

--Dean
You must sign in to post in the forums. This thread is closed to new posts.