This project is read-only.

Installing N2CMS on a shared host

Topics: Developer Forum, User Forum
Jun 2, 2008 at 4:27 PM
Hi,

We've successfully deployed N2CMS on my local machine. We couldn't find any documentation on how to install it to an online server, so we thought it's just a simple case of uploading the compiled project (locally working version) online. So we uploaded all the files within the "WebProject" folder to our online host. making changes to the web.config's database connection string to our online MS SQL database.

We get the error outlined below when trying to run the N2CMS online, and with our limited knowledge of ASP.NET, we can't figure out if it's our config problem, or it's an issue with our host. I could find only one thread relating to this issue on this topic, and no clear answer could be found on there.

I attach the copy of the error below, it's something to do with host's trust issue. We don't plan to change hosts, and it's highly unlikely that our host will change our trust level. I guess my question is: Is there a way around this? Is there something I can do in the config to resolve this issue and run N2CMS on my shared host? Any help will be greatly appreciated.

Thank you,

Error:

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: That assembly does not allow partially trusted callers.

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: That assembly does not allow partially trusted callers.]
N2.Engine.CmsEngine..ctor() +0
N2.Context.CreateEngineInstance() +38
N2.Context.Initialize(Boolean forceRecreate) +78
N2.Installation.InstallerModule.Init(HttpApplication context) +73
System.Web.HttpApplication.InitModulesCommon() +66
System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +1006
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +259
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +114
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +350
Jun 2, 2008 at 5:06 PM
Dit you try the MediumTrust example on your host?
It is located on \Source\src\Examples\MediumTrust\ in the N2 Source Code download.

If that one fails then there is a real problem with the trust level your host provides in combination with .
Jun 2, 2008 at 9:50 PM

Try this:

  • Edit web.config
  • Remove any n2 related modules from <configuration><system.web><httpModules><add name="n2...
  • On your local machine go to /edit/install/mediumtrust.aspx
  • Use the generated web.config exceprts and insert into your configuration.
  • To try locally you can add <configuration><system.web><trust level="Medium"/>

 

Jun 3, 2008 at 9:53 AM
Edited Jun 3, 2008 at 10:09 AM
Hi Martijn,

Thanks for your reply, I have tried the MediumTrust example, but before I could try it on the host, I couldn't even Build & Run it on MS VStudio, it says there's 4 Warnings and 35 Errors, and it doesn't even want to run locally. So I thought it might be a waste of bandwidth & time trying to upload it.



Hi libardo,

Thanks for suggestions, I tried as you suggested made changes to the web.config. But keep running into different errors.

I have called my host, Fasthosts.co.uk, and they said we have their "Full Trust" package, so it shouldn't be a trust level problem. I was just wondering if any of you who successfully put N2CMS on a shared host, could provide us with some guidance as to how you manage to achieve this, i.e. simple step by step instructions? Or maybe even a copy of a functioning web.config file would be much appreciated.


My host has e-mailed me since I called them to help resolve the issue. They have instructed me with following:
The assembly concerned should initially be recompiled with the following line added:
[assembly:AllowPartiallyTrustedCallers] and this should get us past this error.

The problem is I don't know where to insert this bit of code "AllowPartiallyTrustedCallers". I tried to put it in "AssemblyInfo.cs" and it threw 2 errors:
Error    1    The type or namespace name 'AllowPartiallyTrustedCallers' could not be found (are you missing a using directive or an assembly reference?)    C:\N2CMS\WebProject\Properties\AssemblyInfo.cs    36    12    MyProject
Error    2    The type or namespace name 'AllowPartiallyTrustedCallersAttribute' could not be found (are you missing a using directive or an assembly reference?)    C:\N2CMS\WebProject\Properties\AssemblyInfo.cs    36    12    MyProject

Any help on this is greatly appreciated.

Kind regards,
Baysaa.
Jun 3, 2008 at 9:52 PM
Your problem might be related to the InstallerModule. Try removing it from the httpModules section in web.config.
Jun 4, 2008 at 9:19 AM
Edited Jun 4, 2008 at 9:21 AM
Thanks for your continued help libardo.

Unfortunately, my httpModules looks like the following:

        <httpModules>
            <!--<add name="n2.installer" type="N2.Installation.InstallerModule, N2"/>-->
            <!--<add name="n2.initializer" type="N2.Web.InitializerModule, N2"/>-->
            <!--<add name="n2.mediumTrustInitializer" type="N2.MediumTrust.Web.InitializerModule, N2"/>-->
        </httpModules>

