Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9075859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:58:07+00:00 2026-06-16T18:58:07+00:00

I am using a simple method to output a image, and if the media

  • 0

I am using a simple method to output a image, and if the media type has a link attached to it, it will act as a link. This method has been working for months and months, but suddenly a customer complained over it not working.

My razor macro in its entirety looks like this:

@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext

@{
    var topImageId = Model._topImage;

    if ( topImageId != null ) {

        var topImage = Library.MediaById(topImageId);
        var linkId = topImage._link;
        string cssStyle = string.Format( "background-image:url({0});height:{1}px;", topImage.umbracoFile, topImage.umbracoHeight );

        <div id="topImage"

        @if(!string.IsNullOrEmpty(linkId)){

            var tempNode = @Model.NodeById(linkId);
            @Html.Raw(string.Format(" onclick=\"window.location.href='{0}'\"", @tempNode.Url));

            cssStyle += " cursor: pointer;";
        }

        @Html.Raw( string.Format( "style=\"{0}\"", cssStyle ) )

        ></div>

    }
}

and it produces these two errors:

Error Loading Razor Script (file: Top Image) The best overloaded method match for 'string.IsNullOrEmpty(string)' has some invalid arguments    at CallSite.Target(Closure , CallSite , Type , Object )
  at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
  at ASP._Page_macroScripts_general_topImage_cshtml.Execute() in d:\inetpub\wwwroot\friendtex.com\www\macroScripts\general\topImage.cshtml:line 15
  at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
  at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
  at System.Web.WebPages.WebPage.ExecutePageHierarchy()
  at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
  at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
  at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage) 0.741249    0.004230

and

Error loading MacroEngine script (file: /general/topImage.cshtml, Type: ''
The best overloaded method match for 'string.IsNullOrEmpty(string)' has some invalid arguments
  at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)

I suspected the image itself to be the root of the cause, but the media image is absolutely as it should be and I cant see any difference. And to add to the weird-factor – the macro works just perfect with any other image. The image that fails can be found here

EDIT:

For some odd reason, if I do GetType() on the image as Douglas suggested, and it returns a Umbraco.MacroEngines.DynamicXml object, where it on any other image returns a string. It just keep on getting weirder and weirder.

SECOND EDIT:

I decided to throw the code out and rewrite the entire thing using the technique Kevin Hendricks suggested. Now all of a sudden, I get no errors and it works just perfectly. Only difference is a couple of .ToString() a couple of places.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:58:09+00:00Added an answer on June 16, 2026 at 6:58 pm

    It sounds stupid but you might want to convert the var linkId to a string. If for some reason the generic var object sees it as an integer, Uri or different, than problems like these will arrise

    var topImage = Library.MediaById(topImageId);
    var linkId = topImage._link;
    if (!string.IsNullOrEmpty(linkId.ToString()))
    {
    
    }
    

    Prefer:

    var topImage = Library.MediaById(topImageId); 
    string linkId = topImage._link.ToString(); 
    if (!string.IsNullOrEmpty(linkId)) 
    { 
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have managed to hide one image into another using this simple method. Cover
im using simple vector push_back to object of Type A and getting this error
I'm using a simple implementation of saxParser. Within my endElement method, I'm storing vo
I'm trying to do a simple example using jQuerys fadeTo method. It works as
Using simple type like class A { public int X, Y; } with object
I am using simple HTML page for upload and post image to servlet then
I'm creating simple Socket server. Flex application will be client for this server. On
I am working on a tool for Windows that will interface with CloudApp using
Background: Customer X has a CCK-based Content Type (vendorxxentry) and is using Views2 to
I am working on image filter app. I have created the filter using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.