System.Drawing problems

Topics: Troubleshooting, Writing modules
Apr 24, 2012 at 3:24 AM

I had a problem with some file permissions on a project (orchard 1.4.10)  I've been working on for a while. I think it had something to do with originally building it all with VS2010, but then one time running VS2010 in administrator mode for some kind of debugging, but after that I started to have problems saving the files. But since I'd had the project in subversion, I just exported a fresh copy out to another location on my disk and then attempted to work on it making sure I only use the normal non-administrator version of VS2010.  But that aside, my problem with Orchard then was that I exported a recentely saved subversion copy of the project and deleted the bin folders and copied the app_data/Sites/default folder to my fresh version. I then built the project and tried to get it to run. Some parts work, but when I tried to open one of the custom modules I get an exception that says:

\Users\Bob Tournoux\AppData\Local\Temp\Temporary ASP.NET Files\orchardlocal\7c73ea9e\cd57977a\App_Web_index.cshtml.5dc47d62.3itiurze.0.cs(28): error CS0234: The type or namespace name 'Drawing' does not exist in the namespace 'System' (are you missing an assembly reference?)

I cannot figure out what module is in the 7c7ea9e\cd57977a folder. It seems to be a compiler generated thing.

The yellow screen of death error looks like:

Compiler Error Message: CS0234: The type or namespace name 'Drawing' does not exist in the namespace 'System' (are you missing an assembly reference?)

Source Error:

 
Line 26:     using System.Web.Routing;
Line 27:     using Orchard.Mvc.Html;
Line 28:     using System.Drawing;
Line 29:     
Line 30:     #line 2 "H:\BT.CMS\BT.RockinSales\src\Orchard.Web\Modules\EventRegistration\Views\Home\index.cshtml"

Compiler Error Message: CS0234: The type or namespace name 'Drawing' does not exist in the namespace 'System' (are you missing an assembly reference?)

Source Error:

 
Line 26:     using System.Web.Routing;
Line 27:     using Orchard.Mvc.Html;
Line 28:     using System.Drawing;
Line 29:     
Line 30:     #line 2 "H:\BT.CMS\BT.RockinSales\src\Orchard.Web\Modules\EventRegistration\Views\Home\index.cshtml"


Source File: c:\Users\Bob Tournoux\AppData\Local\Temp\Temporary ASP.NET Files\orchardlocal\7c73ea9e\cd57977a\App_Web_index.cshtml.5dc47d62.3itiurze.0.cs Line: 28

Anyway, it appears it does not like my System.Drawing.dll. I do have a reference set to the one at:  C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Drawing.dll

Seems like I've run into this before and it might want a different version of System or System.drawing but I cannot find it.

I wouldn't ask for help on this but I've been beating my brain for 2 days now. I may just have to recreate the project from scratch, and am ready to do that, but was hoping that IF there were something to know about the System.Drawaing.dll that someone else may have seen.

Thanks,

Bob

Bob

 

Coordinator
Apr 24, 2012 at 4:05 AM

It shouldn't set an absolute path in the project file for the reference, especially as that dll is in the GAC.

Apr 24, 2012 at 4:43 AM

The project file doesn't have an absolute path... just has:

    <Reference Include="System.Drawing">

The exception is occurring in Orchard.Mvc.ViewEngines.ThemeAwareness.ViewEngineCollectionWrapper and I see in the top of the file that there is no "using System.Drawing", only using System. Maybe that is a key although I don't know why it works in my other versison...


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

namespace Orchard.Mvc.ViewEngines.ThemeAwareness {
    public class ViewEngineCollectionWrapper : IViewEngine {
        private readonly IEnumerable<IViewEngine> _engines;

        public ViewEngineCollectionWrapper(IEnumerable<IViewEngine> engines) {
            _engines = engines.ToArray();
        }

        public ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache) {
            var searchedLocations = Enumerable.Empty<string>();
            foreach (var engine in _engines) {
                var result = engine.FindPartialView(controllerContext, partialViewName, useCache);
                if (result.View != null)
                    return result;
                if (!useCache)
                    searchedLocations = searchedLocations.Concat(result.SearchedLocations);

The exception is occurring  at the foreach somewhere...

Coordinator
Apr 24, 2012 at 7:01 PM

I don't understand what ViewEngineCollectionWrapper has to do with this: the message you posted before was clear that the error was happening in one of your custom views.

Why do you need System.Drawing from a view in the first place?

Apr 24, 2012 at 9:12 PM

I can't answer that at the moment. I think it had to do with a PayPal interface I was using which renders the buy now button. I'll dig into this some more. It's just frustrating that it all worked before and now is broken. So I will go back and retrace my steps and try again.

Thanks for looking - I was hoping someone else had seen a similar problem. I'll hopefully find the answer and if I do I'll post it.

Coordinator
Apr 24, 2012 at 9:20 PM

If it was to draw a button, there would be no reason to put that reference into a view, you'd just have an img with src pointing at some action that would do the actual drawing. I really think it should not be there.

Apr 24, 2012 at 10:46 PM

Ahhh. Well, If I put the System.Drawing.dll into my orchard.web/bin folder then it all works. well, I tend to agree with you but here is the page that requires it. I believe it has something to do with the SpiceLogic MVC controls. If I comment that out then I get an exception. Somehow I figured out that I needed that assembly. I think it is a SpiceLogic problem and I had sent in some info to them. Anyway, it all works again (with the System.Drawing.dll manually copied into the bin folder. I thought I specified that on the referenced (to copy to local) but apparently I had to do that in the orchard.web/bin file too, not just in the module. For now this will do.  Thanks for the interest...

Bob

@model SpiceLogic.PayPalCtrlForWPS.Controls.BuyNowButton
@using System.Drawing;
@using SpiceLogic.PayPalCtrlForWPS.Controls;
@using SpiceLogic.PayPalCtrlForWPS.Core;
@{
    ViewBag.Title = "New Member Thanks";
}
@{
    var name = ViewBag.Name;

    var myButton = ViewBag.Button as BuyNowButton;
    var email = ViewBag.UserEmail;
    var paypalinfo = ViewBag.PayPalInfo;

}
<h2>
    Welcome to Rockin On The Run online payment @ViewBag.Name</h2>
<div class="paypalFormsDiv">
    @if (!string.IsNullOrEmpty(email))
    { 
        <p>
            Thankyou @name for submitting your data. 
        </p>
    }
    <p>
        </p>
    @if (myButton != null)
    {
        <h2>
            <b>Pay Registration Fees Online</b></h2>
        <p>
            You have elected to pay your registration fee online. Just press the PayPal button
            and you will be taken to the PayPal site where you can pay your membership dues.
            An email will be sent to you with confirmation and you will also receive a confirmation
            report after you have completed the transaction.
        </p>
               
    }
    <p style="text-align: center;">
        @Html.Raw(ViewBag.RenderData)
    </p>
</div>
<div>
    @Html.ActionLink("Back to Registration", "Index", "Home")
</div>