It's all commented out. I would love to get N2CMS running online, I really like it. I'll post my web.config below. And any other suggestions will be greatly appreciated.

 
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <configSections>
        <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" />

        <sectionGroup name="n2" type="N2.Configuration.N2ConfigurationSectionHandler, N2">
            <section name="mediumTrust" type="N2.MediumTrust.Configuration.MediumTrustSectionHandler, N2" requirePermission="false"/>
        </sectionGroup>
    </configSections>

    <connectionStrings>
        <!-- Some connection string examples
        SQLite:            <add name="N2CMS" connectionString="Data Source=|DataDirectory|\n2blog.db;Version=3;New=True;" providerName="System.Data.SQLite"/>
        SQL Server 2005:    <add name="N2CMS" connectionString="Server=(local);Database=N2_Templates;Integrated Security=SSPI"/>
        SQL Express 2005:    <add name="N2CMS" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\N2.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
        SQL Server 2000:    <add name="N2CMS" connectionString="Data Source=SQLServer2000;Database=SQLDatabase2000;User Id=SqlUser2000;Password=SqlPassword2000;Network Library=DBMSSOCN;" providerName="System.Data.SqlClient"/>
        MySQL:            <add name="N2CMS" connectionString="Data Source=MySQLServer;Database=MySQLDatabase;User Id=MySQLUser;Password=MySQLPassword;" providerName="MySql.Data.MySqlClient"/>
        -->
    <add name="N2CMS" connectionString="Data Source=MSSQLHost;Database=MyDBName;User Id=uid;Password=pwd;Network Library=DBMSSOCN;" providerName="System.Data.SqlClient"/>
    <!--<add name="N2CMS" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\N2.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>-->
    </connectionStrings>

    <castle>
        <!-- Required properties -->
        <properties>
            <rootItemID>1</rootItemID>
            <startPageID>2</startPageID>
            <nhSettings>
                <dictionary>
                    <entry key="connection.provider">NHibernate.Connection.DriverConnectionProvider</entry>
                    <entry key="connection.connection_string_name">N2CMS</entry>

                    <!-- set use_second_level_cache to true and uncomment this to enable cache -->
                    <entry key="cache.use_second_level_cache">true</entry>
                    <entry key="cache.use_query_cache">true</entry>
                    <entry key="cache.provider_class">NHibernate.Caches.SysCache2.SysCacheProvider,NHibernate.Caches.SysCache2</entry>

                    <!-- SQL Server 2005
                    <entry key="connection.driver_class">NHibernate.Driver.SqlClientDriver</entry>
                    <entry key="dialect">NHibernate.Dialect.MsSql2005Dialect</entry> -->
          <!-- SQLite
                      <entry key="connection.driver_class">NHibernate.Driver.SQLite20Driver</entry>
                      <entry key="dialect">NHibernate.Dialect.SQLiteDialect</entry>
                      -->
                    <!-- SQL Server 2000 -->
                      <entry key="connection.driver_class">NHibernate.Driver.SqlClientDriver</entry>
                      <entry key="dialect">NHibernate.Dialect.MsSql2000Dialect</entry>
                     
                    <!-- MySQL
                      <entry key="connection.driver_class">NHibernate.Driver.MySqlDataDriver</entry>
                      <entry key="dialect">NHibernate.Dialect.MySQL5Dialect</entry>
                      -->
                </dictionary>
            </nhSettings>
        </properties>

        <!-- Default configuration -->
        <include uri="assembly://N2/Engine/n2.configuration.xml"/>

        <!-- Changed configuration of the services goes here -->
        <components>
            <component id="n2.defaultSite">
                <parameters>
                    <rootItemID>#{rootItemID}</rootItemID>
                    <startPageID>#{startPageID}</startPageID>
                </parameters>
            </component>
        </components>
    </castle>

    <n2>
        <mediumTrust rootItemID="1" startPageID="2">
            <assemblies>
                <add assembly="N2"/>
                <add assembly="N2.Templates.UI"/>
                <add assembly="Demo"/>
                <add assembly="N2.Edit"/>
                <add assembly="N2.Security"/>
                <add assembly="N2.Templates.Advertisement"/>
                <add assembly="N2.Templates.Calendar"/>
                <add assembly="N2.Templates"/>
                <add assembly="N2.Templates.Faq"/>
                <add assembly="N2.Templates.Form"/>
                <add assembly="N2.Templates.ImageGallery"/>
                <add assembly="N2.Templates.News"/>
                <add assembly="N2.Templates.Poll"/>
                <add assembly="N2.Templates.RSS"/>
                <add assembly="N2.Templates.Scrum"/>
                <add assembly="N2.Templates.Search"/>
                <add assembly="N2.Templates.SEO"/>
                <add assembly="N2.Templates.Survey"/>
                <add assembly="N2.Templates.Syndication"/>
            </assemblies>
            <nhProperties>
                <add key="connection.connection_string_name" value="N2CMS"/>
                <add key="cache.use_query_cache" value="false"/>
                <add key="cache.use_second_level_cache" value="false"/>
                <add key="cache.provider_class" value="NHibernate.Caches.SysCache2.SysCacheProvider,NHibernate.Caches.SysCache2"/>
                <add key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
                <add key="use_reflection_optimizer" value="false"/>
                <add key="dialect" value="NHibernate.Dialect.MsSql2000Dialect"/>
                <add key="connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
            </nhProperties>
        </mediumTrust>
    </n2>

    <system.web>
        <!--<globalization uiCulture="nl-NL" culture="nl-NL" />-->
        <!--<globalization uiCulture="it-IT" culture="it-IT" />-->
        <!--<trust level="Medium"/>-->

        <pages validateRequest="false">
            <controls>
                <add tagPrefix="n2" namespace="N2.Web.UI.WebControls" assembly="N2" />
                <add tagPrefix="n2" namespace="N2.Templates.Web.UI.WebControls" assembly="N2.Templates"/>
            </controls>
        </pages>

        <httpModules>
            <!--<add name="n2.installer" type="N2.Installation.InstallerModule, N2"/>-->
            <!--<add name="n2.initializer" type="N2.Web.InitializerModule, N2"/>-->
            <!--<add name="n2.mediumTrustInitializer" type="N2.MediumTrust.Web.InitializerModule, N2"/>-->
        </httpModules>

        <httpHandlers>
            <add path="*.n2.ashx" verb="*" type="N2.Web.AjaxRequestHandler, N2" />
        </httpHandlers>

        <siteMap defaultProvider="PublicSiteMap">
            <providers>
                <add name="PublicSiteMap" type="N2.Web.PublicSiteMapProvider, N2" startPageIsRoot="true"/>
            </providers>
        </siteMap>

        <compilation debug="true">
            <expressionBuilders>
                <add expressionPrefix="CurrentItem" type="N2.Web.Compilation.CurrentItemExpressionBuilder, N2"/>
                <add expressionPrefix="CurrentPage" type="N2.Web.Compilation.CurrentPageExpressionBuilder, N2"/>
                <add expressionPrefix="StartPage" type="N2.Web.Compilation.StartPageExpressionBuilder, N2"/>
                <add expressionPrefix="Code" type="N2.Web.Compilation.CodeExpressionBuilder, N2"/>
                <add expressionPrefix="HasValue" type="N2.Web.Compilation.HasValueExpressionBuilder, N2"/>
            </expressionBuilders>
        </compilation>

        <authentication mode="Forms">
            <forms loginUrl="edit/login.aspx" protection="All" timeout="30000" path="/">
                <credentials passwordFormat="Clear">
                    <!-- WARNING: Change this default password -->
                    <user name="admin" password="admin"/>
                </credentials>
            </forms>
        </authentication>

        <customErrors mode="Off">
            <error statusCode="404" redirect="~/404.aspx" />
        </customErrors>

        <membership defaultProvider="ContentMembershipProvider">
            <providers>
                <clear/>
                <add name="ContentMembershipProvider" type="N2.Security.ContentMembershipProvider, N2.Security" />
            </providers>
        </membership>
        <roleManager enabled="true" defaultProvider="ContentRoleProvider">
            <providers>
                <clear/>
                <add name="ContentRoleProvider" type="N2.Security.ContentRoleProvider, N2.Security" />
            </providers>
        </roleManager>
    </system.web>

    <appSettings>
        <add key="Corporate.MenuHandoverLevel" value="3" />
        <add key="n2cms.com.MenuHandoverLevel" value="3" />
    </appSettings>
