how to put created module onto website

Topics: Troubleshooting, Writing modules
Dec 17, 2011 at 6:57 AM

I was trying to create a module that would access a sqlexpress database. I used the command-line codegen tool to create the structure then I just had the Index method in the controller grab all of the records from the database and create a list and had that displayed on my view. SHould be so simple! But I was getting database errors, so I thought maybe it had to run up on the real webserver instead of in Visual Studio. So I copied my module folder and all its contents up into the webserver. When I try to run my website on the webserver it does not see the module in the modules list. I read and re-read the document on creating HelloWorld, but I didn't see anything tthat told me how to get it from my dev machine to a real website.

THen I tried moving the helloworld to my website; again I could not see the module there. When I tried to just put the url into the browser it came back with not found error.

So, once I build the module how to I get it up to the site?

I tried to zip all of the module contents together and install that using the dashboard modules install from my compuiter. But there it complains that the module failed to load and that it does not have a manifest. Yet, the module.txt is in the module folder.

If I ever get this first problem solved (i.e., getting my module to install on the web) then I'll have to find out why I can't access the database; that seems to be a connection problem or mdtc problem, but that will be later topic; hopefully I'll figure it out once I get this part working.

Coordinator
Dec 17, 2011 at 7:37 AM

It really is as simple as copying the directory. Why it doesn't work in your case must be due to another cause but it's impossible to say with so little information.

Dec 17, 2011 at 1:22 PM

Well, sorry for the little info - I was tired and had to hit the sack, but was hoping to hear at least this, so I'll go at it again later today. If I don't succeed, I'll post again - I'll be more specific. But thanks for your input because I really thought that's all I had to do.

Dec 19, 2011 at 3:19 AM

I fixed that problem - Well, somewhere along the lines I developed a problem with permissions on my web server. I have worked around that by now using Web Deploy.

But now I have a new problem in that I can't access the database the same way I do in my other MVC 3 projects. Here's what I did in more detail than what I provided in the past. Perhaps you can fill me in on what I've done wrong.

I built a new Orchard Project just using the core. I got that running on my developer machine then used web deploy to put it onto my webserver. It worked fine on the development machine but gave an error on the web server but that turned out to be a missing log4net.dll. I built this as a debug version rather than release. Don't know if that is why, but I just copied the log4net.dll into my bin on the webserver and it then works.

Next I used the command line to build a hello world like module. That works fine on my development machine, and now with the new Web Deploy I was able to upload it to the webserver and it works fine.

Now my test was to modify my module to list some records out of a database. So on my development machine I added a new ADO.NET Entity Data Model and hooked it up to a single database table with several columns. In a regular MVC 3 project I just do something like this to read the data:

I create an interface named IRepository.cs and a class to implement it named Respository.cs. Then I put logic like that shown in the controller code snippet. In the test MVC 3 app it works fine, that is I am able get a collection from the data base in the controller's Index method.

If I use the same code in my Orchard Module then I get an exception when I try to invoke the GetAllArtists() method in the Contoller's Index method. I get an exception in the Repository.cs method in Orchard.Data.Repository<T> and a stack trace that looks like the one shown below.

