PackageType is always null

Mar 6, 2011 at 5:18 PM

When I try to upload new package, first step, actual upload file, goes fine. But next, when you submit form populated with package info, fails because PackageType is always null. Even though Fiddler shows that form fields submitted fine, including correct PackageType. To make it more fun, same code works fine in local environment and only fails on the host, so it is impossible to debug. Nothing interesting in the logs. Any thoughts what it can be?

Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 34:             var iconLinkText = string.Empty;
Line 35: }
Line 36: <ul class="@Model.PackageType.ToLower()">
Line 37: @if (!string.IsNullOrWhiteSpace(Model.IconUrl)) {
Line 38: <li class="logo"><img src="@Model.IconUrl" alt="Package Icon" /><span class="violator">Logo</span></li>


Source File: e:\web\dnbegall\cms\Themes\OrchardGallery\Views\Orchard.Gallery\UploadPackageLogoAndScreenshots\Index.cshtml    Line: 36

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
ASP._Page_Themes_OrchardGallery_Views_Orchard_Gallery_UploadPackageLogoAndScreenshots_Index_cshtml.Execute() in e:\web\dnbegall\cms\Themes\OrchardGallery\Views\Orchard.Gallery\UploadPackageLogoAndScreenshots\Index.cshtml:36
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +209
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +89
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +199
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
Orchard.Mvc.ViewEngines.ThemeAwareness.<>c__DisplayClass7.<FindView>b__5(ViewContext viewContext, TextWriter writer, IViewDataContainer viewDataContainer) in D:\Projects\vs2010\Orchard-1020\src\Orchard\Mvc\ViewEngines\ThemeAwareness\LayoutAwareViewEngine.cs:54
Orchard.Mvc.ViewEngines.ThemeAwareness.LayoutView.Render(ViewContext viewContext, TextWriter writer) in D:\Projects\vs2010\Orchard-1020\src\Orchard\Mvc\ViewEngines\ThemeAwareness\LayoutAwareViewEngine.cs:84
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +264
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +176
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +329
System.Web.Mvc.Controller.ExecuteCore() +115
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +94
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +31
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +23
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +59
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in D:\Projects\vs2010\Orchard-1020\src\Orchard\Mvc\Routes\ShellRoute.cs:155
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Mar 11, 2011 at 1:33 PM

I am also get this error.

Orchard Gallery doesn't  recognize "PackageType"  When submitting a package.

Some One know how to fix it?

Coordinator
Mar 11, 2011 at 4:04 PM

Are you sure the PackageType is getting submitted from the previous form? The PackageTypes come from the top-level terms in the taxonomy that you define. If you don't have a taxonomy, the PackageType input field on the new/edit form will be empty so nothing will post for it.

So if it is actually posting the value, can you check your GalleryServer database to see that it's actually getting to the server and being saved in the Package table? The UploadPackageLogoAndScreenshots page simply asks the server for the package that was just submitted on the previous form. So if it's getting submitted correctly the exact same package data should come back on that next page.

Mar 11, 2011 at 7:30 PM

This error is a little misleading. What really happened in my case, the WebDav module installed on the host was configured to handle all requests, and it got to .svc before specific .svc handler.

And because WebDav only handles GET requests, it would throw error on POST so that request would never make it to .svc handler.
Long story short, try to remove WebDav module either using “remove” directive in web.config or going to IIS and disabling module for your site. At least this fixed it for me.


 


Mar 12, 2011 at 7:39 AM
Edited Mar 12, 2011 at 7:39 AM

http://one-v.co.il/files/Orchard/1.jpg

I have a "Taxonomies" module.

When I trying to upload theme I get the list:

http://one-v.co.il/files/Orchard/2.jpg,

Gallery Server creates database record:

http://one-v.co.il/files/Orchard/3.jpg

but packageType is NULL.

 

p.s

I working on localhost

Coordinator
Mar 15, 2011 at 9:11 PM

This is strange. If the Edit form is posting, and you have a value selected for Package Type (like shown in screenshot 2), then the value should be saved in the record on Gallery Server. Since you're working on localhost, have you tried debugging the Update service method on the server? The Edit forms posts to the Update method in PackageService and passes in a Package instance. If you breakpoint right at the start of the Update method, does the Package instance being passed in have a value for the PackageType property?

Coordinator
Mar 15, 2011 at 9:15 PM

Also, it would be good to check the logs on Gallery Server. The server will log exceptions to a Logs folder in the Gallery.Server project folder. Check to see if any exceptions are being logged there when you try to update a package.

Apr 20, 2011 at 1:30 AM

I am also experiencing this error. For a temporary work around what are the acceptable values for Module and Theme.

Coordinator
Apr 20, 2011 at 2:24 PM

The acceptable values for the PackageType are up to each implementation of a gallery. They are defined by how you setup your taxonomy, using the Taxonomies module in Orchard. The values displayed in the dropdown list on the Edit page are taken from the Name property of the top-level taxonomy terms. For Orchard, the values are 'Module' and 'Theme'. But you can use whatever terms make sense for your gallery. For example, the NuGet gallery just has one term named 'Package'.

Jun 8, 2011 at 12:28 PM

I am also receiving the exact same error message when trying to upload packages to my local Nuget Gallery Server.

I’ve had a look in the Gallery.Server\App_Data folder and can see the folder “packages” populate with the package I’m trying to upload before it craps out but when I look at “App_Data\Logs the GalleryServer.log is empty.

Think I’ve hit a wall with this so if anyone has any ideas or suggestions it would be greatly appreciated

Thanks


Jan 18, 2012 at 7:11 PM

Getting the same error too :(

Jan 18, 2012 at 7:25 PM

From what I can see the package gets created on the Nuget Gallery Server BEFORE you can select what type of package it is (i.e. a Module). Then when it posts from the next page where you fill out additional information, it simply keeps trying to use the PackageType it gets from the Nuget Package Server, not the one you select.. so it always stays NULL. Can't see how to resolve this though -_-

Oct 22 at 11:47 AM
Edited Oct 22 at 11:49 AM
In my case the weird behaviour was caused by WebDAV module intercepting REST verb PUT.
In the first step, when you first upload the module file, the UI will use POST request to the gallery server to create the package. This step works fine and the record is created in the database without the "PackageType" field being populated. @hai2u: This is correct behaviour, the PackagesType should be populated in the next step.
In the next step you can update the module details (including "Package Type"). When you submit the form the UI will use PUT request (following REST protocol) to the gallery server to update the package detail. In this step the WebDAV module seems to intercept the request, so the data doesn't get updated.
The fix is to disable the the WebDAV module in the gallery server Web.config. In my cases the config looks something like this:
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
.
.
.
     <remove name="WebDAVModule" />
    </modules>
    <handlers>
       <remove name="WebDAV" />
.
.
.
    </handlers>