</configuration>
Jun 4, 2008 at 5:21 PM
Can you try uncommenting the medium trust initializer?

        <httpModules>
            <!--<add name="n2.installer" type="N2.Installation.InstallerModule, N2"/>-->
            <!--<add name="n2.initializer" type="N2.Web.InitializerModule, N2"/>-->
            <add name="n2.mediumTrustInitializer" type="N2.MediumTrust.Web.InitializerModule, N2"/>
        </httpModules>
Jun 5, 2008 at 9:14 AM
Yes I can,

But I doubt it will do any good, since it was uncommented on the initial installation. And I had the error when it was uncommented. Then according to your first reply, I commented them out, but it wasn't any help.

Quote: "Remove any n2 related modules from <configuration><system.web><httpModules><add name="n2..."


Thanks for your continued help. Maybe I should try a fresh installation...
Jun 5, 2008 at 11:55 AM
Aha, I think I see it.

Remove:
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" />

And:
<castle>
    ...
</castle>


Jul 27, 2008 at 4:58 PM
I'm having trouble with the source/examples in particular the mediumtrust example. I run all the .bat's and can't get it to run.

I continue to get the following errors:
Error    1    Could not load type 'MediumTrustTest.Watch'.    \Visual Studio 2008\Projects\N2CMS\Sources\examples\MediumTrust\wwwroot\Watch.ascx    1   
Error    2    Could not load type 'MediumTrustTest._Default'.  \Visual Studio 2008\Projects\N2CMS\Sources\examples\MediumTrust\wwwroot\Default.aspx    1   

I have no trouble running the Example_VB download
\Visual Studio 2008\Projects\N2CMS\Example_VB\wwwroot

Any idea what to try?


Jul 27, 2008 at 5:24 PM
further research. when I added the " <trust level="Medium"/>" tag to the web.config of the working Example_VB project it broke. according to someone SQLite requires full trust, is that true? Also on the medium trust example it was using a SQL Express database but still has references to SQLite somewhere in the code even without the dll reference.
Jul 27, 2008 at 7:07 PM
It's probably because the system.data.sqlite.dll gets copied to the bin folder. Try removing the file.
Jul 27, 2008 at 10:45 PM
I did initially exclude it which changed the name to .dll.exluded with your reply I actually deleted the file.

I still get the following error with the file excluded or actually deleted:
Cannot instantiate abstract class or interface: N2.ContentItem

btw, i get no errors when I build/rebuild the project in VS2008.
Jul 27, 2008 at 11:01 PM
You might need to configure assemblies to load:

    <engine>
      <assemblies>
        <add assembly="N2"/>
        <add assembly="N2.Security"/>
        <add assembly="N2.Edit"/>
        <add assembly="MyProject"/>
      </assemblies>
Jul 27, 2008 at 11:05 PM
actually I think this last one might be my just dropping a sqlserver db into the App_Data folder but I'll check those setting as well. I'll save any more replies until I get some more experience with N2.
Aug 16, 2008 at 10:24 PM
I've spent the last 3-4 hours trying to get n2cms working in a medium trust environment. Even the medium trust example fails at the N2.Engine.CmsEngine constructor. Is there any hope? Please tell me someone has this working in a shared hosting environment.