I have written many code methods using that similar pattern but have never run into that error before. Am I missing something?

   at System.Transactions.TransactionState.EnlistVolatile(InternalTransaction tx, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)
   at System.Transactions.Transaction.EnlistVolatile(IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions)
   at NHibernate.Transaction.AdoNetWithDistrubtedTransactionFactory.EnlistInDistributedTransactionIfNeeded(ISessionImplementor session)
   at NHibernate.Impl.AbstractSessionImpl.EnlistInAmbientTransactionIfNeeded()
   at NHibernate.Impl.AbstractSessionImpl.CheckAndUpdateSessionStatus()
   at NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType)
   at NHibernate.Impl.SessionImpl.Get(String entityName, Object id)
   at NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id)
   at NHibernate.Impl.SessionImpl.Get[T](Object id)
   at Orchard.Data.Repository`1.Get(Int32 id) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\Data\Repository.cs:line 87
   at Orchard.Data.Repository`1.Orchard.Data.IRepository.Get(Int32 id) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\Data\Repository.cs:line 56
   at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\ContentManagement\DefaultContentManager.cs:line 130
   at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\ContentManagement\DefaultContentManager.cs:line 110
   at Orchard.ContentManagement.ContentGetExtensions.Get[T](IContentManager manager, Int32 id) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\ContentManagement\ContentExtensions.cs:line 146
   at Orchard.Core.Settings.Services.SiteService.GetSiteSettings() in H:\BT.CMS\BT.HacCms.12182011\src\Orchard.Web\Core\Settings\Services\SiteService.cs:line 45
   at Orchard.UI.PageTitle.PageTitleBuilder.GenerateTitle() in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\UI\PageTitle\PageTitleBuilder.cs:line 33
   at Orchard.Mvc.Html.LayoutExtensions.Title(HtmlHelper html, String[] titleParts) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\Mvc\Html\LayoutExtensions.cs:line 39
   at ASP._Page_Core_Shapes_Views_Document_cshtml.Execute() in h:\BT.CMS\BT.HacCms.12182011\src\Orchard.Web\Core\Shapes\Views\Document.cshtml:line 14
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
   at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
   at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
   at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
   at System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection)
   at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData)
   at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model)
   at Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:line 133
   at Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.<>c__DisplayClass26.<>c__DisplayClass28.b__15(DisplayContext displayContext) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:line 117
   at Orchard.DisplayManagement.Descriptors.ShapeAlterationBuilder.<>c__DisplayClass3.<>c__DisplayClass5.b__2(DisplayContext displayContext) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:line 55
   at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 176
   at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 95
   at Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 71
   at Orchard.DisplayManagement.Implementation.DisplayHelper.Invoke(String name, INamedEnumerable`1 parameters) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:line 38
   at Orchard.DisplayManagement.Implementation.DisplayHelperFactory.DisplayHelperBehavior.InvokeMember(Func`1 proceed, Object target, String name, INamedEnumerable`1 args) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\DisplayManagement\Implementation\DisplayHelperFactory.cs:line 27
   at ClaySharp.ClayBehaviorCollection.<>c__DisplayClass14.<>c__DisplayClass16.b__13() in C:\Users\sebros\My Projects\Clay\src\ClaySharp\ClayBehaviorCollection.cs:line 29
   at ClaySharp.ClayBehaviorCollection.Execute(Func`1 proceed, Func`3 linker) in C:\Users\sebros\My Projects\Clay\src\ClaySharp\ClayBehaviorCollection.cs:line 13
   at ClaySharp.ClayBehaviorCollection.InvokeMember(Func`1 proceed, Object self, String name, INamedEnumerable`1 args) in C:\Users\sebros\My Projects\Clay\src\ClaySharp\ClayBehaviorCollection.cs:line 29
   at Orchard.Mvc.ViewEngines.ThemeAwareness.LayoutAwareViewEngine.<>c__DisplayClass7.b__5(ViewContext viewContext, TextWriter writer, IViewDataContainer viewDataContainer) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\Mvc\ViewEngines\ThemeAwareness\LayoutAwareViewEngine.cs:line 63
   at Orchard.Mvc.ViewEngines.ThemeAwareness.LayoutAwareViewEngine.LayoutView.Render(ViewContext viewContext, TextWriter writer) in H:\BT.CMS\BT.HacCms.12182011\src\Orchard\Mvc\ViewEngines\ThemeAwareness\LayoutAwareViewEngine.cs:line 90
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.b__19()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)

--- controller code snippet ---

        IArtistRepository repo;

        public ArtistDataController() : this(new ArtistRepository())
        {
        }

        public ArtistDataController(IArtistRepository repository)
        {
            repo = repository;
        }


        public ActionResult Index()
        {
            var result = repo.GetAllArtists().ToList();

            return View(result);
        }
---- end of controller code snippet ---
----- IRepository Interface ----
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BT.MVC.HAC.Models
{
    public interface IArtistRepository
    {
        IQueryable<Artist> GetAllArtists();
        void DeleteAnArtist(Artist artist);
        void AddArtist(Artist artist);
        Artist GetArtistById(int id);
        IQueryable<Artist> GetArtistsFromZip(string zip);
    }
}
----- IRepository Interface ----

  ------- Repository Implementation -----

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BT.MVC.HAC.Models
{
    public class ArtistRepository : IArtistRepository
    {
        Hac_CmsEntities db;

        public ArtistRepository()
        {
            db = new Hac_CmsEntities();
        }

        #region IArtistRepository Members

        public IQueryable<Artist> GetAllArtists()
        {
            var result = from p in db.Artists
                         select p;
            return result;

        }

        public void DeleteAnArtist(Artist artist)
        {
            db.DeleteObject(artist);
        }

        public void AddArtist(Artist artist)
        {
            db.Artists.AddObject(artist);
        }

        public Artist GetArtistById(int id)
        {
            var result = from p in GetAllArtists()
                         where p.ID == id
                         select p;
            return result.FirstOrDefault();
        }

        public IQueryable<Artist> GetArtistsFromZip(string zip)
        {
            var result = from p in GetAllArtists()
                         where p.Zip == zip
                         select p;
            return result;
        }

        public void Save()
        {
            db.SaveChanges();
        }

        #endregion
    }
}

 ------- Repository Implementation -----