Thanks!
Eric
Aug 17, 2008 at 8:31 PM
Hi. What version are you using? I'm asking since I renamed CmsEngine to ContentEngine prior to the last release.

By the way the ContentEngine shouldn't have been created in medium trust. Instead there's a MediumTrustEngine that should be used if a security exception was thrown during new ContentEngine()...

Also ensure that you don't have any System.Data.SQLite in your bin folder.
Aug 20, 2008 at 9:29 PM
Hi,

I have the same problem.

When I visited castle's website. I saw that it can be complied to work with medium trust settings ( http://forum.castleproject.org/viewtopic.php?p=6150 ) but I couldn't manage to compile it.

Can anyone provide compiled binaries please?

Thanks in advance
Aug 20, 2008 at 10:33 PM
Hi ,could you post a stack trace?
Aug 21, 2008 at 9:41 AM

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: That assembly does not allow partially trusted callers.

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: That assembly does not allow partially trusted callers.]
N2.Engine.ContentEngine..ctor() +0
N2.Context.CreateEngineInstance() +194
N2.Context.Initialize(Boolean forceRecreate) +172
N2.Installation.InstallerModule.Init(HttpApplication application) +204
System.Web.HttpApplication.InitModulesCommon() +66
System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +1006
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +259
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +114
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +350


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
Aug 21, 2008 at 9:45 AM
I tried everything in this thread but didn't solve the problem :( I have the latest version and I really loved your product and I want to run it on medium trust.

Thank you for your help and fast replies.
Aug 21, 2008 at 8:41 PM
Hi, I committed a change that might help. However I can't test it (cannot reproduce). Can you pull code from source repository and try?
Aug 21, 2008 at 10:52 PM
Hi libardo,

Thanks for the help :)

I'm pulling the code now. There are 3 folders but I'm sure that I'll figure out which one you are talking about.

By the way, if you want, I can provide test environment even if it works or not.

Thanks again :)
Aug 21, 2008 at 11:30 PM
Hi libardo,

I just saw that I had to download source from googlecode, not codeplex.

I tried Prepare_Dependencies-vs2008.bat as soon as I got the code but it couldn't finish successfully.

---

Assuming msbuild location: C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe

C:\Users\zoozalp\Desktop\n2gg>C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.ex
e /maxcpucount /target:PrepareDependencies
Microsoft (R) Build Engine Version 3.5.30729.1
[Microsoft .NET Framework, Version 2.0.50727.3053]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 8/22/2008 1:26:43 AM.
     1>Project "C:\Users\zoozalp\Desktop\n2gg\msbuild.proj" on node 0 (PrepareD
       ependencies target(s)).
         Copying file from ".\lib\Castle.Core.dll" to ".\src\wwwroot\Bin\Castle
         .Core.dll".
         Copying file from ".\lib\Castle.DynamicProxy2.dll" to ".\src\wwwroot\B
         in\Castle.DynamicProxy2.dll".
         Copying file from ".\lib\Castle.MicroKernel.dll" to ".\src\wwwroot\Bin
         \Castle.MicroKernel.dll".
         Copying file from ".\lib\Castle.Windsor.dll" to ".\src\wwwroot\Bin\Cas
         tle.Windsor.dll".
         Copying file from ".\lib\Iesi.Collections.dll" to ".\src\wwwroot\Bin\I
         esi.Collections.dll".
         Copying file from ".\lib\log4net.dll" to ".\src\wwwroot\Bin\log4net.dl
         l".
         Copying file from ".\lib\NHibernate.dll" to ".\src\wwwroot\Bin\NHibern
         ate.dll".
         Copying file from ".\lib\System.Data.SQLite.dll" to ".\src\wwwroot\Bin
         \System.Data.SQLite.dll".
     1>Project "C:\Users\zoozalp\Desktop\n2gg\msbuild.proj" (1) is building "C:
       \Users\zoozalp\Desktop\n2gg\src\N2.Everything-vs2008.sln" (2) on node 1
       (default targets).
         Building solution configuration "Release|Any CPU".
     2>Project "C:\Users\zoozalp\Desktop\n2gg\src\N2.Everything-vs2008.sln" (2)
        is building "C:\Users\zoozalp\Desktop\n2gg\src\N2\N2.csproj" (3) on nod
       e 0 (default targets).
       Skipping target "CoreCompile" because all output files are up-to-date wi
       th respect to the input files.
     3>_CopyOutOfDateSourceItemsToOutputDirectory:
       Skipping target "_CopyOutOfDateSourceItemsToOutputDirectory" because all
        output files are up-to-date with respect to the input files.
       CopyFilesToOutputDirectory:
         N2 -> C:\Users\zoozalp\Desktop\n2gg\src\N2\bin\N2.dll
     3>Done Building Project "C:\Users\zoozalp\Desktop\n2gg\src\N2\N2.csproj" (
       default targets).
     2>Project "C:\Users\zoozalp\Desktop\n2gg\src\N2.Everything-vs2008.sln" (2)
        is building "C:\Users\zoozalp\Desktop\n2gg\src\N2.Extensions\N2.Extensi
       ons.csproj" (4) on node 0 (default targets).
         Processing 0 EDMX files.
         Finished processing 0 EDMX files.
     2>Project "C:\Users\zoozalp\Desktop\n2gg\src\N2.Everything-vs2008.sln" (2)
        is building "C:\Users\zoozalp\Desktop\n2gg\src\N2.Tests\N2.Tests.csproj
       " (5) on node 0 (default targets).
         Processing 0 EDMX files.
         Finished processing 0 EDMX files.
     4>CoreCompile:
       Skipping target "CoreCompile" because all output files are up-to-date wi
       th respect to the input files.
     5>CoreCompile:
       Skipping target "CoreCompile" because all output files are up-to-date wi
       th respect to the input files.
     4>_CopyOutOfDateSourceItemsToOutputDirectory:
       Skipping target "_CopyOutOfDateSourceItemsToOutputDirectory" because all
        output files are up-to-date with respect to the input files.
       CopyFilesToOutputDirectory:
         N2.Extensions -> C:\Users\zoozalp\Desktop\n2gg\src\N2.Extensions\bin\N
         2.Extensions.dll
     5>_CopyOutOfDateSourceItemsToOutputDirectory:
       Skipping target "_CopyOutOfDateSourceItemsToOutputDirectory" because all
        output files are up-to-date with respect to the input files.
       _CopyOutOfDateSourceItemsToOutputDirectoryAlways:
         Copying file from "C:\Users\zoozalp\Desktop\n2gg\src\N2.Tests\Serializ
         ation\TestFile.txt" to "bin\Serialization\TestFile.txt".
       _CopyAppConfigFile:
       Skipping target "_CopyAppConfigFile" because all output files are up-to-
       date with respect to the input files.
       CopyFilesToOutputDirectory:
         N2.Tests -> C:\Users\zoozalp\Desktop\n2gg\src\N2.Tests\bin\N2.Tests.ex
         e
     4>Done Building Project "C:\Users\zoozalp\Desktop\n2gg\src\N2.Extensions\N
       2.Extensions.csproj" (default targets).
     5>Done Building Project "C:\Users\zoozalp\Desktop\n2gg\src\N2.Tests\N2.Tes
       ts.csproj" (default targets).
     2>Project "C:\Users\zoozalp\Desktop\n2gg\src\N2.Everything-vs2008.sln" (2)
        is building "C:\Users\zoozalp\Desktop\n2gg\src\N2.Security\N2.Security.
       csproj" (6) on node 1 (default targets).
       Skipping target "CoreCompile" because all output files are up-to-date wi
       th respect to the input files.
     2>Project "C:\Users\zoozalp\Desktop\n2gg\src\N2.Everything-vs2008.sln" (2)
        is building "C:\Users\zoozalp\Desktop\n2gg\src\N2.Templates\N2.Template
       s.csproj" (7) on node 1 (default targets).
       Skipping target "CoreCompile" because all output files are up-to-date wi
       th respect to the input files.
     2>Project "C:\Users\zoozalp\Desktop\n2gg\src\N2.Everything-vs2008.sln" (2)
        is building "C:\Users\zoozalp\Desktop\n2gg\src\wwwroot\N2.Edit.csproj"
       (8) on node 1 (default targets).
     8>CSC : error CS2001: Source file 'Edit\KeepAlive\Ping.ashx.cs' could not
       be found
     8>Done Building Project "C:\Users\zoozalp\Desktop\n2gg\src\wwwroot\N2.Edit
       .csproj" (default targets) -- FAILED.
     6>_CopyOutOfDateSourceItemsToOutputDirectory:
       Skipping target "_CopyOutOfDateSourceItemsToOutputDirectory" because all
        output files are up-to-date with respect to the input files.
     7>_CopyOutOfDateSourceItemsToOutputDirectory:
       Skipping target "_CopyOutOfDateSourceItemsToOutputDirectory" because all
        output files are up-to-date with respect to the input files.
     6>CopyFilesToOutputDirectory:
         N2.Security -> C:\Users\zoozalp\Desktop\n2gg\src\N2.Security\bin\N2.Se
         curity.dll
     7>CopyFilesToOutputDirectory:
         N2.Templates -> C:\Users\zoozalp\Desktop\n2gg\src\N2.Templates\bin\Rel
         ease\N2.Templates.dll
     6>Done Building Project "C:\Users\zoozalp\Desktop\n2gg\src\N2.Security\N2.
       Security.csproj" (default targets).
     7>Done Building Project "C:\Users\zoozalp\Desktop\n2gg\src\N2.Templates\N2
       .Templates.csproj" (default targets).
     1>Done Building Project "C:\Users\zoozalp\Desktop\n2gg\msbuild.proj" (Prep
       areDependencies target(s)) -- FAILED.
     2>Done Building Project "C:\Users\zoozalp\Desktop\n2gg\src\N2.Everything-v
       s2008.sln" (default targets) -- FAILED.

Build FAILED.

       "C:\Users\zoozalp\Desktop\n2gg\msbuild.proj" (PrepareDependencies target
       ) (1) ->
       "C:\Users\zoozalp\Desktop\n2gg\src\N2.Everything-vs2008.sln" (default ta
       rget) (2) ->
       "C:\Users\zoozalp\Desktop\n2gg\src\wwwroot\N2.Edit.csproj" (default targ
       et) (8) ->
       (CoreCompile target) ->
         CSC : error CS2001: Source file 'Edit\KeepAlive\Ping.ashx.cs' could no
       t be found

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.40
Press any key to continue . . .
Aug 22, 2008 at 7:21 AM
Oh, missing file. Try again
Aug 22, 2008 at 11:38 AM
Hi libardo,

You are great! It works on my medium trust local IIS installation.

However it doesn't work on godaddy, I contacted them and it will be a great disappointment if they can't make this work with their hosting service.

Thank you thousand times :)
Aug 22, 2008 at 1:25 PM
It works now!

Thanks for the kind and fast support libardo :))) You are the BEST!!!

Aug 23, 2008 at 12:41 AM
=) Good to know it works. Did they have to change anything notable? Anything that might be useful for the next guy?
Aug 23, 2008 at 1:39 AM
Medium trust project went very smooth. No modifications required.

I'm trying to make templates implementation work on medium settings and it involves some modifications. I'll write down instructions as soon as I manage to convert it.
Aug 23, 2008 at 12:29 PM
Hi,

Here is the path I followed to make Templates Example work in my local medium trust IIS environment.


1. Download TortoiseSVN from http://tortoisesvn.tigris.org/
2. By using TortoiseSVN, checkout latest source code from http://n2cms.googlecode.com/svn/trunk/
3. Go to examples\MediumTrust folder and open N2.Examples.MediumTrust-vs2008.sln
    Change solution name to MediumTrust in Solution Explorer
    Goto Project/MediumTrust properties on the menu
    Change Assembly name and Default namespace to MediumTrust
    Save and quit
4. Go to src folder and open N2.Everything-vs2008.sln
    You will get messages stating that some folders are not supported, just ignore them
    Build the project by hitting Ctrl+Shift+B keys and see if you will get any errors
    You shouldn't have any errors but 4 warnings
    Double click on "Warning 4 Found conflicts between different versions of the same dependent assembly. N2.Extensions.Tests" and Click yes to let visual web developer fix it.
    Build again, save and quit
5. Run Prepare_Dependencies-vs2008.bat in the root folder
6. Go to examples\TemplatesSite\wwwroot\bin folder and delete System.Data.SQLite.dll
7. Go to examples\TemplatesSite\wwwroot and edit Web.config
    Modify connection string. Mine is something like <add name="N2CMS" connectionString="Server=(local);Database=N2;User Id=myuser;Password=mypassword;" />
    Modify flavour. Mine is <database connectionStringName="N2CMS" flavour="SqlServer2005" />
    Find <engine> and remove the commented out lines
        <assemblies>
                <!-- These are only really needed for medium trust-->
            <add assembly="N2"/>
            <add assembly="N2.Security"/>
            <add assembly="N2.Edit"/>            <add assembly="N2.Templates"/>
            <add assembly="N2.Templates.UI"/>
        </assemblies>
    Change admin password and email settings
    Save and quit
8. Go to IIS Manager and create n2 application and make sure that it points to \examples\TemplatesSite\wwwroot folder.
9. Create an empty database named N2 on your Sql Server.
10. Open internet explorer and go to http://localhost/n2
    Follow on screen instructions to complete the setup.

   

Aug 23, 2008 at 1:45 PM
Oh, one last thing. Installer doesn't work on godaddy.

I couldn't figure out why but if you are using their hosting, you better install on your local server and user database publishing wizard to copy your database into their servers.

Here is the instructions:

http://products.secureserver.net/products/hosting/PublishingWithDPW.htm

Zekai
Aug 25, 2008 at 8:12 PM

HELP? trying to set up with godaddy ....

Server Error in '/' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: This configuration section cannot be used at this path.  This happens when the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file.

Source Error:

Line 50: 		<!--<globalization uiCulture="nl-NL" culture="nl-NL" />-->
Line 51: <!--<globalization uiCulture="it-IT" culture="it-IT" />-->
Line 52: <trust level="Medium"/>
Line 53: <sessionState mode="Off"/>
Line 54: <pages enableViewState="false" validateRequest="false">
Aug 25, 2008 at 9:02 PM
remove
<trust level="Medium"/>

you can't change it in godaddy. btw, it's already set to medium.

Aug 28, 2008 at 5:25 AM
Edited Aug 28, 2008 at 5:26 AM
I am still having issue not even on  my local host. i am using IIS7

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: That assembly does not allow partially trusted callers.
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: That assembly does not allow partially trusted callers.]
N2.Engine.ContentEngine..ctor() +0
N2.Context.CreateEngineInstance() +238
N2.Context.Initialize(Boolean forceRecreate) +187
N2.Web.InitializerModule.Init(HttpApplication context) +39
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +406
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +188
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +295
System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr appContext, HttpContext context) +56
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +231


Version Information: Microsoft .NET Framework Version:2.0.50727.3031; ASP.NET Version:2.0.50727.3031





with this web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <configSections>
    <sectionGroup name="n2" type="N2.Configuration.SectionGroup, N2">
      <section name="host" type="N2.Configuration.HostSection, N2" requirePermission="false" />
      <section name="engine" type="N2.Configuration.EngineSection, N2" requirePermission="false" />
      <section name="database" type="N2.Configuration.DatabaseSection, N2" requirePermission="false" />
      <section name="edit" type="N2.Configuration.EditSection, N2" requirePermission="false" />
      <section name="templates" type="N2.Templates.Configuration.TemplatesSection, N2.Templates"

requirePermission="false" />
    </sectionGroup>
  </configSections>

  <connectionStrings>
    <remove name="N2CMS"/>
    <add name="N2CMS" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\N4.mdf;Integrated

Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>

 
  <n2 xmlns="http://n2cms.com/schemas/configuration/v3">
    <!-- If you install a database from scrach you'll need to insert some required pages.
    This can be done by the web based installer located at http://yoursite/install/edit -->
    <host rootID="1" startPageID="2" multipleSites="false">
      <outputCache enabled="false" duration="10" />
      <!-- Set extension="/" for friendlier urls -->
      <web extension=".aspx" />
    </host>
    <engine>
      <assemblies>
        <!-- These are only needed for medium trust -->
        <add assembly="N2"/>
                <add assembly="N2.Security"/>
                <add assembly="N2.Edit"/>
                <add assembly="N2.Templates"/>
                <add assembly="N2.Templates.UI"/>
       
      </assemblies>
      <errors action="Email" mailTo="" mailFrom="noreply@gicofcolo.com" />
      <globalization enabled="false" />
      <scheduler keepAlive="true" interval="10" />
    </engine>
    <!-- Other flavours: SqlServer2005, SqlServer2000, MySql, SqLite, SqlCe, Firebird -->
    <database connectionStringName="N2CMS" flavour="SqlServer2005" />
    <edit>
      <installer checkInstallationStatus="true" />
      <uploadFolders>
        <add path="Upload"/>
      </uploadFolders>
    </edit>
    <templates masterPageFile="~/Layouts/Top.Master"/>
  </n2>

 
  <system.web>
    <!--<globalization uiCulture="it-IT" culture="it-IT" />-->
    <trust level="Medium"/>

    <sessionState mode="Off" />

    <pages enableViewState="false" validateRequest="false">
      <controls>
        <add tagPrefix="n2" namespace="N2.Web.UI.WebControls" assembly="N2" />
        <add tagPrefix="n2" namespace="N2.Templates.Web.UI.WebControls" assembly="N2.Templates" />
        <add tagPrefix="GC" namespace="GC.Controls"/>
      </controls>
    </pages>

    <!-- Please remove the 'n2.installer' module below once the site has
         been installed. This prevents unsuspecting users from reaching the
         installer screen if the database connection fails. -->
    <httpModules>
      <add name="n2.mediumTrustInitializer" type="N2.MediumTrust.Web.InitializerModule, N2"/>
      <add name="n2.initializer" type="N2.Web.InitializerModule, N2" />
    </httpModules>

    <httpHandlers>
      <add path="*.n2.ashx" verb="*" type="N2.Web.AjaxRequestHandler, N2" />
    </httpHandlers>

    <siteMap defaultProvider="PublicSiteMap">
      <providers>
        <add name="PublicSiteMap" type="N2.Web.PublicSiteMapProvider, N2" startPageIsRoot="true" />
      </providers>
    </siteMap>

    <compilation debug="true">
      <expressionBuilders>
        <add expressionPrefix="CurrentItem" type="N2.Web.Compilation.CurrentItemExpressionBuilder, N2" />
        <add expressionPrefix="CurrentPage" type="N2.Web.Compilation.CurrentPageExpressionBuilder, N2" />
        <add expressionPrefix="StartPage" type="N2.Web.Compilation.StartPageExpressionBuilder, N2" />
        <add expressionPrefix="Code" type="N2.Web.Compilation.CodeExpressionBuilder, N2" />
        <add expressionPrefix="HasValue" type="N2.Web.Compilation.HasValueExpressionBuilder, N2" />
      </expressionBuilders>
    </compilation>

    <authentication mode="Forms">
      <forms loginUrl="edit/login.aspx" protection="All" timeout="30000" path="/">
        <credentials passwordFormat="Clear">
          <!-- WARNING: Change this default password. Please do it now. -->
          <user name="admin" password="" />
        </credentials>
      </forms>
    </authentication>

    <customErrors mode="Off" defaultRedirect="~/UI/500.aspx">
      <error statusCode="404" redirect="~/UI/404.aspx" />
    </customErrors>

    <!-- These membership and role providers store their data as content items.
         You can also use the forms authentication credentials only (then remove
         these sections) or the default ASP.NET providers (search for asp.net membership) -->
    <membership defaultProvider="AspNetSqlMembershipProvider">
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web,

Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="N2CMS"

enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/"

requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5"

minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="20" passwordStrengthRegularExpression=""/>
      </providers>
    </membership>
    <roleManager enabled="true">
      <providers>
        <remove name="AspNetSqlRoleProvider"/>
        <add name="AspNetSqlRoleProvider" connectionStringName="N2CMS" applicationName="/"

type="System.Web.Security.SqlRoleProvider,               System.Web, Version=2.0.0.0, Culture=neutral,              

                               PublicKeyToken=b03f5f7f11d50a3a"/>
      </providers>
    </roleManager>
    <profile defaultProvider="AspNetSqlProfileProvider">
      <providers>
        <remove name="AspNetSqlProfileProvider"/>
        <add name="AspNetSqlProfileProvider" connectionStringName="N2CMS" applicationName="/"

type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a"/>
      </providers>
      <properties>
        <add name="FirstName" type="String"/>
        <add name="LastName" type="String"/>
        <add name="Gender" type="String"/>
        <add name="BirthDate" type="DateTime"/>
        <group name="Address">
          <add name="Street" type="String"/>
          <add name="PostalCode" type="String"/>
          <add name="City" type="String"/>
          <add name="State" type="String"/>
          <add name="Country" type="String"/>
        </group>
        <group name="Contacts">
          <add name="Phone" type="String"/>
          <add name="Fax" type="String"/>
        </group>
      </properties>
    </profile>
  </system.web>

  <appSettings></appSettings>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="n2.initializer" type="N2.Web.InitializerModule, N2" />
      <add name="n2.mediumTrustInitializer" type="N2.MediumTrust.Web.InitializerModule, N2"/>
    </modules>
    <handlers>
      <add name="n2.ajax" path="*.n2.ashx" verb="*" type="N2.Web.AjaxRequestHandler, N2" />
    </handlers>
  </system.webServer>
</configuration>


Last but not lest i am using build 385

thanks for any help
Elizabeth
Aug 28, 2008 at 1:54 PM
Did you compile the project using my instructions?

By the way, I see that libardo released another package. I'll try to install it on godaddy as soon as possible and post the way I followed.
Aug 28, 2008 at 8:47 PM
Hi, could you debug-compile and upload the debug symbols (.pdb)? I can't see how this that exception escapes the try catch.
Aug 31, 2008 at 6:47 PM
Hello all,

Fist off I would like to thank all of you for you help so far.

Next i was able to get the site installed and to load with out any errors. kinda but more about that in a second.

the issue that i was having i was able  to solve when i tried to get the .pdb file that was requested. I then got a lazy load error which said
that it could not find my custom object. after some think i found that i had not add my app_code folder to the list under <n2><engine><assemblies>
which i have fixed.

but now i am unable to use the tree in edit mode.

I have tested Ajaxs and it is run and working. I do how ever get the pop-out panel in the upper left hand corner. but nothing else that use java script works

any ideas?

thanks for all the help,
Elizabeth
Aug 31, 2008 at 7:07 PM
Maybe the http handler, like this?
Aug 31, 2008 at 7:53 PM
Edited Aug 31, 2008 at 8:10 PM
as you can see in my post that i made this past Wednesday. my web.config  has the http handler and it works in my local host

which as of yesterday is now IIS7 in Classic mode and Medium Trust (with out needing to set it in the web.config) 


also unlike the user in the post you linked to i see the drop zones but when i try to add some item to anyone it wont work it show as if they should not be add to that zone. try the same thing on my local host and it works just fine.



Aug 31, 2008 at 10:06 PM
Strange. The host runs IIS6? Can you get .js files? Try e.g. /edit/Js/ContextMenu.js and /edit/Js/plugins.ashx
Sep 1, 2008 at 12:38 AM
Edited Sep 1, 2008 at 12:51 AM
hello,
yes i can get .js files it just that they don't work once i get them
I have been doing so read of the n2 code and i think the issue might be in the
N2.Resources.Register file i have found to parts that i don't under stand
one:

public static void JQuery(Page page)
{
#if DEBUG
JavaScript(page, Utility.ToAbsolute("~/Edit/Js/jquery-1.2.3.js"), ScriptOptions.Prioritize | ScriptOptions.Include);
#else
JavaScript(page, typeof(Register), "N2.Resources.jquery-1.2.3.min.js", ScriptOptions.Prioritize | ScriptOptions.Include);
#endif
 }

There is not file called jquery-1.2.3.js there is how ever  one all jquery-1.2.6.js

two:
 protected override void Render(HtmlTextWriter writer)
                        {
                                writer.Write("<script type='text/javascript'>");
                                writer.Write(Environment.NewLine);
                                writer.Write("<!--");
                                writer.Write(Environment.NewLine);
                                base.Render(writer);
                                writer.Write(Environment.NewLine);
                                writer.Write("//-->");
                                writer.Write(Environment.NewLine);
                                writer.Write("</script>");
                        }

why is it rendering any thing in a commented out state shouldn't those lines be change form
 
<!-- to  //<![CDATA[ and //--> to //]]>

the Javascript that is used in the DragDropControlPanel and the SlidingCurtain that are part of the master page works\
 but no where else does any one else have this issue or know why

thanks
Sep 1, 2008 at 4:41 PM
Is it possible that your working copy isn't completely up to date? When I look at the trunk it says jquery 1.2.6
Sep 11, 2008 at 11:04 PM
found what the issue was.

I had beta of VS 2008 sp 1 installed

Update to full release and was all good expect that i was getting an error when i tried to use the Tree Sort
 I did some looking and a ITreeSorter in never add to the MediumTrustEngine 



So I add this line

ItemMover im = AddComponentInstance<ItemMover>(new ItemMover(persister, dispatcher));
ItemCopyer ic = AddComponentInstance<ItemCopyer>(new ItemCopyer(persister, dispatcher));
AddComponentInstance<ICacheManager>(new CacheManager(webContext, persister, hostConfiguration));

AddComponentInstance<ITreeSorter>(new
TreeSorter(persister, editManager, webContext));

and i had no more issues

again thanks for all your help,
Elizabeth




 
Sep 12, 2008 at 10:41 PM
Good find, I've updated the sources
Aug 1, 2010 at 2:51 AM

Hi Everyone,

I've encountered the same problem.  My site works fine locally within my network, however once deployed to goddady it gives me a security exception about assemblies partially trusted.  I tried to create a new project and add a  [assembly: AllowPartiallyTrustedCallers] to the AssemblyInfo.cs file (i don't know why my previous project lacked this file).   However I got the following error:

 Error 4 The type or namespace name 'AllowPartiallyTrustedCallersAttribute' could not be found (are you missing a using directive or an assembly reference?) ... and the route to my assemblyinfo.cs file.

It appears that you have been dealing with a similar issue here. can anyone help me out please?


 

 

 

Aug 3, 2010 at 8:24 PM

Did you get a stack trace?